source: MondoRescue/branches/stable/tools/build2pkg @ 3656

Last change on this file since 3656 was 1591, checked in by Bruno Cornec, 14 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
RevLine 
[553]1#!/bin/bash
2#
3# Creates packages from build repository
4#
5# $Id$
6#
7# Syntax: build2pkg [version-tag [pkg list]]
8#
9
[757]10(
[553]11dname=`dirname $0`
12prem=`echo $dname |cut -c1`
[1042]13if [ _${prem} = _"/" ]; then
[553]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
[825]34    c="mondo-doc mindi mindi-busybox mondo"
[553]35else
36    if [ "$1" = "all" ]; then
[825]37        c="mindi-kernel mondo-doc mindi mindi-busybox mondo"
[553]38    else
[924]39        c="$*"
[553]40    fi
41fi
42
43status=0
44
45#
46# Define on which distro we are to generate the right packages
47#
48
49export pkg=""
[572]50echo "Working under $TOPBUILDDIR"
[553]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
[1263]56    echo "Source file: $src"
[553]57    pv=`basename $src .tar.gz`
[753]58    PVER=`echo $pv | sed "s|^$p-||" | cut -d- -f1`
[553]59
[1063]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
[553]66    if [  _"$dtype" = _"rpm" ]; then
[1121]67        if [ _"$p" = _"mondo-doc" ] || [ _"$p" = _"mindi" ]; then
[556]68            ar="noarch"
69        else
70            ar=$ARCH
71        fi
[553]72
[882]73        log=$MONDOTMP/$p-rpm.log
[553]74
[733]75        if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then
[763]76            echo "Using bzip2 files ($dfam)"
[781]77            ln -sf ${TOPDIR}/${VER}-$TAG/$pv.tar.bz2 SOURCES/
[553]78        else
[763]79            echo "Using gzip files ($dfam)"
[553]80            ln -sf $src SOURCES/
81        fi
[568]82        echo "Generating $p RPMS"
[553]83        cd SPECS
[753]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}
[553]87
[924]88        # set LANGUAGE to check for correct log messages
89        export LANGUAGE=C
[761]90        rpmbuild -ba $p.spec 2>&1 | tee $log
[553]91        if [ $? != 0 ]; then 
92            status=-1
[690]93        else
[888]94            export pkg1="`egrep '^Wrote:' $log | grep -v debug | cut -d: -f2`"
[733]95            if [ -f /usr/bin/rpmlint ]; then
[888]96                /usr/bin/rpmlint $pkg1
[733]97            else
98                echo "No rpmlint found, please install it"
99            fi
[888]100            export pkg="$pkg `ls $pkg1 | grep -v src.rpm`"
[553]101        fi
[596]102        rm -rf ${TOPBUILDDIR}/BUILD/*
[553]103        cd ..
[572]104    elif [  _"$dtype" = _"ebuild" ]; then
[1591]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
[572]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
[556]115
[1591]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
[753]118        rm -rf $p-${PVER}
[572]119
[1591]120        cd ${TOPBUILDDIR}/portage/sys-apps/$eb
121        ebuild $eb-${PVER}.ebuild digest
[556]122        if [ $? != 0 ]; then 
123            status=-1
124        fi
[1591]125        ebuild $eb-${PVER}.ebuild package
[572]126        if [ $? != 0 ]; then 
127            status=-1
128        fi
[1591]129        export pkg="$pkg $eb-${PVER}.ebuild"
[574]130    elif [  _"$dtype" = _"deb" ]; then
131        cd $TOPBUILDDIR
132        tar xfz $src
[753]133        cd ${p}-${PVER}
[659]134        # point to the right debian conf
135        ln -s distributions/${ddir}-$dver debian
136        dpkg-buildpackage -us -uc -rfakeroot
[1028]137        export pkg="$pkg $p-${PVER}.deb"
[574]138        # Et voila !
[1040]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
[1028]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
[1513]169            export CACHEDIR=/var/cache/mindi
170            export PKGBUILDMINDI="true"
[1028]171            ./install.sh
172        elif [ _"$p" = _"mondo" ]; then
173            ./configure --prefix=/usr
174            make VERSION=$PVER
175            make DESTDIR=$TOPBUILDDIR/build-${p} install
[1513]176            mkdir -p $DESTDIR/var/cache/mondo
[1028]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}
[1570]186        ar=`uname -m`
[1028]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"
[556]191    else
192        echo "Unknown"
[553]193    fi
194done
[556]195echo "Packages handled : $pkg"
[553]196
[882]197rm -rf $MONDOTMP
[659]198
[553]199if [ $status = 0 ]; then
[1306]200    echo "Installing packages as root"
[553]201    if [  _"$dtype" = _"rpm" ]; then
[1306]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"
[553]213    fi
214fi
[757]215) 2>&1 | tee /tmp/build2pkg.log
Note: See TracBrowser for help on using the repository browser.