source: branches/stable/tools/build2pkg @ 1028

Last change on this file since 1028 was 1028, checked in by bruno, 12 years ago
  • Slackware 10.2 support added (from svn merge -r 1022:1027 $SVN_M/branches/2.2.1)
  • mkanounce now adds the ANNOUNCE keyword to mails
  • 2.2.1 announce in DB
  • Property svn:executable set to *
File size: 4.6 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    pv=`basename $src .tar.gz`
57    PVER=`echo $pv | sed "s|^$p-||" | cut -d- -f1`
58
59    if [  _"$dtype" = _"rpm" ]; then
60        if [ _"$p" = _"mondo-doc" ]; then
61            ar="noarch"
62        else
63            ar=$ARCH
64        fi
65
66        log=$MONDOTMP/$p-rpm.log
67
68        if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then
69            echo "Using bzip2 files ($dfam)"
70            ln -sf ${TOPDIR}/${VER}-$TAG/$pv.tar.bz2 SOURCES/
71        else
72            echo "Using gzip files ($dfam)"
73            ln -sf $src SOURCES/
74        fi
75        echo "Generating $p RPMS"
76        cd SPECS
77        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p.spec
78        mv $p-${PVER}/distributions/${ddir}-$dver/$p.spec .
79        rm -rf $p-${PVER}
80
81        # set LANGUAGE to check for correct log messages
82        export LANGUAGE=C
83        rpmbuild -ba $p.spec 2>&1 | tee $log
84        if [ $? != 0 ]; then 
85            status=-1
86        else
87            export pkg1="`egrep '^Wrote:' $log | grep -v debug | cut -d: -f2`"
88            if [ -f /usr/bin/rpmlint ]; then
89                /usr/bin/rpmlint $pkg1
90            else
91                echo "No rpmlint found, please install it"
92            fi
93            export pkg="$pkg `ls $pkg1 | grep -v src.rpm`"
94        fi
95        rm -rf ${TOPBUILDDIR}/BUILD/*
96        cd ..
97    elif [  _"$dtype" = _"ebuild" ]; then
98        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild
99        if [ _"`grep $TOPBUILDDIR/portage /etc/make.conf`" = _"" ]; then
100            echo "Adding $TOPBUILDDIR/portage to /etc/make.conf"
101            echo "PORTDIR_OVERLAY=\"$TOPBUILDDIR/portage\"" >> /etc/make.conf
102        fi
103
104        mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$p
105        mv $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p/$p-${PVER}.ebuild
106        rm -rf $p-${PVER}
107
108        cd ${TOPBUILDDIR}/portage/sys-apps/$p
109        ebuild $p-${PVER}.ebuild digest
110        if [ $? != 0 ]; then 
111            status=-1
112        fi
113        ebuild $p-${PVER}.ebuild package
114        if [ $? != 0 ]; then 
115            status=-1
116        fi
117        export pkg="$pkg $p-${PVER}.ebuild"
118    elif [  _"$dtype" = _"deb" ]; then
119        cd $TOPBUILDDIR
120        tar xfz $src
121        cd ${p}-${PVER}
122        # point to the right debian conf
123        ln -s distributions/${ddir}-$dver debian
124        dpkg-buildpackage -us -uc -rfakeroot
125        export pkg="$pkg $p-${PVER}.deb"
126        # Et voila !
127    elif [  _"$dfam" = _"slackware" ]; then
128        mkdir -p $TOPBUILDDIR/build-${p}/install
129        cd $TOPBUILDDIR
130        tar xfz $src
131        cd ${p}-${PVER}
132        mv distributions/${ddir}-$dver/slack-* $TOPBUILDDIR/build-${p}/install
133        if [ -e distributions/${ddir}-$dver/doinst.sh ]; then
134            mv distributions/${ddir}-$dver/doinst.sh $TOPBUILDDIR/build-${p}/install
135        fi
136        if [ _"$p" = _"mindi-busybox" ]; then
137            make oldconfig
138            make busybox
139            DESTDIR=$TOPBUILDDIR/build-${p}/usr/lib/mindi/rootfs
140            make PREFIX=$DESTDIR install
141        elif [ _"$p" = _"mindi" ]; then
142            export DONT_RELINK=1
143            export HEAD=$TOPBUILDDIR/build-${p}
144            export PREFIX=/usr
145            export CONFDIR=/etc
146            export MANDIR=/usr/man
147            export DOCDIR=/usr/doc
148            export LIBDIR=/usr/lib
149            export RPMBUILDMINDI="true"
150            ./install.sh
151        elif [ _"$p" = _"mondo" ]; then
152            ./configure --prefix=/usr
153            make VERSION=$PVER
154            make DESTDIR=$TOPBUILDDIR/build-${p} install
155        elif [ _"$p" = _"mondo-doc" ]; then
156            make -f Makefile.man VERSION=$PVER
157            make -f Makefile.howto VERSION=$PVER
158            make -f Makefile.man install INSTALLDIR=$TOPBUILDDIR/build-${p}/usr/doc/$p-${PVER}
159            make -f Makefile.howto install INSTALLDIR=$TOPBUILDDIR/build-${p}/usr/doc/$p-${PVER}
160        else
161            echo "Package $p not configured for $dfam"
162        fi
163        cd $TOPBUILDDIR/build-${p}
164        ar=`arch`
165        pkg1=$p-${PVER}-${ar}-${TAG}mr.tgz
166        echo "Running sudo /sbin/makepkg -p -l y -c y $pkg1"
167        sudo /sbin/makepkg -p -l y -c y $pkg1
168        export pkg="$pkg $pkg1"
169    else
170        echo "Unknown"
171    fi
172done
173echo "Packages handled : $pkg"
174
175rm -rf $MONDOTMP
176
177if [ $status = 0 ]; then
178    if [  _"$dtype" = _"rpm" ]; then
179        echo "Installing RPMS as root"
180        su - -c "$opt rpm -Uvh --force $pkg"
181    fi
182fi
183) 2>&1 | tee /tmp/build2pkg.log
Note: See TracBrowser for help on using the repository browser.