source: MondoRescue/trunk/tools/svn2build@ 900

Last change on this file since 900 was 900, checked in by Bruno Cornec, 18 years ago

Huge patch to introduce low level functions that will bw used everywhere (mr_free, mr_asprintf, ...)
Nearly linking now due to that.

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