minor improvements for tests in other places than inria
[build.git] / vbuild-nightly.sh
1 #!/bin/bash
2 REVISION=$(echo '$Revision$' | sed -e 's,\$,,g' -e 's,^\w*:\s,,' )
3
4 COMMANDPATH=$0
5 COMMAND=$(basename $0)
6
7 # default values, tunable with command-line options
8 DEFAULT_FCDISTRO=centos5
9 DEFAULT_PLDISTRO=planetlab
10 DEFAULT_PERSONALITY=linux32
11 DEFAULT_BASE="@DATE@--@PLDISTRO@-@FCDISTRO@-@PERSONALITY@"
12 DEFAULT_build_SVNPATH="http://svn.planet-lab.org/svn/build/trunk"
13 DEFAULT_IFNAME=eth0
14
15 # default gpg path used in signing yum repo
16 DEFAULT_GPGPATH="/etc/planetlab"
17 # default email to use in gpg secring
18 DEFAULT_GPGUID="root@$( /bin/hostname )"
19
20 # for publishing results, and the tests settings
21 x=$(hostname)
22 y=$(hostname|sed -e s,inria,,)
23 # INRIA defaults
24 if [ "$x" != "$y" ] ; then
25     DEFAULT_WEBPATH="/build/@PLDISTRO@/"
26     DEFAULT_TESTBUILDURL="http://build.onelab.eu/"
27     # this is where the buildurl is pointing towards
28     DEFAULT_WEBROOT="/build/"
29     DEFAULT_TESTMASTER="testmaster.onelab.eu"
30     DEFAULT_TESTCONFIG="1default"
31 else
32     DEFAULT_WEBPATH="/build/@FCDISTRO@/@PLDISTRO@/"
33     DEFAULT_TESTBUILDURL="http://build.planet-lab.org/"
34     # this is where the buildurl is pointing towards
35     DEFAULT_WEBROOT="/build/"
36     ### xxx change as appropriate
37     DEFAULT_TESTMASTER="p-testmaster.onelab.eu"
38     DEFAULT_TESTCONFIG="pdefault"
39 fi    
40
41 ####################
42 # assuming vserver runs in UTC
43 DATE=$(date +'%Y.%m.%d')
44
45 # temporary - wrap a quick summary of suspicious stuff
46 # this is to focus on installation that go wrong
47 # use with care, a *lot* of other things can go bad as well
48 function summary () {
49     from=$1; shift
50     echo "******************** BEG SUMMARY" 
51     python - $from <<EOF
52 #!/usr/bin/env python
53 # read a full log and tries to extract the interesting stuff
54
55 import sys,re
56 m_show_line=re.compile(".* BEG (RPM|VSERVER).*|.*'boot'.*|\* .*|.*is not installed.*|.*PROPFIND.*|.*Starting.*:runtest.*")
57 m_installing_any=re.compile('\r  (Installing:[^\]]*]) ')
58 m_installing_err=re.compile('\r  (Installing:[^\]]*])(..+)')
59 m_installing_end=re.compile('Installed:.*')
60 m_installing_doc1=re.compile("(.*)install-info: No such file or directory for /usr/share/info/\S+(.*)")
61 m_installing_doc2=re.compile("(.*)grep: /usr/share/info/dir: No such file or directory(.*)")
62
63 def summary (filename):
64
65     try:
66         if filename=="-":
67             filename="stdin"
68             f=sys.stdin
69         else:
70             f=open(filename)
71         echo=False
72         for line in f.xreadlines():
73             # first off : discard warnings related to doc
74             if m_installing_doc1.match(line):
75                 (begin,end)=m_installing_doc1.match(line).groups()
76                 line=begin+end
77             if m_installing_doc2.match(line):
78                 (begin,end)=m_installing_doc2.match(line).groups()
79                 line=begin+end
80             # unconditionnally show these lines
81             if m_show_line.match(line):
82                 print '>>>',line,
83             # an 'installing' line with messages afterwards : needs to be echoed
84             elif m_installing_err.match(line):
85                 (installing,error)=m_installing_err.match(line).groups()
86                 print '>>>',installing
87                 print '>>>',error
88                 echo=True
89             # closing an 'installing' section
90             elif m_installing_end.match(line):
91                 echo=False
92             # any 'installing' line
93             elif m_installing_any.match(line):
94                 if echo: 
95                     installing=m_installing_any.match(line).group(1)
96                     print '>>>',installing
97                 echo=False
98             # print lines when echo is true
99             else:
100                 if echo: print '>>>',line,
101         f.close()
102     except:
103         print 'Failed to analyze',filename
104
105 for arg in sys.argv[1:]:
106     summary(arg)
107 EOF
108     echo "******************** END SUMMARY" 
109 }
110
111
112 # Notify recipient of failure or success, manage various stamps 
113 function failure() {
114     set -x
115     # early stage ? - let's not create /build/@PLDISTRO@
116     if [ ! -d ${WEBPATH} ] ; then
117         WEBPATH=/tmp
118         WEBLOG=/tmp/vbuild-early.log.txt
119     fi
120     cp $LOG ${WEBLOG}
121     summary $LOG >> ${WEBLOG}
122     (echo -n "============================== $COMMAND: failure at " ; date ; tail -c 30k $WEBLOG) > ${WEBLOG}.ko
123     if [ -n "$MAILTO" ] ; then
124         ( \
125             echo "See full build log at ${LOG_URL}" ; \
126             echo "and tail version at ${LOG_URL}.ko" ; \
127             echo "See complete set of testlogs at ${TESTLOGS_URL}" ; \
128             tail -c 30k ${WEBLOG} ) | mail -s "Failures with ${MAIL_SUBJECT} ${BASE}" $MAILTO
129     fi
130     exit 1
131 }
132
133 function success () {
134     set -x
135     # early stage ? - let's not create /build/@PLDISTRO@
136     if [ ! -d ${WEBPATH} ] ; then
137         WEBPATH=/tmp
138         WEBLOG=/tmp/vbuild-early-$(date +%Y-%m-%d).log.txt
139     fi
140     cp $LOG ${WEBLOG}
141     summary $LOG >> ${WEBLOG}
142     if [ -n "$DO_TEST" ] ; then
143         ( \
144             echo "Successfully built and tested" ; \
145             echo "See full build log at ${LOG_URL}" ; \
146             echo "See complete set of testlogs at ${TESTLOGS_URL}" ; \
147             ) > ${WEBLOG}.pass
148         rm -f ${WEBLOG}.pkg-ok ${WEBLOG}.ko
149     else
150         ( \
151             echo "Successful package-only build, no test requested" ; \
152             echo "See full build log at ${LOG_URL}" ; \
153             ) > ${WEBLOG}.pkg-ok
154         rm -f ${WEBLOG}.ko
155     fi
156     if [ -n "$MAILTO" ] ; then
157         ( \
158             echo "$PLDISTRO ($BASE) build for $FCDISTRO completed on $(date)" ; \
159             echo "See full build log at ${LOG_URL}" ; \
160             [ -n "$DO_TEST" ] && echo "See complete set of testlogs at ${TESTLOGS_URL}" ) \
161             | mail -s "Success with ${MAIL_SUBJECT} ${BASE}" $MAILTO
162     fi
163     exit 0
164 }
165
166 # run in the vserver - do not manage success/failure, will be done from the root ctx
167 function build () {
168     set -x
169     set -e
170
171     echo -n "============================== Starting $COMMAND:build on "
172     date
173
174     cd /build
175     show_env
176     
177     echo "Running make IN $(pwd)"
178     
179     # stuff our own variable settings
180     MAKEVARS=("PLDISTRO=${PLDISTRO}" "${MAKEVARS[@]}")
181     MAKEVARS=("PLDISTROTAGS=${PLDISTROTAGS}" "${MAKEVARS[@]}")
182     MAKEVARS=("build-SVNPATH=${build_SVNPATH}" "${MAKEVARS[@]}")
183     MAKEVARS=("PERSONALITY=${PERSONALITY}" "${MAKEVARS[@]}")
184     MAKEVARS=("MAILTO=${MAILTO}" "${MAKEVARS[@]}")
185
186     MAKEVARS=("BASE=${BASE}" "${MAKEVARS[@]}")
187
188     # stage1
189     make -C /build $DRY_RUN "${MAKEVARS[@]}" stage1=true 
190     # store tests_svnpath
191     make -C /build $DRY_RUN "${MAKEVARS[@]}" stage1=true tests_svnpath
192     # versions
193     make -C /build $DRY_RUN "${MAKEVARS[@]}" versions
194     # actual stuff
195     make -C /build $DRY_RUN "${MAKEVARS[@]}" "${MAKETARGETS[@]}"
196
197 }
198
199 # this was formerly run in the myplc-devel chroot but now is run in the root context,
200 # this is so that the .ssh config gets done manually, and once and for all
201 function runtest () {
202     set -x
203     set -e
204     trap failure ERR INT
205
206     echo -n "============================== Starting $COMMAND:runtest on $(date)"
207
208     # where to find TESTS_SVNPATH
209     stamp=/vservers/$BASE/build/tests_svnpath
210     if [ ! -f $stamp ] ; then
211         echo "$COMMAND: Cannot figure TESTS_SVNPATH from missing $stamp"
212         failure
213         exit 1
214     fi
215     TESTS_SVNPATH=$(cat $stamp)
216     # xxx - Thierry - need to rework the test framework in tests/system so it can work
217     # with the entire tests/ module checked out, rather than only tests/system/ 
218     # ugly workaround for now
219     TESTS_SYSTEM_SVNPATH=${TESTS_SVNPATH}/system
220
221     ### the URL to the RPMS/<arch> location
222     url=""
223     for a in i386 x86_64; do
224         archdir=/vservers/$BASE/build/RPMS/$a
225         if [ -d $archdir ] ; then
226             url=$(echo $archdir | sed -e "s,/vservers/$BASE/build,${TESTBUILDURL}${PLDISTRO}/${BASE},")
227             break
228         fi
229     done
230
231     if [ -z "$url" ] ; then
232         echo "$COMMAND: Cannot locate arch URL for testing"
233         failure
234         exit 1
235     fi
236
237     testmaster_ssh="root@${TESTMASTER}"
238
239     # test directory name on test box
240     testdir=${BASE}
241     # clean it
242     ssh -n ${testmaster_ssh} rm -rf ${testdir}
243     # check it out 
244     ssh -n ${testmaster_ssh} svn co ${TESTS_SYSTEM_SVNPATH} ${testdir}
245     # check out the entire tests/ module (with system/ duplicated) as a subdir - see xxx above
246     ssh -n ${testmaster_ssh} svn co ${TESTS_SVNPATH} ${testdir}/tests
247     # invoke test on testbox - pass url and build url - so the tests can use vtest-init-vserver.sh
248     configs=""
249     for config in ${TESTCONFIG} ; do
250         configs="$configs --config $config"
251     done
252     test_env="-p $PERSONALITY -d $PLDISTRO -f $FCDISTRO"
253
254     # need to proceed despite of set -e
255     success=true
256     ssh 2>&1 -n ${testmaster_ssh} ${testdir}/runtest --build ${build_SVNPATH} --url ${url} $configs $test_env --all || success=
257
258     # gather logs in the vserver
259     mkdir -p /vservers/$BASE/build/testlogs
260     ssh 2>&1 -n ${testmaster_ssh} tar -C ${testdir}/logs -cf - . | tar -C /vservers/$BASE/build/testlogs -xf - || true
261     # push them to the build web
262     chmod -R a+r /vservers/$BASE/build/testlogs/
263     rsync --archive --delete /vservers/$BASE/build/testlogs/ $WEBPATH/$BASE/testlogs/
264
265     if [ -z "$success" ] ; then
266         failure
267     fi
268     
269     echo -n "============================== End $COMMAND:runtest on $(date)"
270 }
271
272 function in_root_context () {
273     rpm -q util-vserver > /dev/null 
274 }
275
276 # this part won't work with a remote(rsync) WEBPATH
277 function sign_node_packages () {
278
279     echo "Signing node packages"
280     
281     need_createrepo=""
282
283     repository=$WEBPATH/$BASE/RPMS/
284     # the rpms that need signing
285     new_rpms=
286     # and the corresponding stamps
287     new_stamps=
288
289     for package in $(find $repository/ -name '*.rpm') ; do
290         stamp=$repository/signed-stamps/$(basename $package).signed
291         # If package is newer than signature stamp
292         if [ $package -nt $stamp ] ; then
293             new_rpms="$new_rpms $package"
294             new_stamps="$new_stamps $stamp"
295         fi
296         # Or than createrepo database
297         [ $package -nt $repository/repodata/repomd.xml ] && need_createrepo=true
298     done
299
300     if [ -n "$new_rpms" ] ; then
301         # Create a stamp once the package gets signed
302         mkdir $repository/signed-stamps 2> /dev/null
303         
304         # Sign RPMS. setsid detaches rpm from the terminal,
305         # allowing the (hopefully blank) GPG password to be
306         # entered from stdin instead of /dev/tty.
307         echo | setsid rpm \
308             --define "_signature gpg" \
309             --define "_gpg_path $GPGPATH" \
310             --define "_gpg_name $GPGUID" \
311             --resign $new_rpms && touch $new_stamps
312     fi
313
314      # Update repository index / yum metadata. 
315     if [ -n "$need_createrepo" ] ; then
316         echo "Indexing node packages after signing"
317         if [ -f $repository/yumgroups.xml ] ; then
318             createrepo --quiet -g yumgroups.xml $repository
319         else
320             createrepo --quiet $repository
321         fi
322     fi
323 }
324
325 function show_env () {
326     set +x
327     echo FCDISTRO=$FCDISTRO
328     echo PLDISTRO=$PLDISTRO
329     echo PERSONALITY=$PERSONALITY
330     echo BASE=$BASE
331     echo build_SVNPATH=$build_SVNPATH
332     echo MAKEVARS="${MAKEVARS[@]}"
333     echo DRY_RUN="$DRY_RUN"
334     echo PLDISTROTAGS="$PLDISTROTAGS"
335     # this does not help, it's not yet set when we run show_env
336     #echo WEBPATH="$WEBPATH"
337     echo TESTBUILDURL="$TESTBUILDURL"
338     if in_root_context ; then
339         echo PLDISTROTAGS="$PLDISTROTAGS"
340     else
341         if [ -f /build/$PLDISTROTAGS ] ; then
342             echo "XXXXXXXXXXXXXXXXXXXX Contents of tags definition file /build/$PLDISTROTAGS"
343             cat /build/$PLDISTROTAGS
344             echo "XXXXXXXXXXXXXXXXXXXX end tags definition"
345         else
346             echo "XXXXXXXXXXXXXXXXXXXX Cannot find tags definition file /build/$PLDISTROTAGS, assuming remote pldistro"
347         fi
348     fi
349     set -x
350 }
351
352 function usage () {
353     echo "Usage: $COMMAND [option] [var=value...] make-targets"
354     echo "This is $REVISION"
355     echo "Supported options"
356     echo " -f fcdistro - defaults to $DEFAULT_FCDISTRO"
357     echo " -d pldistro - defaults to $DEFAULT_PLDISTRO"
358     echo " -p personality - defaults to $DEFAULT_PERSONALITY"
359     echo " -m mailto - no default"
360     echo " -s svnpath - where to fetch the build module - defaults to $DEFAULT_build_SVNPATH"
361     echo " -t pldistrotags - defaults to \${PLDISTRO}-tags.mk"
362     echo " -b base - defaults to $DEFAULT_BASE"
363     echo "    @NAME@ replaced as appropriate"
364     echo " -o base: (overwrite) do not re-create vserver, re-use base instead"
365     echo "    the -f/-d/-p/-m/-s/-t options are uneffective in this case"
366     echo " -c testconfig - defaults to $DEFAULT_TESTCONFIG"
367     echo " -w webpath - defaults to $DEFAULT_WEBPATH"
368     echo " -W testbuildurl - defaults to $DEFAULT_TESTBUILDURL"
369     echo " -r webroot - defaults to $DEFAULT_WEBROOT - the fs point where testbuildurl actually sits"
370     echo " -M testmaster - defaults to $DEFAULT_TESTMASTER"
371     echo " -y sign yum repo in webpath"
372     echo " -g path to gpg secring used to sign rpms.  Defaults to $DEFAULT_GPGPATH" 
373     echo " -u gpg email used in secring. Defaults to $DEFAULT_GPGUID"
374     echo " -B : run build only"
375     echo " -T : run test only"
376     echo " -n dry-run : -n passed to make - vserver gets created though - no mail sent"
377     echo " -v : be verbose"
378     echo " -7 : uses weekday-@FCDISTRO@ as base"
379     echo " -i ifname - defaults to $DEFAULT_IFNAME - used to determine local IP"
380     exit 1
381 }
382
383 function main () {
384
385     set -e
386
387     # parse arguments
388     MAKEVARS=()
389     MAKETARGETS=()
390     DRY_RUN=
391     DO_BUILD=true
392     DO_TEST=true
393     SIGNYUMREPO=""
394     while getopts "f:d:p:m:s:t:b:o:c:w:W:M:yg:u:BTnv7i:" opt ; do
395         case $opt in
396             f) FCDISTRO=$OPTARG ;;
397             d) PLDISTRO=$OPTARG ;;
398             p) PERSONALITY=$OPTARG ;;
399             m) MAILTO=$OPTARG ;;
400             s) build_SVNPATH=$OPTARG ;;
401             t) PLDISTROTAGS=$OPTARG ;;
402             b) BASE=$OPTARG ;;
403             o) OVERBASE=$OPTARG ;;
404             c) TESTCONFIG="$TESTCONFIG $OPTARG" ;;
405             w) WEBPATH=$OPTARG ;;
406             W) TESTBUILDURL=$OPTARG ;;
407             r) WEBROOT=$OPTARG ;;
408             M) TESTMASTER=$OPTARG ;;
409             y) SIGNYUMREPO=true ;;
410             g) GPGPATH=$OPTARG ;;
411             u) GPGUID=$OPTARG ;;
412             B) DO_TEST= ;;
413             T) DO_BUILD= ;;
414             n) DRY_RUN="-n" ;;
415             v) set -x ;;
416             7) BASE="$(date +%a|tr A-Z a-z)-@FCDISTRO@" ;;
417             i) IFNAME=$OPTARG ;;
418             h|*) usage ;;
419         esac
420     done
421         
422     # preserve options for passing them again later, together with expanded base
423     declare -a options
424     toshift=$(($OPTIND - 1))
425     arg=1; while [ $arg -le $toshift ] ; do options=(${options[@]} "$1") ; shift; arg=$(($arg+1)) ; done
426
427     # allow var=value stuff; 
428     for target in "$@" ; do
429         # check if contains '='
430         target1=$(echo $target | sed -e s,=,,)
431         if [ "$target" = "$target1" ] ; then
432             MAKETARGETS=(${MAKETARGETS[@]} "$target")
433         else
434             MAKEVARS=(${MAKEVARS[@]} "$target")
435         fi
436     done
437     
438     # set defaults
439     [ -z "$FCDISTRO" ] && FCDISTRO=$DEFAULT_FCDISTRO
440     [ -z "$PLDISTRO" ] && PLDISTRO=$DEFAULT_PLDISTRO
441     [ -z "$PERSONALITY" ] && PERSONALITY=$DEFAULT_PERSONALITY
442     [ -z "$PLDISTROTAGS" ] && PLDISTROTAGS="${PLDISTRO}-tags.mk"
443     [ -z "$BASE" ] && BASE="$DEFAULT_BASE"
444     [ -z "$WEBPATH" ] && WEBPATH="$DEFAULT_WEBPATH"
445     [ -z "$TESTBUILDURL" ] && TESTBUILDURL="$DEFAULT_TESTBUILDURL"
446     [ -z "$WEBROOT" ] && WEBROOT="$DEFAULT_WEBROOT"
447     [ -z "$GPGPATH" ] && GPGPATH="$DEFAULT_GPGPATH"
448     [ -z "$GPGUID" ] && GPGUID="$DEFAULT_GPGUID"
449     [ -z "$IFNAME" ] && IFNAME="$DEFAULT_IFNAME"
450     [ -z "$build_SVNPATH" ] && build_SVNPATH="$DEFAULT_build_SVNPATH"
451     [ -z "$TESTCONFIG" ] && TESTCONFIG="$DEFAULT_TESTCONFIG"
452     [ -z "$TESTMASTER" ] && TESTMASTER="$DEFAULT_TESTMASTER"
453
454     [ -n "$DRY_RUN" ] && MAILTO=""
455         
456     if [ -n "$OVERBASE" ] ; then
457         sedargs="-e s,@DATE@,${DATE},g"
458         BASE=$(echo ${OVERBASE} | sed $sedargs)
459     else
460         sedargs="-e s,@DATE@,${DATE},g -e s,@FCDISTRO@,${FCDISTRO},g -e s,@PLDISTRO@,${PLDISTRO},g -e s,@PERSONALITY@,${PERSONALITY},g"
461         BASE=$(echo ${BASE} | sed $sedargs)
462     fi
463
464     ### elaborate mail subject
465     if [ -n "$DO_BUILD" -a -n "$DO_TEST" ] ; then
466         MAIL_SUBJECT="complete"
467     elif [ -n "$DO_BUILD" ] ; then
468         MAIL_SUBJECT="package-only"
469     elif [ -n "$DO_TEST" ] ; then
470         MAIL_SUBJECT="test-only"
471     fi
472     if [ -n "$OVERBASE" ] ; then
473         MAIL_SUBJECT="$MAIL_SUBJECT incremental run on"
474     else
475         MAIL_SUBJECT="$MAIL_SUBJECT fresh build"
476     fi
477
478     if ! in_root_context ; then
479         # in the vserver
480         echo "==================== Within vserver BEG $(date)"
481         build
482         echo "==================== Within vserver END $(date)"
483
484     else
485         trap failure ERR INT
486         # we run in the root context : 
487         # (*) create or check for the vserver to use
488         # (*) copy this command in the vserver
489         # (*) invoke it
490         
491         if [ -n "$OVERBASE" ] ; then
492             ### Re-use a vserver (finish an unfinished build..)
493             if [ ! -d /vservers/${BASE} ] ; then
494                 echo $COMMAND : cannot find vserver $BASE
495                 exit 1
496             fi
497             # manage LOG - beware it might be a symlink so nuke it first
498             LOG=/vservers/${BASE}.log.txt
499             rm -f $LOG
500             exec > $LOG 2>&1
501             set -x
502             echo "XXXXXXXXXX $COMMAND: using existing vserver $BASE" $(date)
503             # start in case e.g. we just rebooted
504             vserver ${BASE} start || :
505             # update build
506             vserver ${BASE} exec svn update /build
507             # get environment from the first run 
508             FCDISTRO=$(vserver ${BASE} exec /build/getdistroname.sh)
509
510             PLDISTRO=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +PLDISTRO)
511             PLDISTROTAGS=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +PLDISTROTAGS)
512             build_SVNPATH=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +build-SVNPATH)
513             PERSONALITY=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +PERSONALITY)
514             MAILTO=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +MAILTO)
515             WEBPATH=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +WEBPATH)
516             TESTBUILDURL=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +TESTBUILDURL)
517             WEBROOT=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +WEBROOT)
518             show_env
519         else
520             # create vserver: check it does not exist yet
521             i=
522             while [ -d /vservers/${BASE}${i} ] ; do
523                 # we name subsequent builds <base>-n<i> so the logs and builds get sorted properly
524                 [ -z ${i} ] && BASE=${BASE}-n
525                 i=$((${i}+1))
526                 if [ $i -gt 100 ] ; then
527                     echo "$COMMAND: Failed to create build vserver /vservers/${BASE}${i}"
528                     exit 1
529                 fi
530             done
531             BASE=${BASE}${i}
532             # need update
533             # manage LOG - beware it might be a symlink so nuke it first
534             LOG=/vservers/${BASE}.log.txt
535             rm -f $LOG
536             exec > $LOG 2>&1 
537             set -x
538             echo "XXXXXXXXXX $COMMAND: creating vserver $BASE" $(date)
539             show_env
540
541             ### extract the whole build - much simpler
542             tmpdir=/tmp/$COMMAND-$$
543             svn export $build_SVNPATH $tmpdir
544             # Create vserver
545             cd $tmpdir
546             ./vbuild-init-vserver.sh -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} -i ${IFNAME} ${BASE} 
547             # cleanup
548             cd -
549             rm -rf $tmpdir
550             # Extract build again - in the vserver
551             vserver ${BASE} exec svn checkout ${build_SVNPATH} /build
552         fi
553         echo "XXXXXXXXXX $COMMAND: preparation of vserver $BASE done" $(date)
554
555         # The log inside the vserver contains everything
556         LOG2=/vservers/${BASE}/log.txt
557         (echo "==================== BEG VSERVER Transcript of vserver creation" ; \
558          cat $LOG ; \
559          echo "==================== END VSERVER Transcript of vserver creation" ; \
560          echo "xxxxxxxxxx Messing with logs, symlinking $LOG2 to $LOG" ) >> $LOG2
561         ### not too nice : nuke the former log, symlink it to the new one
562         rm $LOG; ln -s $LOG2 $LOG
563         LOG=$LOG2
564         # redirect log again
565         exec >> $LOG 2>&1 
566
567         sedargs="-e s,@DATE@,${DATE},g -e s,@FCDISTRO@,${FCDISTRO},g -e s,@PLDISTRO@,${PLDISTRO},g -e s,@PERSONALITY@,${PERSONALITY},g"
568         WEBPATH=$(echo ${WEBPATH} | sed $sedargs)
569         mkdir -p ${WEBPATH}
570
571         # where to store the log for web access
572         WEBLOG=${WEBPATH}/${BASE}.log.txt
573         # compute the log URL - inserted in the mail messages for convenience
574         LOG_URL=$(echo ${WEBLOG} | sed -e "s,//,/,g" -e "s,${WEBROOT},${TESTBUILDURL},")
575         TESTLOGS_URL=$(echo ${WEBPATH}/${BASE}/testlogs | sed -e "s,//,/,g" -e "s,${WEBROOT},${TESTBUILDURL},")
576     
577         if [ -n "$DO_BUILD" ] ; then 
578
579             cp $COMMANDPATH /vservers/${BASE}/build/
580
581             # invoke this command in the vserver for building (-T)
582             vserver ${BASE} exec chmod +x /build/$COMMAND
583             vserver ${BASE} exec /build/$COMMAND "${options[@]}" -b "${BASE}" "${MAKEVARS[@]}" "${MAKETARGETS[@]}"
584         fi
585
586         # publish to the web so runtest can find them
587         rm -rf $WEBPATH/$BASE ; mkdir -p $WEBPATH/$BASE/{RPMS,SRPMS}
588         rsync --archive --delete --verbose /vservers/$BASE/build/RPMS/ $WEBPATH/$BASE/RPMS/
589         rsync --archive --delete --verbose /vservers/$BASE/build/SRPMS/ $WEBPATH/$BASE/SRPMS/
590         # publish myplc-release
591         rsync --verbose /vservers/$BASE/build/myplc-release $WEBPATH/$BASE
592
593         # create yum repo and sign packages.
594         if [ -n "$SIGNYUMREPO" ] ; then
595             sign_node_packages
596         fi
597
598         if [ -n "$DO_TEST" ] ; then 
599             runtest
600         fi
601
602         success 
603         
604     fi
605
606 }  
607
608 ##########
609 main "$@"