2 REVISION=$(echo '$Revision: 18120 $' | sed -e 's,\$,,g' -e 's,^\w*:\s,,' )
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_SCM_URL="git://git.onelab.eu/build"
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 )"
20 DEFAULT_TESTCONFIG="default"
22 # for publishing results, and the tests settings
24 y=$(hostname|sed -e s,inria,,)
26 if [ "$x" != "$y" ] ; then
27 DEFAULT_WEBPATH="/build/@PLDISTRO@/"
28 DEFAULT_TESTBUILDURL="http://build.onelab.eu/"
29 # this is where the buildurl is pointing towards
30 DEFAULT_WEBROOT="/build/"
31 DEFAULT_TESTMASTER="testmaster.onelab.eu"
33 DEFAULT_WEBPATH="/build/@FCDISTRO@/@PLDISTRO@/"
34 DEFAULT_TESTBUILDURL="http://build.planet-lab.org/"
35 # this is where the buildurl is pointing towards
36 DEFAULT_WEBROOT="/build/"
37 DEFAULT_TESTMASTER="manager.test.planet-lab.org"
41 # assuming vserver runs in UTC
42 DATE=$(date +'%Y.%m.%d')
44 # temporary - wrap a quick summary of suspicious stuff
45 # this is to focus on installation that go wrong
46 # use with care, a *lot* of other things can go bad as well
49 echo "******************** BEG SUMMARY"
52 # read a full log and tries to extract the interesting stuff
55 m_show_line=re.compile(".* (BEG|END) (RPM|VSERVER).*|.*'boot'.*|\* .*| \* .*|.*is not installed.*|.*PROPFIND.*|.* (BEG|END).*:run_log.*|.* Within vserver (BEG|END) .*|.* MAIN (BEG|END).*")
56 m_installing_any=re.compile('\r (Installing:[^\]]*]) ')
57 m_installing_err=re.compile('\r (Installing:[^\]]*])(..+)')
58 m_installing_end=re.compile('Installed:.*')
59 m_installing_doc1=re.compile("(.*)install-info: No such file or directory for /usr/share/info/\S+(.*)")
60 m_installing_doc2=re.compile("(.*)grep: /usr/share/info/dir: No such file or directory(.*)")
62 def summary (filename):
71 for line in f.xreadlines():
72 # first off : discard warnings related to doc
73 if m_installing_doc1.match(line):
74 (begin,end)=m_installing_doc1.match(line).groups()
76 if m_installing_doc2.match(line):
77 (begin,end)=m_installing_doc2.match(line).groups()
79 # unconditionnally show these lines
80 if m_show_line.match(line):
82 # an 'installing' line with messages afterwards : needs to be echoed
83 elif m_installing_err.match(line):
84 (installing,error)=m_installing_err.match(line).groups()
85 print '>>>',installing
88 # closing an 'installing' section
89 elif m_installing_end.match(line):
91 # any 'installing' line
92 elif m_installing_any.match(line):
94 installing=m_installing_any.match(line).group(1)
95 print '>>>',installing
97 # print lines when echo is true
99 if echo: print '>>>',line,
102 print 'Failed to analyze',filename
104 for arg in sys.argv[1:]:
107 echo "******************** END SUMMARY"
110 ### we might build on a box other than the actual web server
111 # utilities for handling the pushed material (rpms, logfiles, ...)
112 function webpublish_misses_dir () { ssh root@${WEBHOST} "bash -c \"test \! -d $1\"" ; }
113 function webpublish () { ssh root@${WEBHOST} "$@" ; }
114 function webpublish_rsync_dir () { rsync --archive --delete $VERBOSE $1 root@${WEBHOST}:$2 ; }
115 function webpublish_rsync_file () { rsync $VERBOSE $1 root@${WEBHOST}:$2 ; }
116 function webpublish_cp_local_to_remote () { scp $1 root@${WEBHOST}:$2 ; }
117 function webpublish_cp_stdin_to_file () { ssh root@${WEBHOST} cat \> $1; }
118 function webpublish_append_stdin_to_file () { ssh root@${WEBHOST} cat \>\> $1; }
120 # Notify recipient of failure or success, manage various stamps
123 # early stage ? - let's not create /build/@PLDISTRO@
124 if test -z "$WEBLOG" ; then
127 WEBBASE=/tmp/vbuild-early-$(date +%Y-%m-%d)
128 WEBLOG=/tmp/vbuild-early-$(date +%Y-%m-%d).log.txt
130 webpublish mkdir -p $WEBBASE ||:
131 webpublish_cp_local_to_remote $LOG $WEBLOG ||:
132 summary $LOG | webpublish_append_stdin_to_file $WEBLOG ||:
133 (echo -n "============================== $COMMAND: failure at " ; date ; \
134 webpublish tail --lines=1000 $WEBLOG) | \
135 webpublish_cp_stdin_to_file $WEBBASE.ko ||:
136 if [ -n "$MAILTO" ] ; then
138 echo "Subject: Failures with $MAIL_SUBJECT $BASE on $(hostname)" ; \
139 echo "To: $MAILTO" ; \
140 echo "See full build log at $WEBBASE_URL/log.txt" ; \
141 echo "and tail version at $WEBBASE_URL.ko" ; \
142 echo "See complete set of testlogs at $WEBBASE_URL/testlogs" ; \
143 echo "........................................" ; \
144 webpublish tail --lines=1000 $WEBLOG ) | \
150 function success () {
152 # early stage ? - let's not create /build/@PLDISTRO@
153 if test -z "$WEBLOG" ; then
156 WEBLOG=/tmp/vbuild-early-$(date +%Y-%m-%d).log.txt
158 webpublish mkdir -p $WEBBASE
159 webpublish_cp_local_to_remote $LOG $WEBLOG
160 summary $LOG | webpublish_append_stdin_to_file $WEBLOG
161 if [ -n "$DO_TEST" ] ; then
163 echo "Successfully built and tested" ; \
164 echo "See full build log at $WEBBASE_URL/log.txt" ; \
165 echo "See complete set of testlogs at $WEBBASE_URL/testlogs" ; \
166 ) | webpublish_cp_stdin_to_file $WEBBASE.pass
167 webpublish rm -f $WEBBASE.pkg-ok $WEBBASE.ko
170 echo "Successful package-only build, no test requested" ; \
171 echo "See full build log at $WEBBASE_URL/log.txt" ; \
172 ) | webpublish_cp_stdin_to_file $WEBBASE.pkg-ok
173 webpublish rm -f $WEBBASE.ko
175 if [ -n "$MAILTO" ] ; then
177 echo "Subject: Success with ${MAIL_SUBJECT} ${BASE} on $(hostname)" ; \
178 echo "To: $MAILTO" ; \
179 echo "$PLDISTRO ($BASE) build for $FCDISTRO completed on $(date)" ; \
180 echo "See full build log at $WEBBASE_URL/log.txt" ; \
181 [ -n "$DO_TEST" ] && echo "See complete set of testlogs at $WEBBASE_URL/testlogs" ) \
184 # XXX For some reason, we haven't been getting this email for successful builds. If this sleep
185 # doesn't fix the problem, I'll remove it -- Sapan.
190 # run in the vserver - do not manage success/failure, will be done from the root ctx
195 echo -n "============================== Starting $COMMAND:build on "
201 echo "Running make IN $(pwd)"
203 # stuff our own variable settings
204 if echo $BUILD_SCM_URL | grep -q git ; then
205 MAKEVARS=("build-GITPATH=${BUILD_SCM_URL}" "${MAKEVARS[@]}")
207 MAKEVARS=("build-SVNPATH=${BUILD_SCM_URL}" "${MAKEVARS[@]}")
209 MAKEVARS=("PLDISTRO=${PLDISTRO}" "${MAKEVARS[@]}")
210 MAKEVARS=("PLDISTROTAGS=${PLDISTROTAGS}" "${MAKEVARS[@]}")
211 MAKEVARS=("PERSONALITY=${PERSONALITY}" "${MAKEVARS[@]}")
212 MAKEVARS=("MAILTO=${MAILTO}" "${MAKEVARS[@]}")
213 MAKEVARS=("WEBPATH=${WEBPATH}" "${MAKEVARS[@]}")
214 MAKEVARS=("TESTBUILDURL=${TESTBUILDURL}" "${MAKEVARS[@]}")
215 MAKEVARS=("WEBROOT=${WEBROOT}" "${MAKEVARS[@]}")
217 MAKEVARS=("BASE=${BASE}" "${MAKEVARS[@]}")
220 /build/latex-first-run.sh || :
223 make -C /build $DRY_RUN "${MAKEVARS[@]}" stage1=true
225 make -C /build $DRY_RUN "${MAKEVARS[@]}" versions
227 make -C /build $DRY_RUN "${MAKEVARS[@]}" "${MAKETARGETS[@]}"
231 # this was formerly run in the myplc-devel chroot but now is run in the root context,
232 # this is so that the .ssh config gets done manually, and once and for all
233 function run_log () {
238 echo "============================== BEG $COMMAND:run_log on $(date)"
240 ### the URL to the RPMS/<arch> location
241 # f12 now has everything in i686; try i386 first as older fedoras have both
243 for a in i386 i686 x86_64; do
244 archdir=/vservers/$BASE/build/RPMS/$a
245 if [ -d $archdir ] ; then
246 # where was that installed
247 url=$(echo $archdir | sed -e "s,/vservers/${BASE}/build,${WEBPATH}/${BASE},")
248 url=$(echo $url | sed -e "s,${WEBROOT},${TESTBUILDURL},")
253 if [ -z "$url" ] ; then
254 echo "$COMMAND: Cannot locate arch URL for testing"
259 testmaster_ssh="root@${TESTMASTER}"
261 # test directory name on test box
265 ssh -n ${testmaster_ssh} rm -rf ${testdir} ${testdir}.git
267 # check it out in the build
268 vserver $BASE exec make -C /build tests-module
270 # push it onto the testmaster - just the 'system' subdir is enough
271 rsync --verbose --archive /vservers/$BASE/build/MODULES/tests/system/ ${testmaster_ssh}:${BASE}
272 # toss the build in the bargain, so the tests don't need to mess with extracting it
273 rsync --verbose --archive /vservers/$BASE/build/MODULES/build ${testmaster_ssh}:${BASE}/
275 # invoke test on testbox - pass url and build url - so the tests can use vtest-init-vserver.sh
277 for config in ${TESTCONFIG} ; do
278 configs="$configs --config $config"
280 test_env="-p $PERSONALITY -d $PLDISTRO -f $FCDISTRO"
282 # need to proceed despite of set -e
284 # passing the build_scm_url should not be needed anymore
285 ssh 2>&1 -n ${testmaster_ssh} ${testdir}/run_log --build ${BUILD_SCM_URL} --url ${url} $configs $test_env $VERBOSE --all || success=
287 # gather logs in the build vserver
288 mkdir -p /vservers/$BASE/build/testlogs
289 rsync --verbose --archive ${testmaster_ssh}:$BASE/logs/ /vservers/$BASE/build/testlogs
290 # push them to the build web
291 chmod -R a+r /vservers/$BASE/build/testlogs/
292 webpublish_rsync_dir /vservers/$BASE/build/testlogs/ $WEBPATH/$BASE/testlogs/
294 echo "============================== END $COMMAND:run_log on $(date)"
296 if [ -z "$success" ] ; then
297 echo "Tests have failed - bailing out"
303 function in_root_context () {
304 rpm -q util-vserver > /dev/null
307 # this part won't work if WEBHOST does not match the local host
308 # would need to be made webpublish_* compliant
309 # but do we really need this feature anyway ?
310 function sign_node_packages () {
312 echo "Signing node packages"
316 repository=$WEBPATH/$BASE/RPMS/
317 # the rpms that need signing
319 # and the corresponding stamps
322 for package in $(find $repository/ -name '*.rpm') ; do
323 stamp=$repository/signed-stamps/$(basename $package).signed
324 # If package is newer than signature stamp
325 if [ $package -nt $stamp ] ; then
326 new_rpms="$new_rpms $package"
327 new_stamps="$new_stamps $stamp"
329 # Or than createrepo database
330 [ $package -nt $repository/repodata/repomd.xml ] && need_createrepo=true
333 if [ -n "$new_rpms" ] ; then
334 # Create a stamp once the package gets signed
335 mkdir $repository/signed-stamps 2> /dev/null
337 # Sign RPMS. setsid detaches rpm from the terminal,
338 # allowing the (hopefully blank) GPG password to be
339 # entered from stdin instead of /dev/tty.
341 --define "_signature gpg" \
342 --define "_gpg_path $GPGPATH" \
343 --define "_gpg_name $GPGUID" \
344 --resign $new_rpms && touch $new_stamps
347 # Update repository index / yum metadata.
348 if [ -n "$need_createrepo" ] ; then
349 echo "Indexing node packages after signing"
350 if [ -f $repository/yumgroups.xml ] ; then
351 createrepo --quiet -g yumgroups.xml $repository
353 createrepo --quiet $repository
358 function show_env () {
360 echo FCDISTRO=$FCDISTRO
361 echo PLDISTRO=$PLDISTRO
362 echo PERSONALITY=$PERSONALITY
364 echo BUILD_SCM_URL=$BUILD_SCM_URL
365 echo MAKEVARS="${MAKEVARS[@]}"
366 echo DRY_RUN="$DRY_RUN"
367 echo PLDISTROTAGS="$PLDISTROTAGS"
368 # this does not help, it's not yet set when we run show_env
369 #echo WEBPATH="$WEBPATH"
370 echo TESTBUILDURL="$TESTBUILDURL"
371 echo WEBHOST="$WEBHOST"
372 if in_root_context ; then
373 echo PLDISTROTAGS="$PLDISTROTAGS"
375 if [ -f /build/$PLDISTROTAGS ] ; then
376 echo "XXXXXXXXXXXXXXXXXXXX Contents of tags definition file /build/$PLDISTROTAGS"
377 cat /build/$PLDISTROTAGS
378 echo "XXXXXXXXXXXXXXXXXXXX end tags definition"
380 echo "XXXXXXXXXXXXXXXXXXXX Cannot find tags definition file /build/$PLDISTROTAGS, assuming remote pldistro"
386 function setupssh () {
390 if [ -f ${sshkey} ] ; then
391 SSHDIR=/vservers/${base}/root/.ssh
393 cp $sshkey ${SSHDIR}/thekey
395 echo " IdentityFile ~/.ssh/thekey"; \
396 echo " StrictHostKeyChecking no" ) > ${SSHDIR}/config
398 chmod 400 ${SSHDIR}/*
400 echo "WARNING : could not find provided ssh key $sshkey - ignored"
405 echo "Usage: $COMMAND [option] [var=value...] make-targets"
406 echo "This is $REVISION"
407 echo "Supported options"
408 echo " -f fcdistro - defaults to $DEFAULT_FCDISTRO"
409 echo " -d pldistro - defaults to $DEFAULT_PLDISTRO"
410 echo " -p personality - defaults to $DEFAULT_PERSONALITY"
411 echo " -m mailto - no default"
412 echo " -s build_scm_url - git or svn URL where to fetch the build module - defaults to $DEFAULT_BUILD_SCM_URL"
413 echo " define GIT tag or branch name appending @tagname to url"
414 echo " -t pldistrotags - defaults to \${PLDISTRO}-tags.mk"
415 echo " -b base - defaults to $DEFAULT_BASE"
416 echo " @NAME@ replaced as appropriate"
417 echo " -o base: (overwrite) do not re-create vserver, re-use base instead"
418 echo " the -f/-d/-p/-m/-s/-t options are uneffective in this case"
419 echo " -c testconfig - defaults to $DEFAULT_TESTCONFIG"
420 echo " -w webpath - defaults to $DEFAULT_WEBPATH"
421 echo " -W testbuildurl - defaults to $DEFAULT_TESTBUILDURL; this is also used to get the hostname where to publish builds"
422 echo " -r webroot - defaults to $DEFAULT_WEBROOT - the fs point where testbuildurl actually sits"
423 echo " -M testmaster - defaults to $DEFAULT_TESTMASTER"
424 echo " -y - sign yum repo in webpath"
425 echo " -g gpg_path - to the gpg secring used to sign rpms. Defaults to $DEFAULT_GPGPATH"
426 echo " -u gpg_uid - email used in secring. Defaults to $DEFAULT_GPGUID"
427 echo " -K svnsshkey - specify key to use when svn+ssh:// URLs are used for SVNPATH"
428 echo " -S - do not publish source rpms"
429 echo " -B - run build only"
430 echo " -T - run test only"
431 echo " -n - dry-run: -n passed to make - vserver gets created though - no mail sent"
432 echo " -v - be verbose"
433 echo " -7 - uses weekday-@FCDISTRO@ as base"
434 echo " -i ifname - defaults to $DEFAULT_IFNAME - used to determine local IP"
435 echo " --build-branch branch - build using the branch from build module"
454 OPTS=$(getopt -o "f:d:p:m:s:t:b:o:c:w:W:r:M:yg:u:K:SBTnv7i:h" -l "build-branch:" -- $@)
462 -f) FCDISTRO=$2; shift 2 ;;
463 -d) PLDISTRO=$2; shift 2 ;;
464 -p) PERSONALITY=$2; shift 2 ;;
465 -m) MAILTO=$2; shift 2 ;;
466 -s) BUILD_SCM_URL=$2; shift 2 ;;
467 -t) PLDISTROTAGS=$2; shift 2 ;;
468 -b) BASE=$2; shift 2 ;;
469 -o) OVERBASE=$2; shift 2 ;;
470 -c) TESTCONFIG="$TESTCONFIG $2"; shift 2 ;;
471 -w) WEBPATH=$2; shift 2 ;;
472 -W) TESTBUILDURL=$2; shift 2 ;;
473 -r) WEBROOT=$2; shift 2 ;;
474 -M) TESTMASTER=$2; shift 2 ;;
475 -y) SIGNYUMREPO=true; shift ;;
476 -g) GPGPATH=$2; shift 2 ;;
477 -u) GPGUID=$2; shift 2 ;;
478 -K) SSH_KEY=$2; shift 2 ;;
479 -S) PUBLISH_SRPMS="" ; shift ;;
480 -B) DO_TEST= ; shift ;;
481 -T) DO_BUILD= ; shift;;
482 -n) DRY_RUN="-n" ; shift ;;
483 -v) set -x ; VERBOSE="-v" ; shift ;;
484 -7) BASE="$(date +%a|tr A-Z a-z)-@FCDISTRO@" ; shift ;;
485 -i) IFNAME=$2; shift 2 ;;
491 # preserve options for passing them again later, together with expanded base
494 # allow var=value stuff;
495 for target in "$@" ; do
496 # check if contains '='
497 target1=$(echo $target | sed -e s,=,,)
498 if [ "$target" = "$target1" ] ; then
499 MAKETARGETS=(${MAKETARGETS[@]} "$target")
501 MAKEVARS=(${MAKEVARS[@]} "$target")
506 [ -z "$FCDISTRO" ] && FCDISTRO=$DEFAULT_FCDISTRO
507 [ -z "$PLDISTRO" ] && PLDISTRO=$DEFAULT_PLDISTRO
508 [ -z "$PERSONALITY" ] && PERSONALITY=$DEFAULT_PERSONALITY
509 [ -z "$PLDISTROTAGS" ] && PLDISTROTAGS="${PLDISTRO}-tags.mk"
510 [ -z "$BASE" ] && BASE="$DEFAULT_BASE"
511 [ -z "$WEBPATH" ] && WEBPATH="$DEFAULT_WEBPATH"
512 [ -z "$TESTBUILDURL" ] && TESTBUILDURL="$DEFAULT_TESTBUILDURL"
513 [ -z "$WEBROOT" ] && WEBROOT="$DEFAULT_WEBROOT"
514 [ -z "$GPGPATH" ] && GPGPATH="$DEFAULT_GPGPATH"
515 [ -z "$GPGUID" ] && GPGUID="$DEFAULT_GPGUID"
516 [ -z "$IFNAME" ] && IFNAME="$DEFAULT_IFNAME"
517 [ -z "$BUILD_SCM_URL" ] && BUILD_SCM_URL="$DEFAULT_BUILD_SCM_URL"
518 [ -z "$TESTCONFIG" ] && TESTCONFIG="$DEFAULT_TESTCONFIG"
519 [ -z "$TESTMASTER" ] && TESTMASTER="$DEFAULT_TESTMASTER"
521 [ -n "$DRY_RUN" ] && MAILTO=""
523 if [ -n "$OVERBASE" ] ; then
524 sedargs="-e s,@DATE@,${DATE},g"
525 BASE=$(echo ${OVERBASE} | sed $sedargs)
527 sedargs="-e s,@DATE@,${DATE},g -e s,@FCDISTRO@,${FCDISTRO},g -e s,@PLDISTRO@,${PLDISTRO},g -e s,@PERSONALITY@,${PERSONALITY},g"
528 BASE=$(echo ${BASE} | sed $sedargs)
531 ### elaborate mail subject
532 if [ -n "$DO_BUILD" -a -n "$DO_TEST" ] ; then
533 MAIL_SUBJECT="complete"
534 elif [ -n "$DO_BUILD" ] ; then
535 MAIL_SUBJECT="package-only"
536 elif [ -n "$DO_TEST" ] ; then
537 MAIL_SUBJECT="test-only"
539 if [ -n "$OVERBASE" ] ; then
540 MAIL_SUBJECT="$MAIL_SUBJECT incremental run on"
542 MAIL_SUBJECT="$MAIL_SUBJECT fresh build"
545 ### compute WEBHOST from TESTBUILDURL
546 # this is to avoid having to change the builds configs everywhere
547 # simplistic way to extract hostname from a URL
548 WEBHOST=$(echo "$TESTBUILDURL" | cut -d/ -f 3)
550 if ! in_root_context ; then
552 echo "==================== Within vserver BEG $(date)"
554 echo "==================== Within vserver END $(date)"
558 # we run in the root context :
559 # (*) create or check for the vserver to use
560 # (*) copy this command in the vserver
563 if [ -n "$OVERBASE" ] ; then
564 ### Re-use a vserver (finish an unfinished build..)
565 if [ ! -d /vservers/${BASE} ] ; then
566 echo $COMMAND : cannot find vserver $BASE
569 # manage LOG - beware it might be a symlink so nuke it first
570 LOG=/vservers/${BASE}.log.txt
574 echo "XXXXXXXXXX $COMMAND: using existing vserver $BASE" $(date)
575 # start in case e.g. we just rebooted
576 vserver ${BASE} start || :
577 # retrieve environment from the previous run
578 FCDISTRO=$(vserver ${BASE} exec /build/getdistroname.sh)
579 BUILD_SCM_URL=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +build-SVNPATH +build-GITPATH)
580 # for efficiency, crop everything in one make run
581 tmp=/tmp/${BASE}-env.sh
582 vserver ${BASE} exec make --no-print-directory -C /build stage1=skip \
583 ++PLDISTRO ++PLDISTROTAGS ++PERSONALITY ++MAILTO ++WEBPATH ++TESTBUILDURL ++WEBROOT > $tmp
587 [ -n "$SSH_KEY" ] && setupssh ${BASE} ${SSH_KEY}
588 if echo $BUILD_SCM_URL | grep -q git ; then
589 vserver $BASE exec bash -c "cd /build; git pull; make tests-clean"
591 vserver $BASE exec svn update /build
593 # make sure we refresh the tests place in case it has changed
594 rm -f /build/MODULES/tests
595 options=(${options[@]} -d $PLDISTRO -t $PLDISTROTAGS -s $BUILD_SCM_URL)
596 [ -n "$PERSONALITY" ] && options=(${options[@]} -p $PERSONALITY)
597 [ -n "$MAILTO" ] && options=(${options[@]} -m $MAILTO)
598 [ -n "$WEBPATH" ] && options=(${options[@]} -w $WEBPATH)
599 [ -n "$TESTBUILDURL" ] && options=(${options[@]} -W $TESTBUILDURL)
600 [ -n "$WEBROOT" ] && options=(${options[@]} -r $WEBROOT)
603 # create vserver: check it does not exist yet
605 while [ -d /vservers/${BASE}${i} ] ; do
606 # we name subsequent builds <base>-n<i> so the logs and builds get sorted properly
607 [ -z ${i} ] && BASE=${BASE}-n
609 if [ $i -gt 100 ] ; then
610 echo "$COMMAND: Failed to create build vserver /vservers/${BASE}${i}"
616 # manage LOG - beware it might be a symlink so nuke it first
617 LOG=/vservers/${BASE}.log.txt
621 echo "XXXXXXXXXX $COMMAND: creating vserver $BASE" $(date)
624 ### extract the whole build - much simpler
625 tmpdir=/tmp/$COMMAND-$$
626 if echo $BUILD_SCM_URL | grep -q git ; then
627 GIT_REPO=$(echo $BUILD_SCM_URL | cut -d@ -f1)
628 GIT_TAG=$(echo $BUILD_SCM_URL | cut -s -d@ -f2)
629 GIT_TAG=${GIT_TAG:-master}
630 mkdir -p $tmpdir; git archive --remote=$GIT_REPO $GIT_TAG | tar -C $tmpdir -xf -
632 svn export $BUILD_SCM_URL $tmpdir
636 ./vbuild-init-vserver.sh $VERBOSE -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} -i ${IFNAME} ${BASE}
640 # Extract build again - in the vserver
641 [ -n "$SSH_KEY" ] && setupssh ${BASE} ${SSH_KEY}
642 if echo $BUILD_SCM_URL | grep -q git ; then
643 vserver $BASE exec bash -c "git clone $GIT_REPO /build; cd /build; git checkout $GIT_TAG"
645 vserver $BASE exec svn checkout ${BUILD_SCM_URL} /build
648 # install ssh key in vserver
649 echo "XXXXXXXXXX $COMMAND: preparation of vserver $BASE done" $(date)
651 # The log inside the vserver contains everything
652 LOG2=/vservers/${BASE}/log.txt
653 (echo "==================== BEG VSERVER Transcript of vserver creation" ; \
655 echo "==================== END VSERVER Transcript of vserver creation" ; \
656 echo "xxxxxxxxxx Messing with logs, symlinking $LOG2 to $LOG" ) >> $LOG2
657 ### not too nice : nuke the former log, symlink it to the new one
658 rm $LOG; ln -s $LOG2 $LOG
663 sedargs="-e s,@DATE@,${DATE},g -e s,@FCDISTRO@,${FCDISTRO},g -e s,@PLDISTRO@,${PLDISTRO},g -e s,@PERSONALITY@,${PERSONALITY},g"
664 WEBPATH=$(echo ${WEBPATH} | sed $sedargs)
665 webpublish mkdir -p ${WEBPATH}
667 # where to store the log for web access
668 WEBBASE=${WEBPATH}/${BASE}
669 WEBLOG=${WEBPATH}/${BASE}/log.txt
670 # compute the log URL - inserted in the mail messages for convenience
671 WEBBASE_URL=$(echo $WEBBASE | sed -e "s,//,/,g" -e "s,${WEBROOT},${TESTBUILDURL},")
673 if [ -n "$DO_BUILD" ] ; then
675 # invoke this command into the build directory of the vserver
676 cp $COMMANDPATH /vservers/${BASE}/build/
678 # invoke this command in the vserver for building (-T)
679 vserver ${BASE} exec chmod +x /build/$COMMAND
680 vserver ${BASE} exec /build/$COMMAND "${options[@]}" -b "${BASE}" "${MAKEVARS[@]}" "${MAKETARGETS[@]}"
683 # publish to the web so run_log can find them
685 webpublish rm -rf $WEBPATH/$BASE
686 webpublish mkdir -p $WEBPATH/$BASE/{RPMS,SRPMS}
687 webpublish_rsync_dir /vservers/$BASE/build/RPMS/ $WEBPATH/$BASE/RPMS/
688 [[ -n "$PUBLISH_SRPMS" ]] && webpublish_rsync_dir /vservers/$BASE/build/SRPMS/ $WEBPATH/$BASE/SRPMS/
689 # publish myplc-release if this exists
690 release=/vservers/$BASE/build/myplc-release
691 [ -f $release ] && webpublish_rsync_file $release $WEBPATH/$BASE
694 # create yum repo and sign packages.
695 if [ -n "$SIGNYUMREPO" ] ; then
696 # this script does not yet support signing on a remote (webhost) repo
697 sign_here=$(hostname) ; sign_web=$(webpublish hostname)
698 if [ "$hostname" = "$sign_here" ] ; then
701 echo "$COMMAND does not support signing on a remote yum repo"
702 echo "you might want to turn off the -y option, or run this on the web server box itself"
707 if [ -n "$DO_TEST" ] ; then
713 echo "==================== MAIN END $(date)"