source: branches/stable/tools/svn2build @ 554

Last change on this file since 554 was 554, checked in by bcornec, 14 years ago

Add new tag variable in spec and corresponding TTT macro in m4 files for filename correct handling during build

  • 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
[549]8umask 022
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
25        c="mondo-doc mindi mondo"
26else
27    if [ "$1" = "all" ]; then
28            c="mindi-kernel mondo-doc mindi mondo"
29    else
30        c=$1
31    fi
32fi
33
[553]34# Make it safe for SVN commands
[549]35cd ${BASE}/svn
36
[550]37for p in $c; do
38    v=`cat ${SVNBRANCH}/$p/VERSION`
39    echo "Management of $p $v-$REVISION"
[553]40    dest="$p-$v-$TAG"
41    rm -fr $dest
42    svn export ${SVNBRANCH}/$p $dest
43    echo "$REVISION" > $dest/REVISION
[550]44    echo "Generating SVN log file ..."
[553]45    svn log -v ${SVNBRANCH}/$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
53        # Create conf file dir
54        mkdir -p ${BUILDDIR}
55
[551]56        ddd=`LANG=C ; date '+%Y-%m-%d'`
57        cat > /tmp/mondorescue.mc << EOF
[554]58define(\`TTT', ${TAG})dnl
[551]59define(\`RRR', ${TAG}${suf})dnl
60define(\`VVV', ${v})dnl
61define(\`DDD', ${ddd})dnl
62EOF
63
[553]64        mkdir -p $dest/distributions/$ddir
65        if [ "$dtype" = "rpm" ]; then
66            if [ -f $dest/distributions/$ddir/spec.m4 ]; then
67                inc=$dest/distributions/$ddir/spec.m4
68            elif [ -f $dest/distributions/$dfam/spec.m4 ]; then
69                inc=$dest/distributions/$dfam/spec.m4
[550]70            else
71                echo "Unable to build the RPM specfile for this distro. Please report to authors"
[549]72                exit -1
73            fi
[550]74            echo "Using $inc customization to build SPEC file"
[553]75            m4 /tmp/mondorescue.mc $inc $dest/distributions/rpm/$p.spec > $dest/distributions/$ddir/$p.spec
[550]76
[553]77            if [ -f $dest/distributions/$ddir/changelog ]; then
78                log=$dest/distributions/$ddir/changelog
79            elif [ -f $dest/distributions/$dfam/changelog ]; then
80                log=$dest/distributions/$dfam/changelog
[550]81            else
82                echo "Unable to build RPM changelog for this distro. Please report to authors"
[549]83                exit -1
84            fi
[550]85
86            echo "Using $log customization to build changelog file"
87            ddate=`LANG=C ; date "+%a %b %d %Y"`
[553]88            cat > $dest/distributions/$ddir/$p.changelog.new << EOF
[550]89* $ddate Bruno Cornec <bruno@mondorescue.org> VVV-RRR
90- Updated to VVV-r${REVISION}
91
92EOF
[553]93            cat $log >> $dest/distributions/$ddir/$p.changelog.new
94            m4 /tmp/mondorescue.mc $dest/distributions/$ddir/$p.changelog.new > $dest/distributions/$ddir/$p.changelog
95            rm -f $dest/distributions/$ddir/$p.changelog.new
[550]96
[553]97        elif [ "$dtype" = "ebuild" ]; then
[551]98            echo "Gentoo Build"
[550]99        else
[551]100            echo "Unknown Build"
[549]101        fi
102    done
[550]103
104    if [ _"`echo $p | grep mondo-doc`" != _"" ]; then
[553]105        cd $dest
[550]106        for f in mondorescue-howto.sgml *8; do
107            m4 /tmp/mondorescue.mc $f > ${f}.new
108            mv ${f}.new $f
109        done
110        make -f Makefile.howto
111        if [ $? != 0 ]; then
112            exit -1
113        fi
114        make -f Makefile.man
115        if [ $? != 0 ]; then
116            exit -1
117        fi
118        cd ..
119    fi
120
121    if [ _"`echo $p | grep -v kernel | grep mindi`" != _"" ]; then
122        v1=`cat ${SVNBRANCH}/mondo-doc/VERSION`
123        if [ ! -d mondo-doc-$v1 ]; then
124            echo "mondo-doc should be created before $p"
125            exit -1
126        fi
[553]127        (cd mondo-doc-$v1 ; make -f Makefile.man install-$p INSTALLDIR=../$dest)
128        rm -f $dest/rootfs/sbin/parted2fdisk-ia64
[550]129    fi
130    if [ "`echo $p | grep -v doc | grep  mondo`" != "" ]; then
131        v1=`cat ${SVNBRANCH}/mondo-doc/VERSION`
132        if [ ! -d mondo-doc-$v1 ]; then
133            echo "mondo-doc should be created before $p"
134            exit -1
135        fi
[553]136        (cd mondo-doc-$v1 ; make -f Makefile.howto install INSTALLDIR=../$dest/docs/en ; make -f Makefile.man install-$p INSTALLDIR=../$dest/docs/man)
137        (cd $dest ; echo "Bootstraping mondo ... " ; ./bootstrap)
[550]138    fi
139
140    # Finally creates the tar files
141    echo "Creating $p tar files"
[553]142    tar cfhz ${DEST}/$p-$v-$TAG.tar.gz $dest
143    #gzip -cd ${DEST}/$p-$v-$TAG.tar.gz | bzip2 -c3 > ${DEST}/$p-$v-$TAG.tar.bz2
144    #tar cfhj ${DEST}/$p-$v-$TAG.tar.bz2 $dest
[549]145done
[550]146
147rm -f /tmp/mondorescue.mc
[553]148
149echo "Version delivered :"
150echo "-------------------"
151echo "${VER}-$TAG"
152echo "-------------------"
153echo "${VER}-$TAG" > ${TOPDIR}/LAST
154exit 0
Note: See TracBrowser for help on using the repository browser.