source: branches/stable/tools/svn2build @ 550

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

Cleanup in build process continue

  • removal of most small scripts
  • based on one main svn2build script
  • spec files reviewed for fedora remarks
  • changelog and TAG integrated
  • Property svn:executable set to *
File size: 4.7 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
21mkdir -p ${TOPDIR}/SOURCES
22
23if [ "$1" = "" ]; then
24        c="mondo-doc mindi mondo"
25else
26    if [ "$1" = "all" ]; then
27            c="mindi-kernel mondo-doc mindi mondo"
28    else
29        c=$1
30    fi
31fi
32
33
34cd ${BASE}/svn
35
36for p in $c; do
37    v=`cat ${SVNBRANCH}/$p/VERSION`
38    echo "Management of $p $v-$REVISION"
39    rm -fr $p-$v
40    svn export ${SVNBRANCH}/$p $p-$v
41    echo "$REVISION" > $p-$v/REVISION
42    echo "Generating SVN log file ..."
43    svn log -v ${SVNBRANCH}/$p > $p-$v/svn.log
44
45    for d in `cat ${TOOLHOME}/DISTROS`; do
46        ddir=`echo $d | cut -f'_' -d1`
47        dver=`echo $d | cut -f'_' -d2`
48        echo "Generating build files for $ddir ($dver)"
49        if [ $ddir = "debian" ]; then
50            dfam="debian"
51            dtype="deb"
52            suf=".${dfam}${dver}"
53            BUILDDIR=${TOPDIR}/debian
54        elif [ $ddir = "gentoo" ]; then
55            dfam="gentoo"
56            dtype="ebuild"
57            suf=".${ddir}${dver}"
58            BUILDDIR=${TOPDIR}/ebuild
59        elif [ $ddir = "slackware" ]; then
60            dfam="slack"
61            dtype="tgz"
62            suf=".${dfam}${dver}"
63            BUILDDIR=${TOPDIR}/slack
64        elif [ $ddir = "sles" || $ddir = "suse" ]; then
65            dfam="suse"
66            dtype="rpm"
67            suf=".${ddir}${dver}"
68            BUILDDIR=${TOPDIR}/SPECS
69        elif [ $ddir = "fedora" || $ddir = "redhat" || $ddir = "rhel" ]; then
70            dfam="redhat"
71            dtype="rpm"
72            dver=`echo ${dver} | sed "s/\.//"`
73            if [ $ddir = "fedora" ]; then
74                suf=".fc${dver}"
75            elif [ $ddir = "redhat" ]; then
76                suf=".rh${dver}"
77            else
78                suf=".rhel${dver}"
79            fi
80            BUILDDIR=${TOPDIR}/SPECS
81        elif [ $ddir = "mandrake" || $ddir = "mandriva" ]; then
82            dfam="mandriva"
83            dtype="rpm"
84            suf=".`echo $dver | sed 's/\.//'`mdk"
85            BUILDDIR=${TOPDIR}/SPECS
86        else
87            dfam="unknown"
88            dtype="unknown"
89            BUILDDIR=${TOPDIR}/SPECS
90            suf="unknown"
91        fi
92
93        # Create conf file dir
94        mkdir -p ${BUILDDIR}
95
96        if [ $dtype = "rpm" ]; then
97            if [ -f $p-$v/distributions/$ddir/spec.m4 ]; then
98                inc=$p-$v/distributions/$ddir/spec.m4
99            elif [ -f $p-$v/distributions/$dfam/spec.m4 ]; then
100                inc=$p-$v/distributions/$dfam/spec.m4
101            else
102                echo "Unable to build the RPM specfile for this distro. Please report to authors"
103                exit -1
104            fi
105            cp $inc /tmp/mondorescue.mc
106            ddd=`LANG=C ; date '+%Y-%m-%d'`
107            cat >> /tmp/mondorescue.mc << EOF
108define(\`RRR', ${TAG}${suf})dnl
109define(\`VVV', ${v})dnl
110define(\`DDD', ${ddd})dnl
111EOF
112            echo "Using $inc customization to build SPEC file"
113            m4 /tmp/mondorescue.mc $p-$v/distributions/rpm/$p.spec > $p-$v/distributions/$ddir/$p.spec
114
115            if [ -f $p-$v/distributions/$ddir/changelog ]; then
116                log=$p-$v/distributions/$ddir/changelog
117            elif [ -f $p-$v/distributions/$dfam/changelog ]; then
118                log=$p-$v/distributions/$dfam/changelog
119            else
120                echo "Unable to build RPM changelog for this distro. Please report to authors"
121                exit -1
122            fi
123
124            echo "Using $log customization to build changelog file"
125            ddate=`LANG=C ; date "+%a %b %d %Y"`
126            cat > $p-$v/distributions/$ddir/$p.changelog.new << EOF
127* $ddate Bruno Cornec <bruno@mondorescue.org> VVV-RRR
128- Updated to VVV-r${REVISION}
129
130EOF
131            cat $log >> $p-$v/distributions/$ddir/$p.changelog.new
132            m4 /tmp/mondorescue.mc $p-$v/distributions/$ddir/$p.changelog.new > $p-$v/distributions/$ddir/$p.changelog
133            rm -f $p-$v/distributions/$ddir/$p.changelog.new
134
135        elif [ $dtype = "ebuild" ]; then
136            echo "Gentoo Buid"
137        else
138            echo "Unknown Buid"
139        fi
140    done
141
142    if [ _"`echo $p | grep mondo-doc`" != _"" ]; then
143        cd ${p}-${v}
144        for f in mondorescue-howto.sgml *8; do
145            m4 /tmp/mondorescue.mc $f > ${f}.new
146            mv ${f}.new $f
147        done
148        make -f Makefile.howto
149        if [ $? != 0 ]; then
150            exit -1
151        fi
152        make -f Makefile.man
153        if [ $? != 0 ]; then
154            exit -1
155        fi
156        cd ..
157    fi
158
159    if [ _"`echo $p | grep -v kernel | grep mindi`" != _"" ]; then
160        v1=`cat ${SVNBRANCH}/mondo-doc/VERSION`
161        if [ ! -d mondo-doc-$v1 ]; then
162            echo "mondo-doc should be created before $p"
163            exit -1
164        fi
165        (cd mondo-doc-$v1 ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v)
166        rm -f $p-$v/rootfs/sbin/parted2fdisk-ia64
167    fi
168    if [ "`echo $p | grep -v doc | grep  mondo`" != "" ]; then
169        v1=`cat ${SVNBRANCH}/mondo-doc/VERSION`
170        if [ ! -d mondo-doc-$v1 ]; then
171            echo "mondo-doc should be created before $p"
172            exit -1
173        fi
174        (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)
175        (cd $p-$v ; echo "Bootstraping mondo ... " ; ./bootstrap)
176    fi
177
178    # Finally creates the tar files
179    echo "Creating $p tar files"
180    tar cfhz ${TOPDIR}/SOURCES/$p-$v-$TAG.tgz $p-$v
181    tar cfhj ${TOPDIR}/SOURCES/$p-$v-$TAG.tar.bz2 $p-$v
182done
183
184rm -f /tmp/mondorescue.mc
Note: See TracBrowser for help on using the repository browser.