source: branches/stable/tools/build2pkg @ 1063

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