source: branches/2.0.9/tools/svn2build @ 756

Last change on this file since 756 was 756, checked in by Bruno Cornec, 14 years ago

merge -r754:755 $SVN_M/branches/stable

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