source: trunk/tools/distro-env @ 561

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

merge -r 542:560 $SVN_M/branches/stable

  • Property svn:executable set to *
File size: 2.9 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 | sed "s/\.//"`
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    else
46        export ddir="unknown"
47        export dver=""
48    fi
49fi
50
51#
52# Generate all other parameters
53#
54if [ $ddir = "debian" ]; then
55    dfam="debian"
56    dtype="deb"
57    suf=".${dfam}${dver}"
58    BUILDDIR=${TOPDIR}/debian
59elif [ $ddir = "gentoo" ]; then
60    dfam="gentoo"
61    dtype="ebuild"
62    suf=".${ddir}${dver}"
63    BUILDDIR=${TOPDIR}/ebuild
64elif [ $ddir = "slackware" ]; then
65    dfam="slack"
66    dtype="tgz"
67    suf=".${dfam}${dver}"
68    BUILDDIR=${TOPDIR}/slack
69elif [ $ddir = "sles" -o $ddir = "suse" ]; then
70    dfam="suse"
71    dtype="rpm"
72    suf=".${ddir}${dver}"
73    BUILDDIR=${TOPDIR}/SPECS
74elif [ $ddir = "fedora" -o $ddir = "redhat" -o $ddir = "rhel" ]; then
75    dfam="redhat"
76    dtype="rpm"
77    dver=`echo ${dver} | sed "s/\.//"`
78    if [ $ddir = "fedora" ]; then
79        suf=".fc${dver}"
80    elif [ $ddir = "redhat" ]; then
81        suf=".rh${dver}"
82    else
83        suf=".rhel${dver}"
84    fi
85    BUILDDIR=${TOPDIR}/SPECS
86elif [ $ddir = "mandrake" -o $ddir = "mandriva" ]; then
87    dfam="mandriva"
88    dtype="rpm"
89    suf=".`echo $dver | sed 's/\.//'`mdk"
90    BUILDDIR=${TOPDIR}/SPECS
91else
92    dfam="unknown"
93    dtype="unknown"
94    BUILDDIR=${TOPDIR}/SPECS
95    suf="unknown"
96fi
97
98export dfam
99export dtype
100export BUILDDIR
101export suf
102
103#
104# Additional exports and preparation for some distros
105#
106if [ _"$dtype" = _"rpm" ]; then
107    export ARCH=`rpm --showrc | egrep "^build arch" | awk '{print $4}'`
108    if [ -f ${HOME}/.rpmmacros ]; then
109        export TOPBUILDDIR=`egrep '^%_topdir' ${HOME}/.rpmmacros | awk '{print $2}'`
110    else
111        export TOPBUILDDIR=${BASE}/build
112    fi
113    mkdir -p ${TOPBUILDDIR}/{RPMS,SRPMS,SPECS,SOURCES,BUILD}
114fi
Note: See TracBrowser for help on using the repository browser.