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