[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`
|
---|
[1236] | 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 |
|
---|
| 59 | if [ _"$dtype" = _"rpm" ]; then
|
---|
[556] | 60 | if [ _"$p" = _"mondo-doc" ]; then
|
---|
| 61 | ar="noarch"
|
---|
| 62 | else
|
---|
| 63 | ar=$ARCH
|
---|
| 64 | fi
|
---|
[553] | 65 |
|
---|
[882] | 66 | log=$MONDOTMP/$p-rpm.log
|
---|
[553] | 67 |
|
---|
[733] | 68 | if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then
|
---|
[763] | 69 | echo "Using bzip2 files ($dfam)"
|
---|
[781] | 70 | ln -sf ${TOPDIR}/${VER}-$TAG/$pv.tar.bz2 SOURCES/
|
---|
[553] | 71 | else
|
---|
[763] | 72 | echo "Using gzip files ($dfam)"
|
---|
[553] | 73 | ln -sf $src SOURCES/
|
---|
| 74 | fi
|
---|
[568] | 75 | echo "Generating $p RPMS"
|
---|
[553] | 76 | cd SPECS
|
---|
[753] | 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 |
|
---|
[924] | 81 | # set LANGUAGE to check for correct log messages
|
---|
| 82 | export LANGUAGE=C
|
---|
[761] | 83 | rpmbuild -ba $p.spec 2>&1 | tee $log
|
---|
[553] | 84 | if [ $? != 0 ]; then
|
---|
| 85 | status=-1
|
---|
[690] | 86 | else
|
---|
[888] | 87 | export pkg1="`egrep '^Wrote:' $log | grep -v debug | cut -d: -f2`"
|
---|
[733] | 88 | if [ -f /usr/bin/rpmlint ]; then
|
---|
[888] | 89 | /usr/bin/rpmlint $pkg1
|
---|
[733] | 90 | else
|
---|
| 91 | echo "No rpmlint found, please install it"
|
---|
| 92 | fi
|
---|
[888] | 93 | export pkg="$pkg `ls $pkg1 | grep -v src.rpm`"
|
---|
[553] | 94 | fi
|
---|
[596] | 95 | rm -rf ${TOPBUILDDIR}/BUILD/*
|
---|
[553] | 96 | cd ..
|
---|
[572] | 97 | elif [ _"$dtype" = _"ebuild" ]; then
|
---|
[755] | 98 | tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild
|
---|
[572] | 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 |
|
---|
[572] | 104 | mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$p
|
---|
[753] | 105 | mv $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p/$p-${PVER}.ebuild
|
---|
| 106 | rm -rf $p-${PVER}
|
---|
[572] | 107 |
|
---|
| 108 | cd ${TOPBUILDDIR}/portage/sys-apps/$p
|
---|
[765] | 109 | ebuild $p-${PVER}.ebuild digest
|
---|
[556] | 110 | if [ $? != 0 ]; then
|
---|
| 111 | status=-1
|
---|
| 112 | fi
|
---|
[765] | 113 | ebuild $p-${PVER}.ebuild package
|
---|
[572] | 114 | if [ $? != 0 ]; then
|
---|
| 115 | status=-1
|
---|
| 116 | fi
|
---|
[1023] | 117 | export pkg="$pkg $p-${PVER}.ebuild"
|
---|
[574] | 118 | elif [ _"$dtype" = _"deb" ]; then
|
---|
| 119 | cd $TOPBUILDDIR
|
---|
| 120 | tar xfz $src
|
---|
[753] | 121 | cd ${p}-${PVER}
|
---|
[659] | 122 | # point to the right debian conf
|
---|
| 123 | ln -s distributions/${ddir}-$dver debian
|
---|
| 124 | dpkg-buildpackage -us -uc -rfakeroot
|
---|
[1023] | 125 | export pkg="$pkg $p-${PVER}.deb"
|
---|
[574] | 126 | # Et voila !
|
---|
[1236] | 127 | elif [ _"$dtype" = _"port" ]; then
|
---|
| 128 | cd $TOPBUILDDIR
|
---|
| 129 | tar xfz $src
|
---|
| 130 | cd ${p}-${PVER}
|
---|
| 131 | mv distributions/${ddir}-$dver/* $TOPBUILDDIR
|
---|
| 132 | cd ..
|
---|
| 133 | rm -rf ${p}-${PVER}
|
---|
| 134 | make DISTDIR=$TOPBUILDDIR
|
---|
[1023] | 135 | elif [ _"$dfam" = _"slackware" ]; then
|
---|
[1026] | 136 | mkdir -p $TOPBUILDDIR/build-${p}/install
|
---|
[1024] | 137 | cd $TOPBUILDDIR
|
---|
[1023] | 138 | tar xfz $src
|
---|
[1024] | 139 | cd ${p}-${PVER}
|
---|
[1026] | 140 | mv distributions/${ddir}-$dver/slack-* $TOPBUILDDIR/build-${p}/install
|
---|
[1025] | 141 | if [ -e distributions/${ddir}-$dver/doinst.sh ]; then
|
---|
[1026] | 142 | mv distributions/${ddir}-$dver/doinst.sh $TOPBUILDDIR/build-${p}/install
|
---|
[1025] | 143 | fi
|
---|
[1023] | 144 | if [ _"$p" = _"mindi-busybox" ]; then
|
---|
| 145 | make oldconfig
|
---|
| 146 | make busybox
|
---|
[1026] | 147 | DESTDIR=$TOPBUILDDIR/build-${p}/usr/lib/mindi/rootfs
|
---|
[1023] | 148 | make PREFIX=$DESTDIR install
|
---|
| 149 | elif [ _"$p" = _"mindi" ]; then
|
---|
| 150 | export DONT_RELINK=1
|
---|
[1026] | 151 | export HEAD=$TOPBUILDDIR/build-${p}
|
---|
[1023] | 152 | export PREFIX=/usr
|
---|
| 153 | export CONFDIR=/etc
|
---|
| 154 | export MANDIR=/usr/man
|
---|
| 155 | export DOCDIR=/usr/doc
|
---|
| 156 | export LIBDIR=/usr/lib
|
---|
| 157 | export RPMBUILDMINDI="true"
|
---|
| 158 | ./install.sh
|
---|
| 159 | elif [ _"$p" = _"mondo" ]; then
|
---|
[1025] | 160 | ./configure --prefix=/usr
|
---|
| 161 | make VERSION=$PVER
|
---|
[1026] | 162 | make DESTDIR=$TOPBUILDDIR/build-${p} install
|
---|
[1023] | 163 | elif [ _"$p" = _"mondo-doc" ]; then
|
---|
| 164 | make -f Makefile.man VERSION=$PVER
|
---|
| 165 | make -f Makefile.howto VERSION=$PVER
|
---|
[1026] | 166 | make -f Makefile.man install INSTALLDIR=$TOPBUILDDIR/build-${p}/usr/doc/$p-${PVER}
|
---|
| 167 | make -f Makefile.howto install INSTALLDIR=$TOPBUILDDIR/build-${p}/usr/doc/$p-${PVER}
|
---|
[1023] | 168 | else
|
---|
| 169 | echo "Package $p not configured for $dfam"
|
---|
| 170 | fi
|
---|
[1026] | 171 | cd $TOPBUILDDIR/build-${p}
|
---|
[1023] | 172 | ar=`arch`
|
---|
| 173 | pkg1=$p-${PVER}-${ar}-${TAG}mr.tgz
|
---|
[1027] | 174 | echo "Running sudo /sbin/makepkg -p -l y -c y $pkg1"
|
---|
| 175 | sudo /sbin/makepkg -p -l y -c y $pkg1
|
---|
[1023] | 176 | export pkg="$pkg $pkg1"
|
---|
[556] | 177 | else
|
---|
| 178 | echo "Unknown"
|
---|
[553] | 179 | fi
|
---|
| 180 | done
|
---|
[556] | 181 | echo "Packages handled : $pkg"
|
---|
[553] | 182 |
|
---|
[882] | 183 | rm -rf $MONDOTMP
|
---|
[659] | 184 |
|
---|
[553] | 185 | if [ $status = 0 ]; then
|
---|
| 186 | if [ _"$dtype" = _"rpm" ]; then
|
---|
[556] | 187 | echo "Installing RPMS as root"
|
---|
[553] | 188 | su - -c "$opt rpm -Uvh --force $pkg"
|
---|
| 189 | fi
|
---|
| 190 | fi
|
---|
[757] | 191 | ) 2>&1 | tee /tmp/build2pkg.log
|
---|