source: ProjectBuilder/devel/pb/bin/cms2build.pl@ 5

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

Lots of modifs to find the right way. Probably still not good

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