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