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