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