source: branches/stable/tools/distro-env @ 596

Last change on this file since 596 was 596, checked in by bcornec, 13 years ago

Build process fixes following first attempt to deliver 2.0.8

  • Property svn:executable set to *
File size: 3.6 KB
Line 
1#!/bin/bash
2#
3# Create env depending on the distro on which we are
4#
5# $Id$
6#
7# Input parameters : $ddir (distro name) and $dver (distro version)
8# If they do not exist then deduce from current distro
9# Exports : $dfam (distro family) $suf (pkg suffix) $dtype (distro type) BUILDDIR (dir to build packages)
10
11#
12# Guess ddir and dver from the underlying distro
13#
14if [ _"$ddir" = _"" ]; then
15    if [ -e /etc/mandriva-release ]; then
16        export ddir="mandriva"
17        export dver=`awk '{print $4}' /etc/mandriva-release`
18    elif [ -e /etc/mandrake-release ]; then
19        export ddir="mandrake"
20        export dver=`awk '{print $3}' /etc/mandrake-release`
21    elif [ -e /etc/redhat-release ]; then
22        grep -q Enterprise /etc/redhat-release
23        if [ $? -eq 0 ]; then
24            export ddir="rhel"
25            export dver=`awk '{print $7}' /etc/redhat-release`
26        elif grep -q Fedora /etc/redhat-release ; then
27            export ddir="fedora"
28            export dver=`awk '{print $4}' /etc/redhat-release`
29        else
30            export ddir="redhat"
31            export dver=`awk '{print $5}' /etc/redhat-release`
32        fi
33    elif [ -e /etc/SuSE-release ]; then
34        grep -q Enterprise /etc/SuSE-release
35        if [ $? -eq 0 ]; then
36            export ddir="sles"
37            export dver=`head -1 /etc/SuSE-release | awk '{print $5}'`
38        else
39            export ddir="suse"
40            export dver=`head -1 /etc/SuSE-release | awk '{print $3}'`
41        fi
42    elif [ -e /etc/gentoo-release ]; then
43        export ddir="gentoo"
44        export dver=`awk '{print $5}' /etc/gentoo-release | cut -d. -f1-2`
45    elif [ -e /etc/debian_version ]; then
46        export ddir="debian"
47        export dver=`cat /etc/debian_version`
48        # Debian assigns release names only once a release actually happens.
49        # Debian does not distinguish between testing and unstable because
50        # unstable today is what testing will be in about ten days time. So,
51        # in case we encounter "tesing/unstable", we assume unstable, i.e. sid.
52        # Note that for released versions, the numeric version will be contained
53        # in debian_version, e.g. on a sarge system, the value will be '3.1'.
54        if [ $dver = "testing/unstable" ]; then
55            export dver = "sid"
56        fi
57    else
58        export ddir="unknown"
59        export dver=""
60    fi
61fi
62
63#
64# Generate all other parameters
65#
66if [ $ddir = "debian" ]; then
67    dfam="debian"
68    dtype="deb"
69    suf=".${dfam}${dver}"
70    BUILDDIR=${TOPDIR}/debian
71elif [ $ddir = "gentoo" ]; then
72    dfam="gentoo"
73    dtype="ebuild"
74    suf=".${ddir}${dver}"
75    BUILDDIR=${TOPDIR}/ebuild
76elif [ $ddir = "slackware" ]; then
77    dfam="slack"
78    dtype="tgz"
79    suf=".${dfam}${dver}"
80    BUILDDIR=${TOPDIR}/slack
81elif [ $ddir = "sles" -o $ddir = "suse" ]; then
82    dfam="suse"
83    dtype="rpm"
84    suf=".${ddir}${dver}"
85    BUILDDIR=${TOPDIR}/SPECS
86elif [ $ddir = "fedora" -o $ddir = "redhat" -o $ddir = "rhel" ]; then
87    dfam="redhat"
88    dtype="rpm"
89    dver1=`echo ${dver} | sed "s/\.//"`
90    if [ $ddir = "fedora" ]; then
91        suf=".fc${dver1}"
92    elif [ $ddir = "redhat" ]; then
93        suf=".rh${dver1}"
94    else
95        suf=".rhel${dver1}"
96    fi
97    BUILDDIR=${TOPDIR}/SPECS
98elif [ $ddir = "mandrake" -o $ddir = "mandriva" ]; then
99    dfam="mandriva"
100    dtype="rpm"
101    suf=".`echo $dver | sed 's/\.//'`mdk"
102    BUILDDIR=${TOPDIR}/SPECS
103else
104    dfam="unknown"
105    dtype="unknown"
106    BUILDDIR=${TOPDIR}/SPECS
107    suf="unknown"
108fi
109
110export dfam
111export dtype
112export BUILDDIR
113export suf
114
115#
116# Additional exports and preparation for some distros
117#
118if [ _"$dtype" = _"rpm" ]; then
119    export ARCH=`rpm --showrc | egrep "^build arch" | awk '{print $4}'`
120    if [ -f ${HOME}/.rpmmacros ]; then
121        export TOPBUILDDIR=`egrep '^%_topdir' ${HOME}/.rpmmacros | awk '{print $2}'`
122    else
123        export TOPBUILDDIR=${BASE}/build
124    fi
125    mkdir -p ${TOPBUILDDIR}/{RPMS,SRPMS,SPECS,SOURCES,BUILD}
126elif [ _"$dtype" = _"ebuild" ]; then
127    export TOPBUILDDIR=${BASE}/build
128    mkdir -p ${TOPBUILDDIR}/portage
129fi
Note: See TracBrowser for help on using the repository browser.