[388] | 1 | #!/bin/bash
|
---|
| 2 | #
|
---|
[550] | 3 | # Creates build environment and files for packages creation from SVN repository
|
---|
[388] | 4 | #
|
---|
| 5 | # $Id$
|
---|
| 6 | #
|
---|
| 7 |
|
---|
[757] | 8 | (
|
---|
[549] | 9 | dname=`dirname $0`
|
---|
| 10 | prem=`echo $dname |cut -c1`
|
---|
[1042] | 11 | if [ _${prem} = _"/" ]; then
|
---|
[549] | 12 | export TOOLHOME=$dname
|
---|
[388] | 13 | else
|
---|
[549] | 14 | export TOOLHOME=${PWD}/$dname
|
---|
[388] | 15 | fi
|
---|
| 16 |
|
---|
[549] | 17 | cd $TOOLHOME
|
---|
| 18 | . ./common-env
|
---|
| 19 | . ./svn-env
|
---|
[388] | 20 |
|
---|
[924] | 21 | VER=`cat ${TOOLHOME}/../mondo/VERSION`
|
---|
| 22 | TAG=`cat ${TOOLHOME}/../mondo/TAG`
|
---|
[553] | 23 | DEST=${TOPDIR}/${VER}-$TAG
|
---|
[1051] | 24 | TEST="false"
|
---|
| 25 | OPT=""
|
---|
[553] | 26 | mkdir -p $DEST
|
---|
[549] | 27 |
|
---|
[1051] | 28 | if [ "$1" = "--test" ]; then
|
---|
| 29 | TEST="true"
|
---|
[1263] | 30 | #OPT="-r BASE"
|
---|
[1051] | 31 | shift
|
---|
| 32 | fi
|
---|
| 33 |
|
---|
[549] | 34 | if [ "$1" = "" ]; then
|
---|
[1051] | 35 | c="mondo-doc mindi mindi-busybox mondo"
|
---|
[549] | 36 | else
|
---|
| 37 | if [ "$1" = "all" ]; then
|
---|
[825] | 38 | c="mindi-kernel mondo-doc mindi mindi-busybox mondo"
|
---|
[549] | 39 | else
|
---|
[924] | 40 | c="$*"
|
---|
[549] | 41 | fi
|
---|
| 42 | fi
|
---|
| 43 |
|
---|
[553] | 44 | # Make it safe for SVN commands
|
---|
[872] | 45 | cd ${TOOLHOME}/..
|
---|
[549] | 46 |
|
---|
[550] | 47 | for p in $c; do
|
---|
[872] | 48 | v=`cat ${TOOLHOME}/../$p/VERSION`
|
---|
[924] | 49 | tag=`cat ${TOOLHOME}/../$p/TAG`
|
---|
| 50 | echo "Management of $p $v-$tag (rev $REVISION)"
|
---|
[882] | 51 | dest="$DEST/$p-$v"
|
---|
[553] | 52 | rm -fr $dest
|
---|
[1051] | 53 | svn $OPT export ${TOOLHOME}/../$p $dest
|
---|
[553] | 54 | echo "$REVISION" > $dest/REVISION
|
---|
[550] | 55 | echo "Generating SVN log file ..."
|
---|
[1051] | 56 | svn $OPT log -v ${TOOLHOME}/../$p > $dest/svn.log
|
---|
[550] | 57 |
|
---|
| 58 | for d in `cat ${TOOLHOME}/DISTROS`; do
|
---|
[553] | 59 | export ddir=`echo $d | cut -d_ -f1`
|
---|
| 60 | export dver=`echo $d | cut -d_ -f2`
|
---|
[550] | 61 | echo "Generating build files for $ddir ($dver)"
|
---|
[553] | 62 | . $TOOLHOME/distro-env
|
---|
[550] | 63 |
|
---|
[551] | 64 | ddd=`LANG=C ; date '+%Y-%m-%d'`
|
---|
[882] | 65 | cat > $MONDOTMP/mondorescue.mc << EOF
|
---|
[924] | 66 | define(\`TTT', ${tag})dnl
|
---|
| 67 | define(\`RRR', ${tag}${suf})dnl
|
---|
[551] | 68 | define(\`VVV', ${v})dnl
|
---|
| 69 | define(\`DDD', ${ddd})dnl
|
---|
| 70 | EOF
|
---|
| 71 |
|
---|
[596] | 72 | mkdir -p $dest/distributions/$ddir $dest/distributions/${ddir}-$dver
|
---|
[553] | 73 | if [ "$dtype" = "rpm" ]; then
|
---|
| 74 | if [ -f $dest/distributions/$ddir/spec.m4 ]; then
|
---|
| 75 | inc=$dest/distributions/$ddir/spec.m4
|
---|
| 76 | elif [ -f $dest/distributions/$dfam/spec.m4 ]; then
|
---|
| 77 | inc=$dest/distributions/$dfam/spec.m4
|
---|
[550] | 78 | else
|
---|
| 79 | echo "Unable to build the RPM specfile for this distro. Please report to authors"
|
---|
[549] | 80 | exit -1
|
---|
| 81 | fi
|
---|
[550] | 82 |
|
---|
[1270] | 83 | if [ $ddir = "fedora" ]; then
|
---|
| 84 | $TOOLHOME/mkchangelog.pl fc $p $MONDOTMP/$p-fc.spec
|
---|
| 85 | m4 $MONDOTMP/mondorescue.mc $inc $dest/distributions/rpm/$p.spec $MONDOTMP/$p-fc.spec > $dest/distributions/${ddir}-$dver/$p-fc.spec
|
---|
| 86 | fi
|
---|
[882] | 87 | $TOOLHOME/mkchangelog.pl $dtype $p $MONDOTMP/$p.spec
|
---|
[636] | 88 | if [ $? -ne 0 ]; then
|
---|
| 89 | echo "Unable to create changelog for ${ddir}-$dver/$p.spec"
|
---|
[549] | 90 | exit -1
|
---|
| 91 | fi
|
---|
[882] | 92 | m4 $MONDOTMP/mondorescue.mc $inc $dest/distributions/rpm/$p.spec $MONDOTMP/$p.spec > $dest/distributions/${ddir}-$dver/$p.spec
|
---|
[1121] | 93 | if [ _"`/bin/arch`" = _"x86_64" ] && [ $ddir = "rhel" ]; then
|
---|
| 94 | # Bug on x86_64 on _sysconfdir on rhel4 at least
|
---|
| 95 | perl -pi -e 's~^export CONFDIR=.*~export CONFDIR=/etc~' $dest/distributions/${ddir}-$dver/$p.spec
|
---|
| 96 | fi
|
---|
[710] | 97 |
|
---|
[882] | 98 | rm -f $MONDOTMP/$p.spec
|
---|
[553] | 99 | elif [ "$dtype" = "ebuild" ]; then
|
---|
[882] | 100 | m4 $MONDOTMP/mondorescue.mc $dest/distributions/$dfam/$p.ebuild > $dest/distributions/${ddir}-$dver/$p-$v.ebuild
|
---|
[1028] | 101 | elif [ "$dtype" = "tgz" ]; then
|
---|
| 102 | m4 $MONDOTMP/mondorescue.mc $dest/distributions/$dfam/slack-desc > $dest/distributions/${ddir}-$dver/slack-desc
|
---|
[1039] | 103 | elif [ "$dtype" = "port" ]; then
|
---|
| 104 | m4 $MONDOTMP/mondorescue.mc $dest/distributions/$dfam/Makefile > $dest/distributions/${ddir}-$dver/Makefile
|
---|
[578] | 105 | elif [ "$dtype" = "deb" ]; then
|
---|
[1474] | 106 | if [ -f $dest/distributions/$ddir/rules ]; then
|
---|
| 107 | cp -a $dest/distributions/$ddir/* $dest/distributions/${ddir}-$dver
|
---|
| 108 | inc=$dest/distributions/$ddir/rules
|
---|
| 109 | elif [ -f $dest/distributions/$dfam/rules ]; then
|
---|
| 110 | cp -a $dest/distributions/$dfam/* $dest/distributions/${ddir}-$dver
|
---|
| 111 | inc=$dest/distributions/$dfam/rules
|
---|
| 112 | else
|
---|
| 113 | echo "Unable to build the .deb build files for this distro. Please report to authors"
|
---|
| 114 | exit -1
|
---|
| 115 | fi
|
---|
| 116 | m4 $MONDOTMP/mondorescue.mc $inc > $dest/distributions/${ddir}-$dver/rules
|
---|
[659] | 117 | $TOOLHOME/mkchangelog.pl $dtype $p $dest/distributions/${ddir}-$dver/changelog
|
---|
| 118 | if [ $? -ne 0 ]; then
|
---|
| 119 | echo "Unable to create changelog for ${ddir}-$dver/changelog"
|
---|
| 120 | exit -1
|
---|
| 121 | fi
|
---|
[550] | 122 | else
|
---|
[551] | 123 | echo "Unknown Build"
|
---|
[549] | 124 | fi
|
---|
| 125 | done
|
---|
[550] | 126 |
|
---|
[882] | 127 | # The rest is done there
|
---|
| 128 | cd $DEST
|
---|
[550] | 129 | if [ _"`echo $p | grep mondo-doc`" != _"" ]; then
|
---|
[553] | 130 | cd $dest
|
---|
[550] | 131 | for f in mondorescue-howto.sgml *8; do
|
---|
[882] | 132 | m4 $MONDOTMP/mondorescue.mc $f > ${f}.new
|
---|
[550] | 133 | mv ${f}.new $f
|
---|
| 134 | done
|
---|
| 135 | make -f Makefile.howto
|
---|
| 136 | if [ $? != 0 ]; then
|
---|
| 137 | exit -1
|
---|
| 138 | fi
|
---|
| 139 | make -f Makefile.man
|
---|
| 140 | if [ $? != 0 ]; then
|
---|
| 141 | exit -1
|
---|
| 142 | fi
|
---|
| 143 | cd ..
|
---|
| 144 | fi
|
---|
[1006] | 145 | if [ _"`echo $p | grep 'busybox'`" != _"" ]; then
|
---|
| 146 | cd $dest
|
---|
| 147 | mv Rules.mak Rules.mak.orig
|
---|
| 148 | cat Rules.mak.orig | sed "s/^EXTRAVERSION\([\t ]*\):=/EXTRAVERSION\1:=-$tag-r$REVISION/" > Rules.mak
|
---|
| 149 | cd ..
|
---|
| 150 | fi
|
---|
[550] | 151 |
|
---|
[829] | 152 | if [ _"`echo $p | grep -vE 'kernel|busybox' | grep mindi`" != _"" ]; then
|
---|
[872] | 153 | v1=`cat ${TOOLHOME}/../mondo-doc/VERSION`
|
---|
[721] | 154 | if [ ! -d mondo-doc-$v1 ]; then
|
---|
[550] | 155 | echo "mondo-doc should be created before $p"
|
---|
| 156 | exit -1
|
---|
| 157 | fi
|
---|
[882] | 158 | (cd mondo-doc-$v1 ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v)
|
---|
[553] | 159 | rm -f $dest/rootfs/sbin/parted2fdisk-ia64
|
---|
[550] | 160 | fi
|
---|
| 161 | if [ "`echo $p | grep -v doc | grep mondo`" != "" ]; then
|
---|
[872] | 162 | v1=`cat ${TOOLHOME}/../mondo-doc/VERSION`
|
---|
[721] | 163 | if [ ! -d mondo-doc-$v1 ]; then
|
---|
[550] | 164 | echo "mondo-doc should be created before $p"
|
---|
| 165 | exit -1
|
---|
| 166 | fi
|
---|
[882] | 167 | (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)
|
---|
[553] | 168 | (cd $dest ; echo "Bootstraping mondo ... " ; ./bootstrap)
|
---|
[550] | 169 | fi
|
---|
| 170 |
|
---|
| 171 | # Finally creates the tar files
|
---|
[781] | 172 | echo -n "Creating $p tar files (gzip... "
|
---|
[882] | 173 | tar cfphz ${DEST}/$p-$v.tar.gz $p-$v
|
---|
[1051] | 174 | if [ $TEST = "false" ]; then
|
---|
| 175 | echo -n " bzip2..."
|
---|
| 176 | tar cfphj ${DEST}/$p-$v.tar.bz2 $p-$v
|
---|
| 177 | fi
|
---|
[781] | 178 | echo " )"
|
---|
[1051] | 179 | if [ $TEST = "true" ]; then
|
---|
| 180 | echo "Use source under $DEST/$p-$v"
|
---|
| 181 | fi
|
---|
[549] | 182 | done
|
---|
[550] | 183 |
|
---|
[882] | 184 | rm -rf $MONDOTMP
|
---|
[553] | 185 |
|
---|
| 186 | echo "Version delivered :"
|
---|
| 187 | echo "-------------------"
|
---|
| 188 | echo "${VER}-$TAG"
|
---|
| 189 | echo "-------------------"
|
---|
| 190 | echo "${VER}-$TAG" > ${TOPDIR}/LAST
|
---|
| 191 | exit 0
|
---|
[757] | 192 | ) 2>&1 | tee /tmp/svn2build.log
|
---|