source: MondoRescue/branches/2.2.5/tools/svn2build@ 1682

Last change on this file since 1682 was 1490, checked in by Bruno Cornec, 17 years ago

Stricter POSIX conformance for all shell scripts (== replaced by = in compare)

  • Property svn:executable set to *
File size: 5.3 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
21VER=`cat ${TOOLHOME}/../mondo/VERSION`
22TAG=`cat ${TOOLHOME}/../mondo/TAG`
23DEST=${TOPDIR}/${VER}-$TAG
24TEST="false"
25OPT=""
26mkdir -p $DEST
27
28if [ "$1" = "--test" ]; then
29 TEST="true"
30 OPT="-r BASE"
31 shift
32fi
33
34if [ "$1" = "" ]; then
35 c="mondo-doc mindi mindi-busybox mondo"
36else
37 if [ "$1" = "all" ]; then
38 c="mindi-kernel mondo-doc mindi mindi-busybox mondo"
39 else
40 c="$*"
41 fi
42fi
43
44# Make it safe for SVN commands
45cd ${TOOLHOME}/..
46
47for p in $c; do
48 v=`cat ${TOOLHOME}/../$p/VERSION`
49 tag=`cat ${TOOLHOME}/../$p/TAG`
50 echo "Management of $p $v-$tag (rev $REVISION)"
51 dest="$DEST/$p-$v"
52 rm -fr $dest
53 svn $OPT export ${TOOLHOME}/../$p $dest
54 echo "$REVISION" > $dest/REVISION
55 echo "Generating SVN log file ..."
56 svn $OPT log -v ${TOOLHOME}/../$p > $dest/svn.log
57
58 for d in `cat ${TOOLHOME}/DISTROS`; do
59 export ddir=`echo $d | cut -d_ -f1`
60 export dver=`echo $d | cut -d_ -f2`
61 echo "Generating build files for $ddir ($dver)"
62 . $TOOLHOME/distro-env
63
64 ddd=`LANG=C ; date '+%Y-%m-%d'`
65 cat > $MONDOTMP/mondorescue.mc << EOF
66define(\`TTT', ${tag})dnl
67define(\`RRR', ${tag}${suf})dnl
68define(\`VVV', ${v})dnl
69define(\`DDD', ${ddd})dnl
70EOF
71
72 mkdir -p $dest/distributions/$ddir $dest/distributions/${ddir}-$dver
73 if [ "$dtype" = "rpm" ]; then
74 if [ -f $dest/distributions/$ddir/spec.m4 ]; then
75 inc=$dest/distributions/$ddir/spec.m4
76 elif [ -f $dest/distributions/$dfam/spec.m4 ]; then
77 inc=$dest/distributions/$dfam/spec.m4
78 else
79 echo "Unable to build the RPM specfile for this distro. Please report to authors"
80 exit -1
81 fi
82
83 if [ $ddir = "fedora" ]; then
84 $TOOLHOME/mkchangelog.pl fc $p $MONDOTMP/$p-fc.spec
85 m4 $MONDOTMP/mondorescue.mc $inc $dest/distributions/rpm/$p.spec $MONDOTMP/$p-fc.spec > $dest/distributions/${ddir}-$dver/$p-fc.spec
86 fi
87 $TOOLHOME/mkchangelog.pl $dtype $p $MONDOTMP/$p.spec
88 if [ $? -ne 0 ]; then
89 echo "Unable to create changelog for ${ddir}-$dver/$p.spec"
90 exit -1
91 fi
92 m4 $MONDOTMP/mondorescue.mc $inc $dest/distributions/rpm/$p.spec $MONDOTMP/$p.spec > $dest/distributions/${ddir}-$dver/$p.spec
93
94 rm -f $MONDOTMP/$p.spec
95 elif [ "$dtype" = "ebuild" ]; then
96 m4 $MONDOTMP/mondorescue.mc $dest/distributions/$dfam/$p.ebuild > $dest/distributions/${ddir}-$dver/$p-$v.ebuild
97 elif [ "$dtype" = "tgz" ]; then
98 m4 $MONDOTMP/mondorescue.mc $dest/distributions/$dfam/slack-desc > $dest/distributions/${ddir}-$dver/slack-desc
99 elif [ "$dtype" = "port" ]; then
100 m4 $MONDOTMP/mondorescue.mc $dest/distributions/$dfam/Makefile > $dest/distributions/${ddir}-$dver/Makefile
101 elif [ "$dtype" = "deb" ]; then
102 if [ -f $dest/distributions/$ddir/rules ]; then
103 cp -a $dest/distributions/$ddir/* $dest/distributions/${ddir}-$dver
104 inc=$dest/distributions/$ddir/rules
105 elif [ -f $dest/distributions/$dfam/rules ]; then
106 cp -a $dest/distributions/$dfam/* $dest/distributions/${ddir}-$dver
107 inc=$dest/distributions/$dfam/rules
108 else
109 echo "Unable to build the .deb build files for this distro. Please report to authors"
110 exit -1
111 fi
112 m4 $MONDOTMP/mondorescue.mc $inc > $dest/distributions/${ddir}-$dver/rules
113 $TOOLHOME/mkchangelog.pl $dtype $p $dest/distributions/${ddir}-$dver/changelog
114 if [ $? -ne 0 ]; then
115 echo "Unable to create changelog for ${ddir}-$dver/changelog"
116 exit -1
117 fi
118 else
119 echo "Unknown Build"
120 fi
121 done
122
123 # The rest is done there
124 cd $DEST
125 if [ _"`echo $p | grep mondo-doc`" != _"" ]; then
126 cd $dest
127 for f in mondorescue-howto.sgml *8; do
128 m4 $MONDOTMP/mondorescue.mc $f > ${f}.new
129 mv ${f}.new $f
130 done
131 make -f Makefile.howto
132 if [ $? != 0 ]; then
133 exit -1
134 fi
135 make -f Makefile.man
136 if [ $? != 0 ]; then
137 exit -1
138 fi
139 cd ..
140 fi
141 if [ _"`echo $p | grep 'busybox'`" != _"" ]; then
142 cd $dest
143 mv Rules.mak Rules.mak.orig
144 cat Rules.mak.orig | sed "s/^EXTRAVERSION\([\t ]*\):=/EXTRAVERSION\1:=-$tag-r$REVISION/" > Rules.mak
145 cd ..
146 fi
147
148 if [ _"`echo $p | grep -vE 'kernel|busybox' | grep mindi`" != _"" ]; then
149 v1=`cat ${TOOLHOME}/../mondo-doc/VERSION`
150 if [ ! -d mondo-doc-$v1 ]; then
151 echo "mondo-doc should be created before $p"
152 exit -1
153 fi
154 (cd mondo-doc-$v1 ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v)
155 rm -f $dest/rootfs/sbin/parted2fdisk-ia64
156 fi
157 if [ "`echo $p | grep -v doc | grep mondo`" != "" ]; then
158 v1=`cat ${TOOLHOME}/../mondo-doc/VERSION`
159 if [ ! -d mondo-doc-$v1 ]; then
160 echo "mondo-doc should be created before $p"
161 exit -1
162 fi
163 (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)
164 (cd $dest ; echo "Bootstraping mondo ... " ; ./bootstrap)
165 fi
166
167 # Finally creates the tar files
168 echo -n "Creating $p tar files (gzip... "
169 tar cfphz ${DEST}/$p-$v.tar.gz $p-$v
170 if [ $TEST = "false" ]; then
171 echo -n " bzip2..."
172 tar cfphj ${DEST}/$p-$v.tar.bz2 $p-$v
173 fi
174 echo " )"
175 if [ $TEST = "true" ]; then
176 echo "Use source under $DEST/$p-$v"
177 fi
178done
179
180rm -rf $MONDOTMP
181
182echo "Version delivered :"
183echo "-------------------"
184echo "${VER}-$TAG"
185echo "-------------------"
186echo "${VER}-$TAG" > ${TOPDIR}/LAST
187exit 0
188) 2>&1 | tee /tmp/svn2build.log
Note: See TracBrowser for help on using the repository browser.