source: trunk/tools/svn2build @ 900

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