| 1 | #!/bin/bash
|
|---|
| 2 | #
|
|---|
| 3 | # Creates build environment and files for packages creation from SVN repository
|
|---|
| 4 | #
|
|---|
| 5 | # $Id$
|
|---|
| 6 | #
|
|---|
| 7 |
|
|---|
| 8 | (
|
|---|
| 9 | dname=`dirname $0`
|
|---|
| 10 | prem=`echo $dname |cut -c1`
|
|---|
| 11 | if [ ${prem} == "/" ]; then
|
|---|
| 12 | export TOOLHOME=$dname
|
|---|
| 13 | else
|
|---|
| 14 | export TOOLHOME=${PWD}/$dname
|
|---|
| 15 | fi
|
|---|
| 16 |
|
|---|
| 17 | cd $TOOLHOME
|
|---|
| 18 | . ./common-env
|
|---|
| 19 | . ./svn-env
|
|---|
| 20 |
|
|---|
| 21 | DEST=${TOPDIR}/${VER}-$TAG
|
|---|
| 22 | mkdir -p $DEST
|
|---|
| 23 |
|
|---|
| 24 | if [ "$1" = "" ]; then
|
|---|
| 25 | c="mondo-doc mindi mindi-busybox mondo"
|
|---|
| 26 | else
|
|---|
| 27 | if [ "$1" = "all" ]; then
|
|---|
| 28 | c="mindi-kernel mondo-doc mindi mindi-busybox mondo"
|
|---|
| 29 | else
|
|---|
| 30 | c=$1
|
|---|
| 31 | fi
|
|---|
| 32 | fi
|
|---|
| 33 |
|
|---|
| 34 | # Make it safe for SVN commands
|
|---|
| 35 | cd ${TOOLHOME}/..
|
|---|
| 36 |
|
|---|
| 37 | for p in $c; do
|
|---|
| 38 | v=`cat ${TOOLHOME}/../$p/VERSION`
|
|---|
| 39 | echo "Management of $p $v-$TAG (rev $REVISION)"
|
|---|
| 40 | dest="$DEST/$p-$v"
|
|---|
| 41 | rm -fr $dest
|
|---|
| 42 | svn export ${TOOLHOME}/../$p $dest
|
|---|
| 43 | echo "$REVISION" > $dest/REVISION
|
|---|
| 44 | echo "Generating SVN log file ..."
|
|---|
| 45 | svn log -v ${TOOLHOME}/../$p > $dest/svn.log
|
|---|
| 46 |
|
|---|
| 47 | for d in `cat ${TOOLHOME}/DISTROS`; do
|
|---|
| 48 | export ddir=`echo $d | cut -d_ -f1`
|
|---|
| 49 | export dver=`echo $d | cut -d_ -f2`
|
|---|
| 50 | echo "Generating build files for $ddir ($dver)"
|
|---|
| 51 | . $TOOLHOME/distro-env
|
|---|
| 52 |
|
|---|
| 53 | ddd=`LANG=C ; date '+%Y-%m-%d'`
|
|---|
| 54 | cat > $MONDOTMP/mondorescue.mc << EOF
|
|---|
| 55 | define(\`TTT', ${TAG})dnl
|
|---|
| 56 | define(\`RRR', ${TAG}${suf})dnl
|
|---|
| 57 | define(\`VVV', ${v})dnl
|
|---|
| 58 | define(\`DDD', ${ddd})dnl
|
|---|
| 59 | EOF
|
|---|
| 60 |
|
|---|
| 61 | mkdir -p $dest/distributions/$ddir $dest/distributions/${ddir}-$dver
|
|---|
| 62 | if [ "$dtype" = "rpm" ]; then
|
|---|
| 63 | if [ -f $dest/distributions/$ddir/spec.m4 ]; then
|
|---|
| 64 | inc=$dest/distributions/$ddir/spec.m4
|
|---|
| 65 | elif [ -f $dest/distributions/$dfam/spec.m4 ]; then
|
|---|
| 66 | inc=$dest/distributions/$dfam/spec.m4
|
|---|
| 67 | else
|
|---|
| 68 | echo "Unable to build the RPM specfile for this distro. Please report to authors"
|
|---|
| 69 | exit -1
|
|---|
| 70 | fi
|
|---|
| 71 | echo "Using $inc customization to build SPEC file"
|
|---|
| 72 |
|
|---|
| 73 | $TOOLHOME/mkchangelog.pl $dtype $p $MONDOTMP/$p.spec
|
|---|
| 74 | if [ $? -ne 0 ]; then
|
|---|
| 75 | echo "Unable to create changelog for ${ddir}-$dver/$p.spec"
|
|---|
| 76 | exit -1
|
|---|
| 77 | fi
|
|---|
| 78 | m4 $MONDOTMP/mondorescue.mc $inc $dest/distributions/rpm/$p.spec $MONDOTMP/$p.spec > $dest/distributions/${ddir}-$dver/$p.spec
|
|---|
| 79 |
|
|---|
| 80 | rm -f $MONDOTMP/$p.spec
|
|---|
| 81 | elif [ "$dtype" = "ebuild" ]; then
|
|---|
| 82 | m4 $MONDOTMP/mondorescue.mc $dest/distributions/$dfam/$p.ebuild > $dest/distributions/${ddir}-$dver/$p-$v.ebuild
|
|---|
| 83 | elif [ "$dtype" = "deb" ]; then
|
|---|
| 84 | cp -a $dest/distributions/$ddir/* $dest/distributions/${ddir}-$dver
|
|---|
| 85 | m4 $MONDOTMP/mondorescue.mc $dest/distributions/$ddir/rules > $dest/distributions/${ddir}-$dver/rules
|
|---|
| 86 | $TOOLHOME/mkchangelog.pl $dtype $p $dest/distributions/${ddir}-$dver/changelog
|
|---|
| 87 | if [ $? -ne 0 ]; then
|
|---|
| 88 | echo "Unable to create changelog for ${ddir}-$dver/changelog"
|
|---|
| 89 | exit -1
|
|---|
| 90 | fi
|
|---|
| 91 | else
|
|---|
| 92 | echo "Unknown Build"
|
|---|
| 93 | fi
|
|---|
| 94 | done
|
|---|
| 95 |
|
|---|
| 96 | # The rest is done there
|
|---|
| 97 | cd $DEST
|
|---|
| 98 | if [ _"`echo $p | grep mondo-doc`" != _"" ]; then
|
|---|
| 99 | cd $dest
|
|---|
| 100 | for f in mondorescue-howto.sgml *8; do
|
|---|
| 101 | m4 $MONDOTMP/mondorescue.mc $f > ${f}.new
|
|---|
| 102 | mv ${f}.new $f
|
|---|
| 103 | done
|
|---|
| 104 | make -f Makefile.howto
|
|---|
| 105 | if [ $? != 0 ]; then
|
|---|
| 106 | exit -1
|
|---|
| 107 | fi
|
|---|
| 108 | make -f Makefile.man
|
|---|
| 109 | if [ $? != 0 ]; then
|
|---|
| 110 | exit -1
|
|---|
| 111 | fi
|
|---|
| 112 | cd ..
|
|---|
| 113 | fi
|
|---|
| 114 |
|
|---|
| 115 | if [ _"`echo $p | grep -vE 'kernel|busybox' | grep mindi`" != _"" ]; then
|
|---|
| 116 | v1=`cat ${TOOLHOME}/../mondo-doc/VERSION`
|
|---|
| 117 | if [ ! -d mondo-doc-$v1 ]; then
|
|---|
| 118 | echo "mondo-doc should be created before $p"
|
|---|
| 119 | exit -1
|
|---|
| 120 | fi
|
|---|
| 121 | (cd mondo-doc-$v1 ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v)
|
|---|
| 122 | rm -f $dest/rootfs/sbin/parted2fdisk-ia64
|
|---|
| 123 | fi
|
|---|
| 124 | if [ "`echo $p | grep -v doc | grep mondo`" != "" ]; then
|
|---|
| 125 | v1=`cat ${TOOLHOME}/../mondo-doc/VERSION`
|
|---|
| 126 | if [ ! -d mondo-doc-$v1 ]; then
|
|---|
| 127 | echo "mondo-doc should be created before $p"
|
|---|
| 128 | exit -1
|
|---|
| 129 | fi
|
|---|
| 130 | (cd mondo-doc-$v1 ; make -f Makefile.howto install INSTALLDIR=../$p-$v/docs/en ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v/docs/man)
|
|---|
| 131 | (cd $dest ; echo "Bootstraping mondo ... " ; ./bootstrap)
|
|---|
| 132 | fi
|
|---|
| 133 |
|
|---|
| 134 | # Finally creates the tar files
|
|---|
| 135 | echo -n "Creating $p tar files (gzip... "
|
|---|
| 136 | tar cfphz ${DEST}/$p-$v.tar.gz $p-$v
|
|---|
| 137 | echo -n " bzip2..."
|
|---|
| 138 | tar cfphj ${DEST}/$p-$v.tar.bz2 $p-$v
|
|---|
| 139 | echo " )"
|
|---|
| 140 | done
|
|---|
| 141 |
|
|---|
| 142 | rm -rf $MONDOTMP
|
|---|
| 143 |
|
|---|
| 144 | echo "Version delivered :"
|
|---|
| 145 | echo "-------------------"
|
|---|
| 146 | echo "${VER}-$TAG"
|
|---|
| 147 | echo "-------------------"
|
|---|
| 148 | echo "${VER}-$TAG" > ${TOPDIR}/LAST
|
|---|
| 149 | exit 0
|
|---|
| 150 | ) 2>&1 | tee /tmp/svn2build.log
|
|---|