source: branches/2.0.8/tools/svn2build @ 597

Last change on this file since 597 was 597, checked in by bcornec, 13 years ago

Build process fixes following first attempt to deliver 2.0.8

  • Property svn:executable set to *
File size: 4.3 KB
Line 
1#!/bin/bash
2#
3# Creates build environment and files for packages creation from SVN repository
4#
5# $Id$
6#
7
8umask 022
9dname=`dirname $0`
10prem=`echo $dname |cut -c1`
11if [ ${prem} == "/" ]; then
12        export TOOLHOME=$dname
13else
14        export TOOLHOME=${PWD}/$dname
15fi
16
17cd $TOOLHOME
18. ./common-env
19. ./svn-env
20
21DEST=${TOPDIR}/${VER}-$TAG
22mkdir -p $DEST
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
34# Make it safe for SVN commands
35cd ${BASE}/svn
36
37for p in $c; do
38    v=`cat ${SVNBRANCH}/$p/VERSION`
39    echo "Management of $p $v-$REVISION"
40    dest="$p-$v-$TAG"
41    rm -fr $dest
42    svn export ${SVNBRANCH}/$p $dest
43    echo "$REVISION" > $dest/REVISION
44    echo "Generating SVN log file ..."
45    svn log -v ${SVNBRANCH}/$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        # Create conf file dir
54        mkdir -p ${BUILDDIR}
55
56        ddd=`LANG=C ; date '+%Y-%m-%d'`
57        cat > /tmp/mondorescue.mc << EOF
58define(\`TTT', ${TAG})dnl
59define(\`RRR', ${TAG}${suf})dnl
60define(\`VVV', ${v})dnl
61define(\`DDD', ${ddd})dnl
62EOF
63
64        mkdir -p $dest/distributions/$ddir $dest/distributions/${ddir}-$dver
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
70            else
71                echo "Unable to build the RPM specfile for this distro. Please report to authors"
72                exit -1
73            fi
74            echo "Using $inc customization to build SPEC file"
75            m4 /tmp/mondorescue.mc $inc $dest/distributions/rpm/$p.spec > $dest/distributions/${ddir}-$dver/$p.spec
76
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
81            else
82                echo "Unable to build RPM changelog for this distro. Please report to authors"
83                exit -1
84            fi
85
86            echo "Using $log customization to build changelog file"
87            ddate=`LANG=C ; date "+%a %b %d %Y"`
88            cat > $dest/distributions/${ddir}-$dver/$p.changelog.new << EOF
89* $ddate Bruno Cornec <bruno@mondorescue.org> VVV-RRR
90- Updated to VVV-r${REVISION}
91
92EOF
93            cat $log >> $dest/distributions/${ddir}-$dver/$p.changelog.new
94            m4 /tmp/mondorescue.mc $dest/distributions/${ddir}-$dver/$p.changelog.new >> $dest/distributions/${ddir}-${dver}/$p.spec
95            rm -f $dest/distributions/${ddir}-$dver/$p.changelog.new
96
97        elif [ "$dtype" = "ebuild" ]; then
98            m4 /tmp/mondorescue.mc $dest/distributions/$dfam/$p.ebuild > $dest/distributions/${ddir}-$dver/$p-$v-r$TAG.ebuild
99        elif [ "$dtype" = "deb" ]; then
100            # To be developped
101            m4 /tmp/mondorescue.mc $dest/distributions/$dfam/$p > /dev/null
102        else
103            echo "Unknown Build"
104        fi
105    done
106
107    if [ _"`echo $p | grep mondo-doc`" != _"" ]; then
108        cd $dest
109        for f in mondorescue-howto.sgml *8; do
110            m4 /tmp/mondorescue.mc $f > ${f}.new
111            mv ${f}.new $f
112        done
113        make -f Makefile.howto
114        if [ $? != 0 ]; then
115            exit -1
116        fi
117        make -f Makefile.man
118        if [ $? != 0 ]; then
119            exit -1
120        fi
121        cd ..
122    fi
123
124    if [ _"`echo $p | grep -v kernel | grep mindi`" != _"" ]; then
125        v1=`cat ${SVNBRANCH}/mondo-doc/VERSION`
126        if [ ! -d mondo-doc-$v1-$TAG ]; then
127            echo "mondo-doc should be created before $p"
128            exit -1
129        fi
130        (cd mondo-doc-$v1-$TAG ; make -f Makefile.man install-$p INSTALLDIR=../$dest)
131        rm -f $dest/rootfs/sbin/parted2fdisk-ia64
132    fi
133    if [ "`echo $p | grep -v doc | grep  mondo`" != "" ]; then
134        v1=`cat ${SVNBRANCH}/mondo-doc/VERSION`
135        if [ ! -d mondo-doc-$v1-$TAG ]; then
136            echo "mondo-doc should be created before $p"
137            exit -1
138        fi
139        (cd mondo-doc-$v1-$TAG ; make -f Makefile.howto install INSTALLDIR=../$dest/docs/en ; make -f Makefile.man install-$p INSTALLDIR=../$dest/docs/man)
140        (cd $dest ; echo "Bootstraping mondo ... " ; ./bootstrap)
141    fi
142
143    # Finally creates the tar files
144    echo "Creating $p tar files"
145    tar cfhz ${DEST}/$p-$v-$TAG.tar.gz $dest
146    #gzip -cd ${DEST}/$p-$v-$TAG.tar.gz | bzip2 -c3 > ${DEST}/$p-$v-$TAG.tar.bz2
147    #tar cfhj ${DEST}/$p-$v-$TAG.tar.bz2 $dest
148done
149
150rm -f /tmp/mondorescue.mc
151
152echo "Version delivered :"
153echo "-------------------"
154echo "${VER}-$TAG"
155echo "-------------------"
156echo "${VER}-$TAG" > ${TOPDIR}/LAST
157exit 0
Note: See TracBrowser for help on using the repository browser.