source: MondoRescue/branches/stable/tools/distro-env @ 882

Last change on this file since 882 was 882, checked in by Bruno Cornec, 14 years ago
  • Build process reviewed to fix again bug #79
  • MONDOTMP now used uniformaly across all scripts
  • mandriva has its own set of variables
  • svn2build should now generate directories in the right place
  • Property svn:executable set to *
File size: 3.5 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) TOPBUILDDIR (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}"
70elif [ $ddir = "gentoo" ]; then
71    dfam="gentoo"
72    dtype="ebuild"
73    dver1=`echo ${dver} | sed "s/\.//"`
74    suf=".${ddir}${dver1}"
75elif [ $ddir = "slackware" ]; then
76    dfam="slack"
77    dtype="tgz"
78    suf=".${dfam}${dver}"
79elif [ $ddir = "sles" -o $ddir = "suse" ]; then
80    dfam="suse"
81    dtype="rpm"
82    suf=".${ddir}${dver}"
83elif [ $ddir = "fedora" -o $ddir = "redhat" -o $ddir = "rhel" ]; then
84    dfam="redhat"
85    dtype="rpm"
86    dver1=`echo ${dver} | sed "s/\.//"`
87    if [ $ddir = "fedora" ]; then
88        suf=".fc${dver1}"
89    elif [ $ddir = "redhat" ]; then
90        suf=".rh${dver1}"
91    else
92        suf=".rhel${dver1}"
93    fi
94elif [ $ddir = "mandrake" ]; then
95    dfam="mandriva"
96    dtype="rpm"
97    suf=".`echo $dver | sed 's/\.//'`mdk"
98elif [ $ddir = "mandriva" ]; then
99    dfam="mandriva"
100    dtype="rpm"
101    suf=".`echo $dver | sed 's/\.//'`mdv"
102else
103    dfam="unknown"
104    dtype="unknown"
105    suf="unknown"
106fi
107
108export dfam
109export dtype
110export suf
111
112#
113# Additional exports and preparation for some distros
114#
115
116# Default
117export TOPBUILDDIR=${TOPDIR}/../build
118
119if [ _"$dtype" = _"rpm" ]; then
120    export ARCH=`rpm --showrc | egrep "^build arch" | awk '{print $4}'`
121    if [ -f ${HOME}/.rpmmacros ]; then
122        export TOPBUILDDIR=`egrep '^%_topdir' ${HOME}/.rpmmacros | awk '{print $2}'`
123    fi
124    mkdir -p ${TOPBUILDDIR}/{RPMS,SRPMS,SPECS,SOURCES,BUILD}
125elif [ _"$dtype" = _"deb" ]; then
126    mkdir -p ${TOPBUILDDIR}
127elif [ _"$dtype" = _"ebuild" ]; then
128    mkdir -p ${TOPBUILDDIR}/portage
129fi
Note: See TracBrowser for help on using the repository browser.