[553] | 1 | #!/bin/bash
|
---|
| 2 | #
|
---|
| 3 | # Creates packages from build repository
|
---|
| 4 | #
|
---|
| 5 | # $Id$
|
---|
| 6 | #
|
---|
| 7 | # Syntax: build2pkg [version-tag [pkg list]]
|
---|
| 8 | #
|
---|
| 9 |
|
---|
[757] | 10 | (
|
---|
[553] | 11 | dname=`dirname $0`
|
---|
| 12 | prem=`echo $dname |cut -c1`
|
---|
[1042] | 13 | if [ _${prem} = _"/" ]; then
|
---|
[553] | 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
|
---|
[825] | 34 | c="mondo-doc mindi mindi-busybox mondo"
|
---|
[553] | 35 | else
|
---|
| 36 | if [ "$1" = "all" ]; then
|
---|
[825] | 37 | c="mindi-kernel mondo-doc mindi mindi-busybox mondo"
|
---|
[553] | 38 | else
|
---|
[924] | 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=""
|
---|
[572] | 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`
|
---|
[753] | 57 | PVER=`echo $pv | sed "s|^$p-||" | cut -d- -f1`
|
---|
[553] | 58 |
|
---|
[1063] | 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 |
|
---|
[553] | 65 | if [ _"$dtype" = _"rpm" ]; then
|
---|
[1121] | 66 | if [ _"$p" = _"mondo-doc" ] || [ _"$p" = _"mindi" ]; then
|
---|
[556] | 67 | ar="noarch"
|
---|
| 68 | else
|
---|
| 69 | ar=$ARCH
|
---|
| 70 | fi
|
---|
[553] | 71 |
|
---|
[882] | 72 | log=$MONDOTMP/$p-rpm.log
|
---|
[553] | 73 |
|
---|
[733] | 74 | if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then
|
---|
[763] | 75 | echo "Using bzip2 files ($dfam)"
|
---|
[781] | 76 | ln -sf ${TOPDIR}/${VER}-$TAG/$pv.tar.bz2 SOURCES/
|
---|
[553] | 77 | else
|
---|
[763] | 78 | echo "Using gzip files ($dfam)"
|
---|
[553] | 79 | ln -sf $src SOURCES/
|
---|
| 80 | fi
|
---|
[568] | 81 | echo "Generating $p RPMS"
|
---|
[553] | 82 | cd SPECS
|
---|
[753] | 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}
|
---|
[553] | 86 |
|
---|
[924] | 87 | # set LANGUAGE to check for correct log messages
|
---|
| 88 | export LANGUAGE=C
|
---|
[761] | 89 | rpmbuild -ba $p.spec 2>&1 | tee $log
|
---|
[553] | 90 | if [ $? != 0 ]; then
|
---|
| 91 | status=-1
|
---|
[690] | 92 | else
|
---|
[888] | 93 | export pkg1="`egrep '^Wrote:' $log | grep -v debug | cut -d: -f2`"
|
---|
[733] | 94 | if [ -f /usr/bin/rpmlint ]; then
|
---|
[888] | 95 | /usr/bin/rpmlint $pkg1
|
---|
[733] | 96 | else
|
---|
| 97 | echo "No rpmlint found, please install it"
|
---|
| 98 | fi
|
---|
[888] | 99 | export pkg="$pkg `ls $pkg1 | grep -v src.rpm`"
|
---|
[553] | 100 | fi
|
---|
[596] | 101 | rm -rf ${TOPBUILDDIR}/BUILD/*
|
---|
[553] | 102 | cd ..
|
---|
[572] | 103 | elif [ _"$dtype" = _"ebuild" ]; then
|
---|
[755] | 104 | tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild
|
---|
[572] | 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
|
---|
[556] | 109 |
|
---|
[572] | 110 | mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$p
|
---|
[753] | 111 | mv $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p/$p-${PVER}.ebuild
|
---|
| 112 | rm -rf $p-${PVER}
|
---|
[572] | 113 |
|
---|
| 114 | cd ${TOPBUILDDIR}/portage/sys-apps/$p
|
---|
[765] | 115 | ebuild $p-${PVER}.ebuild digest
|
---|
[556] | 116 | if [ $? != 0 ]; then
|
---|
| 117 | status=-1
|
---|
| 118 | fi
|
---|
[765] | 119 | ebuild $p-${PVER}.ebuild package
|
---|
[572] | 120 | if [ $? != 0 ]; then
|
---|
| 121 | status=-1
|
---|
| 122 | fi
|
---|
[1028] | 123 | export pkg="$pkg $p-${PVER}.ebuild"
|
---|
[574] | 124 | elif [ _"$dtype" = _"deb" ]; then
|
---|
| 125 | cd $TOPBUILDDIR
|
---|
| 126 | tar xfz $src
|
---|
[753] | 127 | cd ${p}-${PVER}
|
---|
[659] | 128 | # point to the right debian conf
|
---|
| 129 | ln -s distributions/${ddir}-$dver debian
|
---|
| 130 | dpkg-buildpackage -us -uc -rfakeroot
|
---|
[1028] | 131 | export pkg="$pkg $p-${PVER}.deb"
|
---|
[574] | 132 | # Et voila !
|
---|
[1040] | 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
|
---|
[1028] | 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"
|
---|
[556] | 183 | else
|
---|
| 184 | echo "Unknown"
|
---|
[553] | 185 | fi
|
---|
| 186 | done
|
---|
[556] | 187 | echo "Packages handled : $pkg"
|
---|
[553] | 188 |
|
---|
[882] | 189 | rm -rf $MONDOTMP
|
---|
[659] | 190 |
|
---|
[553] | 191 | if [ $status = 0 ]; then
|
---|
| 192 | if [ _"$dtype" = _"rpm" ]; then
|
---|
[556] | 193 | echo "Installing RPMS as root"
|
---|
[553] | 194 | su - -c "$opt rpm -Uvh --force $pkg"
|
---|
| 195 | fi
|
---|
| 196 | fi
|
---|
[757] | 197 | ) 2>&1 | tee /tmp/build2pkg.log
|
---|