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

Last change on this file since 553 was 553, checked in by bcornec, 14 years ago

Build process in 3 steps:

svn2build creates tar files from SVN (works mostly)
build2pkg creates packages from tar files (works mostly)
build2qemu (has to be created from mkqemu) will create packages for all supported virtuel machines

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