source: branches/stable/tools/build2pkg

Last change on this file was 1591, checked in by Bruno Cornec, 13 years ago
  • Improve tape support doc (Tilman Schmidt <tilman_at_imap.cc>)
  • mdadm.conf files added to deplist
  • Fix gentoo issues again (Francesco Talamona ti.liame_at_email.it)
  • Fix bug #187 (Scott Cummings rsc_at_usfamily.net)

(merge -r1579:1590 $SVN_M/branches/2.2.5)

  • Property svn:executable set to *
File size: 5.5 KB
Line 
1#!/bin/bash
2#
3# Creates packages from build repository
4#
5# $Id$
6#
7# Syntax: build2pkg [version-tag [pkg list]]
8#
9
10(
11dname=`dirname $0`
12prem=`echo $dname |cut -c1`
13if [ _${prem} = _"/" ]; then
14    export TOOLHOME=$dname
15else
16    export TOOLHOME=${PWD}/$dname
17fi
18
19. $TOOLHOME/common-env
20. $TOOLHOME/distro-env
21
22# We need to get $VER and $TAG
23if [ "$1" = "" ]; then
24    LAST=`cat ${TOPDIR}/LAST`
25else
26    LAST=$1
27    shift
28fi
29VER=`echo $LAST | cut -d- -f1`
30TAG=`echo $LAST | cut -d- -f2`
31echo "Working on ${VER}-$TAG"
32   
33if [ "$1" = "" ]; then
34    c="mondo-doc mindi mindi-busybox mondo"
35else
36    if [ "$1" = "all" ]; then
37        c="mindi-kernel mondo-doc mindi mindi-busybox mondo"
38    else
39        c="$*"
40    fi
41fi
42
43status=0
44
45#
46# Define on which distro we are to generate the right packages
47#
48
49export pkg=""
50echo "Working under $TOPBUILDDIR"
51cd $TOPBUILDDIR
52
53for p in $c; do
54    # s= stable; t = trunk; 1-9 = official version
55    src=${TOPDIR}/${VER}-$TAG/$p-[1-9st]*.tar.gz
56    echo "Source file: $src"
57    pv=`basename $src .tar.gz`
58    PVER=`echo $pv | sed "s|^$p-||" | cut -d- -f1`
59
60    if [ _"$p" = _"mindi" ]; then
61        # Copy FindDistroFailsafe if it makes sense for that distro
62        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/FindDistroFailsafe 2> /dev/null
63        ln $p-${PVER}/distributions/${ddir}-$dver/FindDistroFailsafe $p-${PVER} 2> /dev/null
64    fi
65
66    if [  _"$dtype" = _"rpm" ]; then
67        if [ _"$p" = _"mondo-doc" ] || [ _"$p" = _"mindi" ]; then
68            ar="noarch"
69        else
70            ar=$ARCH
71        fi
72
73        log=$MONDOTMP/$p-rpm.log
74
75        if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then
76            echo "Using bzip2 files ($dfam)"
77            ln -sf ${TOPDIR}/${VER}-$TAG/$pv.tar.bz2 SOURCES/
78        else
79            echo "Using gzip files ($dfam)"
80            ln -sf $src SOURCES/
81        fi
82        echo "Generating $p RPMS"
83        cd SPECS
84        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p.spec
85        mv $p-${PVER}/distributions/${ddir}-$dver/$p.spec .
86        rm -rf $p-${PVER}
87
88        # set LANGUAGE to check for correct log messages
89        export LANGUAGE=C
90        rpmbuild -ba $p.spec 2>&1 | tee $log
91        if [ $? != 0 ]; then 
92            status=-1
93        else
94            export pkg1="`egrep '^Wrote:' $log | grep -v debug | cut -d: -f2`"
95            if [ -f /usr/bin/rpmlint ]; then
96                /usr/bin/rpmlint $pkg1
97            else
98                echo "No rpmlint found, please install it"
99            fi
100            export pkg="$pkg `ls $pkg1 | grep -v src.rpm`"
101        fi
102        rm -rf ${TOPBUILDDIR}/BUILD/*
103        cd ..
104    elif [  _"$dtype" = _"ebuild" ]; then
105        if [ _"$p" = _"mondo" ]; then
106            eb="mondo-rescue"
107        else
108            eb=$p
109        fi
110        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$eb-${PVER}.ebuild
111        if [ _"`grep $TOPBUILDDIR/portage /etc/make.conf`" = _"" ]; then
112            echo "Adding $TOPBUILDDIR/portage to /etc/make.conf"
113            echo "PORTDIR_OVERLAY=\"$TOPBUILDDIR/portage\"" >> /etc/make.conf
114        fi
115
116        mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$eb
117        mv $p-${PVER}/distributions/${ddir}-$dver/$eb-${PVER}.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p/$eb-${PVER}.ebuild
118        rm -rf $p-${PVER}
119
120        cd ${TOPBUILDDIR}/portage/sys-apps/$eb
121        ebuild $eb-${PVER}.ebuild digest
122        if [ $? != 0 ]; then 
123            status=-1
124        fi
125        ebuild $eb-${PVER}.ebuild package
126        if [ $? != 0 ]; then 
127            status=-1
128        fi
129        export pkg="$pkg $eb-${PVER}.ebuild"
130    elif [  _"$dtype" = _"deb" ]; then
131        cd $TOPBUILDDIR
132        tar xfz $src
133        cd ${p}-${PVER}
134        # point to the right debian conf
135        ln -s distributions/${ddir}-$dver debian
136        dpkg-buildpackage -us -uc -rfakeroot
137        export pkg="$pkg $p-${PVER}.deb"
138        # Et voila !
139    elif [  _"$dtype" = _"port" ]; then
140        cd $TOPBUILDDIR
141        tar xfz $src
142        cd ${p}-${PVER}
143        mv distributions/${ddir}-$dver/* $TOPBUILDDIR
144        cd ..
145        rm -rf ${p}-${PVER}
146        make DISTDIR=$TOPBUILDDIR
147    elif [  _"$dfam" = _"slackware" ]; then
148        mkdir -p $TOPBUILDDIR/build-${p}/install
149        cd $TOPBUILDDIR
150        tar xfz $src
151        cd ${p}-${PVER}
152        mv distributions/${ddir}-$dver/slack-* $TOPBUILDDIR/build-${p}/install
153        if [ -e distributions/${ddir}-$dver/doinst.sh ]; then
154            mv distributions/${ddir}-$dver/doinst.sh $TOPBUILDDIR/build-${p}/install
155        fi
156        if [ _"$p" = _"mindi-busybox" ]; then
157            make oldconfig
158            make busybox
159            DESTDIR=$TOPBUILDDIR/build-${p}/usr/lib/mindi/rootfs
160            make PREFIX=$DESTDIR install
161        elif [ _"$p" = _"mindi" ]; then
162            export DONT_RELINK=1
163            export HEAD=$TOPBUILDDIR/build-${p}
164            export PREFIX=/usr
165            export CONFDIR=/etc
166            export MANDIR=/usr/man
167            export DOCDIR=/usr/doc
168            export LIBDIR=/usr/lib
169            export CACHEDIR=/var/cache/mindi
170            export PKGBUILDMINDI="true"
171            ./install.sh
172        elif [ _"$p" = _"mondo" ]; then
173            ./configure --prefix=/usr
174            make VERSION=$PVER
175            make DESTDIR=$TOPBUILDDIR/build-${p} install
176            mkdir -p $DESTDIR/var/cache/mondo
177        elif [ _"$p" = _"mondo-doc" ]; then
178            make -f Makefile.man VERSION=$PVER
179            make -f Makefile.howto VERSION=$PVER
180            make -f Makefile.man install INSTALLDIR=$TOPBUILDDIR/build-${p}/usr/doc/$p-${PVER}
181            make -f Makefile.howto install INSTALLDIR=$TOPBUILDDIR/build-${p}/usr/doc/$p-${PVER}
182        else
183            echo "Package $p not configured for $dfam"
184        fi
185        cd $TOPBUILDDIR/build-${p}
186        ar=`uname -m`
187        pkg1=$p-${PVER}-${ar}-${TAG}mr.tgz
188        echo "Running sudo /sbin/makepkg -p -l y -c y $pkg1"
189        sudo /sbin/makepkg -p -l y -c y $pkg1
190        export pkg="$pkg $pkg1"
191    else
192        echo "Unknown"
193    fi
194done
195echo "Packages handled : $pkg"
196
197rm -rf $MONDOTMP
198
199if [ $status = 0 ]; then
200    echo "Installing packages as root"
201    if [  _"$dtype" = _"rpm" ]; then
202        sudo rpm -Uvh --force $pkg
203    elif [  _"$dtype" = _"ebuild" ]; then
204        sudo emerge $pkg
205    elif [  _"$dtype" = _"deb" ]; then
206        sudo dpkg -i $pkg
207    elif [  _"$dtype" = _"port" ]; then
208        sudo echo empty
209    elif [  _"$dfam" = _"slackware" ]; then
210        sudo installpkg $pkg
211    else
212        echo "No method to install those packages"
213    fi
214fi
215) 2>&1 | tee /tmp/build2pkg.log
Note: See TracBrowser for help on using the repository browser.