[553] | 1 | #!/bin/bash
|
---|
| 2 | #
|
---|
| 3 | # Creates packages from build repository
|
---|
| 4 | #
|
---|
| 5 | # $Id$
|
---|
| 6 | #
|
---|
| 7 | # Syntax: build2pkg [version-tag [pkg list]]
|
---|
| 8 | #
|
---|
| 9 |
|
---|
[764] | 10 | (
|
---|
[553] | 11 | dname=`dirname $0`
|
---|
| 12 | prem=`echo $dname |cut -c1`
|
---|
| 13 | if [ ${prem} == "/" ]; then
|
---|
| 14 | export TOOLHOME=$dname
|
---|
| 15 | else
|
---|
| 16 | export TOOLHOME=${PWD}/$dname
|
---|
| 17 | fi
|
---|
| 18 |
|
---|
| 19 | . $TOOLHOME/common-env
|
---|
| 20 | . $TOOLHOME/distro-env
|
---|
| 21 |
|
---|
| 22 | # We need to get $VER and $TAG
|
---|
| 23 | if [ "$1" = "" ]; then
|
---|
| 24 | LAST=`cat ${TOPDIR}/LAST`
|
---|
| 25 | else
|
---|
| 26 | LAST=$1
|
---|
| 27 | shift
|
---|
| 28 | fi
|
---|
| 29 | VER=`echo $LAST | cut -d- -f1`
|
---|
| 30 | TAG=`echo $LAST | cut -d- -f2`
|
---|
| 31 | echo "Working on ${VER}-$TAG"
|
---|
| 32 |
|
---|
| 33 | if [ "$1" = "" ]; then
|
---|
[839] | 34 | c="mondo-doc mindi mindi-busybox mondo"
|
---|
[553] | 35 | else
|
---|
| 36 | if [ "$1" = "all" ]; then
|
---|
[839] | 37 | c="mindi-kernel mondo-doc mindi mindi-busybox mondo"
|
---|
[553] | 38 | else
|
---|
[932] | 39 | c="$*"
|
---|
[553] | 40 | fi
|
---|
| 41 | fi
|
---|
| 42 |
|
---|
| 43 | status=0
|
---|
| 44 |
|
---|
| 45 | #
|
---|
| 46 | # Define on which distro we are to generate the right packages
|
---|
| 47 | #
|
---|
| 48 |
|
---|
| 49 | export pkg=""
|
---|
[588] | 50 | echo "Working under $TOPBUILDDIR"
|
---|
[553] | 51 | cd $TOPBUILDDIR
|
---|
| 52 |
|
---|
| 53 | for 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`
|
---|
[764] | 57 | PVER=`echo $pv | sed "s|^$p-||" | cut -d- -f1`
|
---|
[553] | 58 |
|
---|
| 59 | if [ _"$dtype" = _"rpm" ]; then
|
---|
[556] | 60 | if [ _"$p" = _"mondo-doc" ]; then
|
---|
| 61 | ar="noarch"
|
---|
| 62 | else
|
---|
| 63 | ar=$ARCH
|
---|
| 64 | fi
|
---|
[553] | 65 |
|
---|
[900] | 66 | log=$MONDOTMP/$p-rpm.log
|
---|
[553] | 67 |
|
---|
[764] | 68 | if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then
|
---|
| 69 | echo "Using bzip2 files ($dfam)"
|
---|
[782] | 70 | ln -sf ${TOPDIR}/${VER}-$TAG/$pv.tar.bz2 SOURCES/
|
---|
[553] | 71 | else
|
---|
[764] | 72 | echo "Using gzip files ($dfam)"
|
---|
[553] | 73 | ln -sf $src SOURCES/
|
---|
| 74 | fi
|
---|
[588] | 75 | echo "Generating $p RPMS"
|
---|
[553] | 76 | cd SPECS
|
---|
[764] | 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}
|
---|
[553] | 80 |
|
---|
[932] | 81 | # set LANGUAGE to check for correct log messages
|
---|
[923] | 82 | export LANGUAGE=C
|
---|
[764] | 83 | rpmbuild -ba $p.spec 2>&1 | tee $log
|
---|
[553] | 84 | if [ $? != 0 ]; then
|
---|
| 85 | status=-1
|
---|
[729] | 86 | else
|
---|
[900] | 87 | export pkg1="`egrep '^Wrote:' $log | grep -v debug | cut -d: -f2`"
|
---|
[764] | 88 | if [ -f /usr/bin/rpmlint ]; then
|
---|
[900] | 89 | /usr/bin/rpmlint $pkg1
|
---|
[764] | 90 | else
|
---|
| 91 | echo "No rpmlint found, please install it"
|
---|
| 92 | fi
|
---|
[900] | 93 | export pkg="$pkg `ls $pkg1 | grep -v src.rpm`"
|
---|
[553] | 94 | fi
|
---|
[600] | 95 | rm -rf ${TOPBUILDDIR}/BUILD/*
|
---|
[553] | 96 | cd ..
|
---|
[588] | 97 | elif [ _"$dtype" = _"ebuild" ]; then
|
---|
[764] | 98 | tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild
|
---|
[588] | 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
|
---|
[556] | 103 |
|
---|
[588] | 104 | mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$p
|
---|
[764] | 105 | mv $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p/$p-${PVER}.ebuild
|
---|
| 106 | rm -rf $p-${PVER}
|
---|
[588] | 107 |
|
---|
| 108 | cd ${TOPBUILDDIR}/portage/sys-apps/$p
|
---|
[782] | 109 | ebuild $p-${PVER}.ebuild digest
|
---|
[556] | 110 | if [ $? != 0 ]; then
|
---|
| 111 | status=-1
|
---|
| 112 | fi
|
---|
[782] | 113 | ebuild $p-${PVER}.ebuild package
|
---|
[588] | 114 | if [ $? != 0 ]; then
|
---|
| 115 | status=-1
|
---|
| 116 | fi
|
---|
| 117 | elif [ _"$dtype" = _"deb" ]; then
|
---|
| 118 | cd $TOPBUILDDIR
|
---|
| 119 | tar xfz $src
|
---|
[764] | 120 | cd ${p}-${PVER}
|
---|
[672] | 121 | # point to the right debian conf
|
---|
| 122 | ln -s distributions/${ddir}-$dver debian
|
---|
| 123 | dpkg-buildpackage -us -uc -rfakeroot
|
---|
[588] | 124 | # Et voila !
|
---|
[556] | 125 | else
|
---|
| 126 | echo "Unknown"
|
---|
[553] | 127 | fi
|
---|
| 128 | done
|
---|
[556] | 129 | echo "Packages handled : $pkg"
|
---|
[553] | 130 |
|
---|
[900] | 131 | rm -rf $MONDOTMP
|
---|
[672] | 132 |
|
---|
[553] | 133 | if [ $status = 0 ]; then
|
---|
| 134 | if [ _"$dtype" = _"rpm" ]; then
|
---|
[556] | 135 | echo "Installing RPMS as root"
|
---|
[553] | 136 | su - -c "$opt rpm -Uvh --force $pkg"
|
---|
| 137 | fi
|
---|
| 138 | fi
|
---|
[764] | 139 | ) 2>&1 | tee /tmp/build2pkg.log
|
---|