source: branches/3.0/tools/build2pkg

Last change on this file was 1586, checked in by bruno, 12 years ago

Fix gentoo issues again (Francesco Talamona ti.liame_at_email.it)

  • Property svn:executable set to *
File size: 4.9 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        if [ _"$p" = _"mondo" ]; then
99            eb="mondo-rescue"
100        else
101            eb=$p
102        fi
103        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$eb-${PVER}.ebuild
104        if [ _"`grep $TOPBUILDDIR/portage /etc/make.conf`" = _"" ]; then
105            echo "Adding $TOPBUILDDIR/portage to /etc/make.conf"
106            echo "PORTDIR_OVERLAY=\"$TOPBUILDDIR/portage\"" >> /etc/make.conf
107        fi
108
109        mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$eb
110        mv $p-${PVER}/distributions/${ddir}-$dver/$eb-${PVER}.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p/$eb-${PVER}.ebuild
111        rm -rf $p-${PVER}
112
113        cd ${TOPBUILDDIR}/portage/sys-apps/$eb
114        ebuild $eb-${PVER}.ebuild digest
115        if [ $? != 0 ]; then 
116            status=-1
117        fi
118        ebuild $eb-${PVER}.ebuild package
119        if [ $? != 0 ]; then 
120            status=-1
121        fi
122        export pkg="$pkg $eb-${PVER}.ebuild"
123    elif [  _"$dtype" = _"deb" ]; then
124        cd $TOPBUILDDIR
125        tar xfz $src
126        cd ${p}-${PVER}
127        # point to the right debian conf
128        ln -s distributions/${ddir}-$dver debian
129        dpkg-buildpackage -us -uc -rfakeroot
130        export pkg="$pkg $p-${PVER}.deb"
131        # Et voila !
132    elif [  _"$dtype" = _"port" ]; then
133        cd $TOPBUILDDIR
134        tar xfz $src
135        cd ${p}-${PVER}
136        mv distributions/${ddir}-$dver/* $TOPBUILDDIR
137        cd ..
138        rm -rf ${p}-${PVER}
139        make DISTDIR=$TOPBUILDDIR
140    elif [  _"$dfam" = _"slackware" ]; then
141        mkdir -p $TOPBUILDDIR/build-${p}/install
142        cd $TOPBUILDDIR
143        tar xfz $src
144        cd ${p}-${PVER}
145        mv distributions/${ddir}-$dver/slack-* $TOPBUILDDIR/build-${p}/install
146        if [ -e distributions/${ddir}-$dver/doinst.sh ]; then
147            mv distributions/${ddir}-$dver/doinst.sh $TOPBUILDDIR/build-${p}/install
148        fi
149        if [ _"$p" = _"mindi-busybox" ]; then
150            make oldconfig
151            make busybox
152            DESTDIR=$TOPBUILDDIR/build-${p}/usr/lib/mindi/rootfs
153            make PREFIX=$DESTDIR install
154        elif [ _"$p" = _"mindi" ]; then
155            export DONT_RELINK=1
156            export HEAD=$TOPBUILDDIR/build-${p}
157            export PREFIX=/usr
158            export CONFDIR=/etc
159            export MANDIR=/usr/man
160            export DOCDIR=/usr/doc
161            export LIBDIR=/usr/lib
162            export CACHEDIR=/var/cache/mindi
163            export PKGBUILDMINDI="true"
164            ./install.sh
165        elif [ _"$p" = _"mondo" ]; then
166            ./configure --prefix=/usr
167            make VERSION=$PVER
168            make DESTDIR=$TOPBUILDDIR/build-${p} install
169            mkdir -p $DESTDIR/var/cache/mondo
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=`uname -m`
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        su - -c "$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.