source: MondoRescue/branches/stable/tools/svn2build@ 551

Last change on this file since 551 was 551, checked in by bcornec, 18 years ago

mondo-doc & mindi-kernel structure updated for build management

  • Property svn:executable set to *
File size: 4.8 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 -d_ -f1`
47 dver=`echo $d | cut -d_ -f2`
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" -o $ddir = "suse" ]; then
65 dfam="suse"
66 dtype="rpm"
67 suf=".${ddir}${dver}"
68 BUILDDIR=${TOPDIR}/SPECS
69 elif [ $ddir = "fedora" -o $ddir = "redhat" -o $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" -o $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 ddd=`LANG=C ; date '+%Y-%m-%d'`
97 cat > /tmp/mondorescue.mc << EOF
98define(\`RRR', ${TAG}${suf})dnl
99define(\`VVV', ${v})dnl
100define(\`DDD', ${ddd})dnl
101EOF
102
103 mkdir -p $p-$v/distributions/$ddir
104 if [ $dtype = "rpm" ]; then
105 if [ -f $p-$v/distributions/$ddir/spec.m4 ]; then
106 inc=$p-$v/distributions/$ddir/spec.m4
107 elif [ -f $p-$v/distributions/$dfam/spec.m4 ]; then
108 inc=$p-$v/distributions/$dfam/spec.m4
109 else
110 echo "Unable to build the RPM specfile for this distro. Please report to authors"
111 exit -1
112 fi
113 echo "Using $inc customization to build SPEC file"
114 m4 /tmp/mondorescue.mc $inc $p-$v/distributions/rpm/$p.spec > $p-$v/distributions/$ddir/$p.spec
115
116 if [ -f $p-$v/distributions/$ddir/changelog ]; then
117 log=$p-$v/distributions/$ddir/changelog
118 elif [ -f $p-$v/distributions/$dfam/changelog ]; then
119 log=$p-$v/distributions/$dfam/changelog
120 else
121 echo "Unable to build RPM changelog for this distro. Please report to authors"
122 exit -1
123 fi
124
125 echo "Using $log customization to build changelog file"
126 ddate=`LANG=C ; date "+%a %b %d %Y"`
127 cat > $p-$v/distributions/$ddir/$p.changelog.new << EOF
128* $ddate Bruno Cornec <bruno@mondorescue.org> VVV-RRR
129- Updated to VVV-r${REVISION}
130
131EOF
132 cat $log >> $p-$v/distributions/$ddir/$p.changelog.new
133 m4 /tmp/mondorescue.mc $p-$v/distributions/$ddir/$p.changelog.new > $p-$v/distributions/$ddir/$p.changelog
134 rm -f $p-$v/distributions/$ddir/$p.changelog.new
135
136 elif [ $dtype = "ebuild" ]; then
137 echo "Gentoo Build"
138 else
139 echo "Unknown Build"
140 fi
141 done
142
143 if [ _"`echo $p | grep mondo-doc`" != _"" ]; then
144 cd ${p}-${v}
145 for f in mondorescue-howto.sgml *8; do
146 m4 /tmp/mondorescue.mc $f > ${f}.new
147 mv ${f}.new $f
148 done
149 make -f Makefile.howto
150 if [ $? != 0 ]; then
151 exit -1
152 fi
153 make -f Makefile.man
154 if [ $? != 0 ]; then
155 exit -1
156 fi
157 cd ..
158 fi
159
160 if [ _"`echo $p | grep -v kernel | grep mindi`" != _"" ]; then
161 v1=`cat ${SVNBRANCH}/mondo-doc/VERSION`
162 if [ ! -d mondo-doc-$v1 ]; then
163 echo "mondo-doc should be created before $p"
164 exit -1
165 fi
166 (cd mondo-doc-$v1 ; make -f Makefile.man install-$p INSTALLDIR=../$p-$v)
167 rm -f $p-$v/rootfs/sbin/parted2fdisk-ia64
168 fi
169 if [ "`echo $p | grep -v doc | grep mondo`" != "" ]; then
170 v1=`cat ${SVNBRANCH}/mondo-doc/VERSION`
171 if [ ! -d mondo-doc-$v1 ]; then
172 echo "mondo-doc should be created before $p"
173 exit -1
174 fi
175 (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)
176 (cd $p-$v ; echo "Bootstraping mondo ... " ; ./bootstrap)
177 fi
178
179 # Finally creates the tar files
180 echo "Creating $p tar files"
181 tar cfhz ${TOPDIR}/SOURCES/$p-$v-$TAG.tar.gz $p-$v
182 gzip -cd ${TOPDIR}/SOURCES/$p-$v-$TAG.tar.gz | bzip2 -c3 > ${TOPDIR}/SOURCES/$p-$v-$TAG.tar.bz2
183 #tar cfhj ${TOPDIR}/SOURCES/$p-$v-$TAG.tar.bz2 $p-$v
184done
185
186rm -f /tmp/mondorescue.mc
Note: See TracBrowser for help on using the repository browser.