source: branches/stable/tools/build2pkg @ 1263

Last change on this file since 1263 was 1263, checked in by bruno, 13 years ago

Small improvements for build tools

  • Property svn:executable set to *
File size: 5.1 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        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild
106        if [ _"`grep $TOPBUILDDIR/portage /etc/make.conf`" = _"" ]; then
107            echo "Adding $TOPBUILDDIR/portage to /etc/make.conf"
108            echo "PORTDIR_OVERLAY=\"$TOPBUILDDIR/portage\"" >> /etc/make.conf
109        fi
110
111        mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$p
112        mv $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p/$p-${PVER}.ebuild
113        rm -rf $p-${PVER}
114
115        cd ${TOPBUILDDIR}/portage/sys-apps/$p
116        ebuild $p-${PVER}.ebuild digest
117        if [ $? != 0 ]; then 
118            status=-1
119        fi
120        ebuild $p-${PVER}.ebuild package
121        if [ $? != 0 ]; then 
122            status=-1
123        fi
124        export pkg="$pkg $p-${PVER}.ebuild"
125    elif [  _"$dtype" = _"deb" ]; then
126        cd $TOPBUILDDIR
127        tar xfz $src
128        cd ${p}-${PVER}
129        # point to the right debian conf
130        ln -s distributions/${ddir}-$dver debian
131        dpkg-buildpackage -us -uc -rfakeroot
132        export pkg="$pkg $p-${PVER}.deb"
133        # Et voila !
134    elif [  _"$dtype" = _"port" ]; then
135        cd $TOPBUILDDIR
136        tar xfz $src
137        cd ${p}-${PVER}
138        mv distributions/${ddir}-$dver/* $TOPBUILDDIR
139        cd ..
140        rm -rf ${p}-${PVER}
141        make DISTDIR=$TOPBUILDDIR
142    elif [  _"$dfam" = _"slackware" ]; then
143        mkdir -p $TOPBUILDDIR/build-${p}/install
144        cd $TOPBUILDDIR
145        tar xfz $src
146        cd ${p}-${PVER}
147        mv distributions/${ddir}-$dver/slack-* $TOPBUILDDIR/build-${p}/install
148        if [ -e distributions/${ddir}-$dver/doinst.sh ]; then
149            mv distributions/${ddir}-$dver/doinst.sh $TOPBUILDDIR/build-${p}/install
150        fi
151        if [ _"$p" = _"mindi-busybox" ]; then
152            make oldconfig
153            make busybox
154            DESTDIR=$TOPBUILDDIR/build-${p}/usr/lib/mindi/rootfs
155            make PREFIX=$DESTDIR install
156        elif [ _"$p" = _"mindi" ]; then
157            export DONT_RELINK=1
158            export HEAD=$TOPBUILDDIR/build-${p}
159            export PREFIX=/usr
160            export CONFDIR=/etc
161            export MANDIR=/usr/man
162            export DOCDIR=/usr/doc
163            export LIBDIR=/usr/lib
164            export RPMBUILDMINDI="true"
165            ./install.sh
166        elif [ _"$p" = _"mondo" ]; then
167            ./configure --prefix=/usr
168            make VERSION=$PVER
169            make DESTDIR=$TOPBUILDDIR/build-${p} install
170        elif [ _"$p" = _"mondo-doc" ]; then
171            make -f Makefile.man VERSION=$PVER
172            make -f Makefile.howto VERSION=$PVER
173            make -f Makefile.man install INSTALLDIR=$TOPBUILDDIR/build-${p}/usr/doc/$p-${PVER}
174            make -f Makefile.howto install INSTALLDIR=$TOPBUILDDIR/build-${p}/usr/doc/$p-${PVER}
175        else
176            echo "Package $p not configured for $dfam"
177        fi
178        cd $TOPBUILDDIR/build-${p}
179        ar=`arch`
180        pkg1=$p-${PVER}-${ar}-${TAG}mr.tgz
181        echo "Running sudo /sbin/makepkg -p -l y -c y $pkg1"
182        sudo /sbin/makepkg -p -l y -c y $pkg1
183        export pkg="$pkg $pkg1"
184    else
185        echo "Unknown"
186    fi
187done
188echo "Packages handled : $pkg"
189
190rm -rf $MONDOTMP
191
192if [ $status = 0 ]; then
193    if [  _"$dtype" = _"rpm" ]; then
194        echo "Installing RPMS as root"
195        sudo $opt rpm -Uvh --force $pkg
196    fi
197fi
198) 2>&1 | tee /tmp/build2pkg.log
Note: See TracBrowser for help on using the repository browser.