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"
14 DEFAULT_BUILD_BRANCH="master"
16 # default gpg path used in signing yum repo
17 DEFAULT_GPGPATH="/etc/planetlab"
18 # default email to use in gpg secring
19 DEFAULT_GPGUID="root@$( /bin/hostname )"
21 DEFAULT_TESTCONFIG="default"
23 # for publishing results, and the tests settings
25 y=$(hostname|sed -e s,inria,,)
27 if [ "$x" != "$y" ] ; then
28 DEFAULT_WEBPATH="/build/@PLDISTRO@/"
29 DEFAULT_TESTBUILDURL="http://build.onelab.eu/"
30 # this is where the buildurl is pointing towards
31 DEFAULT_WEBROOT="/build/"
32 DEFAULT_TESTMASTER="testmaster.onelab.eu"
34 DEFAULT_WEBPATH="/build/@FCDISTRO@/@PLDISTRO@/"
35 DEFAULT_TESTBUILDURL="http://build.planet-lab.org/"
36 # this is where the buildurl is pointing towards
37 DEFAULT_WEBROOT="/build/"
38 DEFAULT_TESTMASTER="manager.test.planet-lab.org"
42 # assuming vserver runs in UTC
43 DATE=$(date +'%Y.%m.%d')
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
50 echo "******************** BEG SUMMARY"
53 # read a full log and tries to extract the interesting stuff
56 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).*")
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(.*)")
63 def summary (filename):
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()
77 if m_installing_doc2.match(line):
78 (begin,end)=m_installing_doc2.match(line).groups()
80 # unconditionnally show these lines
81 if m_show_line.match(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
89 # closing an 'installing' section
90 elif m_installing_end.match(line):
92 # any 'installing' line
93 elif m_installing_any.match(line):
95 installing=m_installing_any.match(line).group(1)
96 print '>>>',installing
98 # print lines when echo is true
100 if echo: print '>>>',line,
103 print 'Failed to analyze',filename
105 for arg in sys.argv[1:]:
108 echo "******************** END SUMMARY"
111 ### we might build on a box other than the actual web server
112 # utilities for handling the pushed material (rpms, logfiles, ...)
113 function webpublish_misses_dir () { ssh root@${WEBHOST} "bash -c \"test \! -d $1\"" ; }
114 function webpublish () { ssh root@${WEBHOST} "$@" ; }
115 function webpublish_rsync_dir () { rsync --archive --delete $VERBOSE $1 root@${WEBHOST}:$2 ; }
116 function webpublish_rsync_file () { rsync $VERBOSE $1 root@${WEBHOST}:$2 ; }
117 function webpublish_cp_local_to_remote () { scp $1 root@${WEBHOST}:$2 ; }
118 function webpublish_cp_stdin_to_file () { ssh root@${WEBHOST} cat \> $1; }
119 function webpublish_append_stdin_to_file () { ssh root@${WEBHOST} cat \>\> $1; }
121 # Notify recipient of failure or success, manage various stamps
124 # early stage ? - let's not create /build/@PLDISTRO@
125 if test -z "$WEBLOG" ; then
128 WEBBASE=/tmp/vbuild-early-$(date +%Y-%m-%d)
129 WEBLOG=/tmp/vbuild-early-$(date +%Y-%m-%d).log.txt
131 webpublish mkdir -p $WEBBASE ||:
132 webpublish_cp_local_to_remote $LOG $WEBLOG ||:
133 summary $LOG | webpublish_append_stdin_to_file $WEBLOG ||:
134 (echo -n "============================== $COMMAND: failure at " ; date ; \
135 webpublish tail --lines=1000 $WEBLOG) | \
136 webpublish_cp_stdin_to_file $WEBBASE.ko ||:
137 if [ -n "$MAILTO" ] ; then
139 echo "Subject: Failures with $MAIL_SUBJECT $BASE on $(hostname)" ; \
140 echo "To: $MAILTO" ; \
141 echo "See full build log at $WEBBASE_URL/log.txt" ; \
142 echo "and tail version at $WEBBASE_URL.ko" ; \
143 echo "See complete set of testlogs at $WEBBASE_URL/testlogs" ; \
144 echo "........................................" ; \
145 webpublish tail --lines=1000 $WEBLOG ) | \
151 function success () {
153 # early stage ? - let's not create /build/@PLDISTRO@
154 if test -z "$WEBLOG" ; then
157 WEBLOG=/tmp/vbuild-early-$(date +%Y-%m-%d).log.txt
159 webpublish mkdir -p $WEBBASE
160 webpublish_cp_local_to_remote $LOG $WEBLOG
161 summary $LOG | webpublish_append_stdin_to_file $WEBLOG
162 if [ -n "$DO_TEST" ] ; then
164 echo "Successfully built and tested" ; \
165 echo "See full build log at $WEBBASE_URL/log.txt" ; \
166 echo "See complete set of testlogs at $WEBBASE_URL/testlogs" ; \
167 ) | webpublish_cp_stdin_to_file $WEBBASE.pass
168 webpublish rm -f $WEBBASE.pkg-ok $WEBBASE.ko
171 echo "Successful package-only build, no test requested" ; \
172 echo "See full build log at $WEBBASE_URL/log.txt" ; \
173 ) | webpublish_cp_stdin_to_file $WEBBASE.pkg-ok
174 webpublish rm -f $WEBBASE.ko
176 if [ -n "$MAILTO" ] ; then
178 echo "Subject: Success with ${MAIL_SUBJECT} ${BASE} on $(hostname)" ; \
179 echo "To: $MAILTO" ; \
180 echo "$PLDISTRO ($BASE) build for $FCDISTRO completed on $(date)" ; \
181 echo "See full build log at $WEBBASE_URL/log.txt" ; \
182 [ -n "$DO_TEST" ] && echo "See complete set of testlogs at $WEBBASE_URL/testlogs" ) \
185 # XXX For some reason, we haven't been getting this email for successful builds. If this sleep
186 # doesn't fix the problem, I'll remove it -- Sapan.
191 # run in the vserver - do not manage success/failure, will be done from the root ctx
196 echo -n "============================== Starting $COMMAND:build on "
202 echo "Running make IN $(pwd)"
204 # stuff our own variable settings
205 if echo $BUILD_SCM_URL | grep -q git ; then
206 MAKEVARS=("build-GITPATH=${BUILD_SCM_URL}" "${MAKEVARS[@]}")
208 MAKEVARS=("build-SVNPATH=${BUILD_SCM_URL}" "${MAKEVARS[@]}")
210 MAKEVARS=("PLDISTRO=${PLDISTRO}" "${MAKEVARS[@]}")
211 MAKEVARS=("PLDISTROTAGS=${PLDISTROTAGS}" "${MAKEVARS[@]}")
212 MAKEVARS=("PERSONALITY=${PERSONALITY}" "${MAKEVARS[@]}")
213 MAKEVARS=("MAILTO=${MAILTO}" "${MAKEVARS[@]}")
214 MAKEVARS=("WEBPATH=${WEBPATH}" "${MAKEVARS[@]}")
215 MAKEVARS=("TESTBUILDURL=${TESTBUILDURL}" "${MAKEVARS[@]}")
216 MAKEVARS=("WEBROOT=${WEBROOT}" "${MAKEVARS[@]}")
218 MAKEVARS=("BASE=${BASE}" "${MAKEVARS[@]}")
221 make -C /build $DRY_RUN "${MAKEVARS[@]}" stage1=true
223 make -C /build $DRY_RUN "${MAKEVARS[@]}" versions
225 make -C /build $DRY_RUN "${MAKEVARS[@]}" "${MAKETARGETS[@]}"
229 # this was formerly run in the myplc-devel chroot but now is run in the root context,
230 # this is so that the .ssh config gets done manually, and once and for all
231 function run_log () {
236 echo "============================== BEG $COMMAND:run_log on $(date)"
238 ### the URL to the RPMS/<arch> location
239 # f12 now has everything in i686; try i386 first as older fedoras have both
241 for a in i386 i686 x86_64; do
242 archdir=/vservers/$BASE/build/RPMS/$a
243 if [ -d $archdir ] ; then
244 # where was that installed
245 url=$(echo $archdir | sed -e "s,/vservers/${BASE}/build,${WEBPATH}/${BASE},")
246 url=$(echo $url | sed -e "s,${WEBROOT},${TESTBUILDURL},")
251 if [ -z "$url" ] ; then
252 echo "$COMMAND: Cannot locate arch URL for testing"
257 testmaster_ssh="root@${TESTMASTER}"
259 # test directory name on test box
263 ssh -n ${testmaster_ssh} rm -rf ${testdir} ${testdir}.git
265 # check it out in the build
266 vserver $BASE exec make -C /build tests-module
268 # push it onto the testmaster - just the 'system' subdir is enough
269 rsync --verbose --archive /vservers/$BASE/build/MODULES/tests/system/ ${testmaster_ssh}:${BASE}
270 # toss the build in the bargain, so the tests don't need to mess with extracting it
271 rsync --verbose --archive /vservers/$BASE/build/MODULES/build ${testmaster_ssh}:${BASE}/
273 # invoke test on testbox - pass url and build url - so the tests can use vtest-init-vserver.sh
275 for config in ${TESTCONFIG} ; do
276 configs="$configs --config $config"
278 test_env="-p $PERSONALITY -d $PLDISTRO -f $FCDISTRO"
280 # need to proceed despite of set -e
282 # passing the build_scm_url should not be needed anymore
283 ssh 2>&1 -n ${testmaster_ssh} ${testdir}/run_log --build ${BUILD_SCM_URL} --url ${url} $configs $test_env $VERBOSE --all || success=
285 # gather logs in the build vserver
286 mkdir -p /vservers/$BASE/build/testlogs
287 rsync --verbose --archive ${testmaster_ssh}:$BASE/logs/ /vservers/$BASE/build/testlogs
288 # push them to the build web
289 chmod -R a+r /vservers/$BASE/build/testlogs/
290 webpublish_rsync_dir /vservers/$BASE/build/testlogs/ $WEBPATH/$BASE/testlogs/
292 echo "============================== END $COMMAND:run_log on $(date)"
294 if [ -z "$success" ] ; then
295 echo "Tests have failed - bailing out"
301 function in_root_context () {
302 rpm -q util-vserver > /dev/null
305 # this part won't work if WEBHOST does not match the local host
306 # would need to be made webpublish_* compliant
307 # but do we really need this feature anyway ?
308 function sign_node_packages () {
310 echo "Signing node packages"
314 repository=$WEBPATH/$BASE/RPMS/
315 # the rpms that need signing
317 # and the corresponding stamps
320 for package in $(find $repository/ -name '*.rpm') ; do
321 stamp=$repository/signed-stamps/$(basename $package).signed
322 # If package is newer than signature stamp
323 if [ $package -nt $stamp ] ; then
324 new_rpms="$new_rpms $package"
325 new_stamps="$new_stamps $stamp"
327 # Or than createrepo database
328 [ $package -nt $repository/repodata/repomd.xml ] && need_createrepo=true
331 if [ -n "$new_rpms" ] ; then
332 # Create a stamp once the package gets signed
333 mkdir $repository/signed-stamps 2> /dev/null
335 # Sign RPMS. setsid detaches rpm from the terminal,
336 # allowing the (hopefully blank) GPG password to be
337 # entered from stdin instead of /dev/tty.
339 --define "_signature gpg" \
340 --define "_gpg_path $GPGPATH" \
341 --define "_gpg_name $GPGUID" \
342 --resign $new_rpms && touch $new_stamps
345 # Update repository index / yum metadata.
346 if [ -n "$need_createrepo" ] ; then
347 echo "Indexing node packages after signing"
348 if [ -f $repository/yumgroups.xml ] ; then
349 createrepo --quiet -g yumgroups.xml $repository
351 createrepo --quiet $repository
356 function show_env () {
358 echo FCDISTRO=$FCDISTRO
359 echo PLDISTRO=$PLDISTRO
360 echo PERSONALITY=$PERSONALITY
362 echo BUILD_SCM_URL=$BUILD_SCM_URL
363 echo BUILD_BRANCH=$BUILD_BRANCH
364 echo MAKEVARS="${MAKEVARS[@]}"
365 echo DRY_RUN="$DRY_RUN"
366 echo PLDISTROTAGS="$PLDISTROTAGS"
367 # this does not help, it's not yet set when we run show_env
368 #echo WEBPATH="$WEBPATH"
369 echo TESTBUILDURL="$TESTBUILDURL"
370 echo WEBHOST="$WEBHOST"
371 if in_root_context ; then
372 echo PLDISTROTAGS="$PLDISTROTAGS"
374 if [ -f /build/$PLDISTROTAGS ] ; then
375 echo "XXXXXXXXXXXXXXXXXXXX Contents of tags definition file /build/$PLDISTROTAGS"
376 cat /build/$PLDISTROTAGS
377 echo "XXXXXXXXXXXXXXXXXXXX end tags definition"
379 echo "XXXXXXXXXXXXXXXXXXXX Cannot find tags definition file /build/$PLDISTROTAGS, assuming remote pldistro"
385 function setupssh () {
389 if [ -f ${sshkey} ] ; then
390 SSHDIR=/vservers/${base}/root/.ssh
392 cp $sshkey ${SSHDIR}/thekey
394 echo " IdentityFile ~/.ssh/thekey"; \
395 echo " StrictHostKeyChecking no" ) > ${SSHDIR}/config
397 chmod 400 ${SSHDIR}/*
399 echo "WARNING : could not find provided ssh key $sshkey - ignored"
404 echo "Usage: $COMMAND [option] [var=value...] make-targets"
405 echo "This is $REVISION"
406 echo "Supported options"
407 echo " -f fcdistro - defaults to $DEFAULT_FCDISTRO"
408 echo " -d pldistro - defaults to $DEFAULT_PLDISTRO"
409 echo " -p personality - defaults to $DEFAULT_PERSONALITY"
410 echo " -m mailto - no default"
411 echo " -s build_scm_url - git or svn URL where to fetch the build module - defaults to $DEFAULT_BUILD_SCM_URL"
412 echo " -t pldistrotags - defaults to \${PLDISTRO}-tags.mk"
413 echo " -b base - defaults to $DEFAULT_BASE"
414 echo " @NAME@ replaced as appropriate"
415 echo " -o base: (overwrite) do not re-create vserver, re-use base instead"
416 echo " the -f/-d/-p/-m/-s/-t options are uneffective in this case"
417 echo " -c testconfig - defaults to $DEFAULT_TESTCONFIG"
418 echo " -w webpath - defaults to $DEFAULT_WEBPATH"
419 echo " -W testbuildurl - defaults to $DEFAULT_TESTBUILDURL; this is also used to get the hostname where to publish builds"
420 echo " -r webroot - defaults to $DEFAULT_WEBROOT - the fs point where testbuildurl actually sits"
421 echo " -M testmaster - defaults to $DEFAULT_TESTMASTER"
422 echo " -y - sign yum repo in webpath"
423 echo " -g gpg_path - to the gpg secring used to sign rpms. Defaults to $DEFAULT_GPGPATH"
424 echo " -u gpg_uid - email used in secring. Defaults to $DEFAULT_GPGUID"
425 echo " -K svnsshkey - specify key to use when svn+ssh:// URLs are used for SVNPATH"
426 echo " -S - do not publish source rpms"
427 echo " -B - run build only"
428 echo " -T - run test only"
429 echo " -n - dry-run: -n passed to make - vserver gets created though - no mail sent"
430 echo " -v - be verbose"
431 echo " -7 - uses weekday-@FCDISTRO@ as base"
432 echo " -i ifname - defaults to $DEFAULT_IFNAME - used to determine local IP"
433 echo " --build-branch branch - build using the branch from build module"
452 OPTS=$(getopt -o "f:d:p:m:s:t:b:o:c:w:W:r:M:yg:u:K:SBTnv7i:h" -l "build-branch:" -- $@)
460 -f) FCDISTRO=$2; shift 2 ;;
461 -d) PLDISTRO=$2; shift 2 ;;
462 -p) PERSONALITY=$2; shift 2 ;;
463 -m) MAILTO=$2; shift 2 ;;
464 -s) BUILD_SCM_URL=$2; shift 2 ;;
465 -t) PLDISTROTAGS=$2; shift 2 ;;
466 -b) BASE=$2; shift 2 ;;
467 -o) OVERBASE=$2; shift 2 ;;
468 -c) TESTCONFIG="$TESTCONFIG $2"; shift 2 ;;
469 -w) WEBPATH=$2; shift 2 ;;
470 -W) TESTBUILDURL=$2; shift 2 ;;
471 -r) WEBROOT=$2; shift 2 ;;
472 -M) TESTMASTER=$2; shift 2 ;;
473 -y) SIGNYUMREPO=true; shift ;;
474 -g) GPGPATH=$2; shift 2 ;;
475 -u) GPGUID=$2; shift 2 ;;
476 -K) SSH_KEY=$2; shift 2 ;;
477 -S) PUBLISH_SRPMS="" ; shift ;;
478 -B) DO_TEST= ; shift ;;
479 -T) DO_BUILD= ; shift;;
480 -n) DRY_RUN="-n" ; shift ;;
481 -v) set -x ; VERBOSE="-v" ; shift ;;
482 -7) BASE="$(date +%a|tr A-Z a-z)-@FCDISTRO@" ; shift ;;
483 -i) IFNAME=$2; shift 2 ;;
485 --build-branch) BUILD_BRANCH=$2; shift 2 ;;
490 eval set -- "$OPTS_ORIG"
493 # preserve options for passing them again later, together with expanded base
495 toshift=$(($OPTIND - 1))
496 arg=1; while [ $arg -le $toshift ] ; do options=(${options[@]} "$1") ; shift; arg=$(($arg+1)) ; done
498 # allow var=value stuff;
499 for target in "$@" ; do
500 # check if contains '='
501 target1=$(echo $target | sed -e s,=,,)
502 if [ "$target" = "$target1" ] ; then
503 MAKETARGETS=(${MAKETARGETS[@]} "$target")
505 MAKEVARS=(${MAKEVARS[@]} "$target")
510 [ -z "$FCDISTRO" ] && FCDISTRO=$DEFAULT_FCDISTRO
511 [ -z "$PLDISTRO" ] && PLDISTRO=$DEFAULT_PLDISTRO
512 [ -z "$PERSONALITY" ] && PERSONALITY=$DEFAULT_PERSONALITY
513 [ -z "$PLDISTROTAGS" ] && PLDISTROTAGS="${PLDISTRO}-tags.mk"
514 [ -z "$BASE" ] && BASE="$DEFAULT_BASE"
515 [ -z "$WEBPATH" ] && WEBPATH="$DEFAULT_WEBPATH"
516 [ -z "$TESTBUILDURL" ] && TESTBUILDURL="$DEFAULT_TESTBUILDURL"
517 [ -z "$WEBROOT" ] && WEBROOT="$DEFAULT_WEBROOT"
518 [ -z "$GPGPATH" ] && GPGPATH="$DEFAULT_GPGPATH"
519 [ -z "$GPGUID" ] && GPGUID="$DEFAULT_GPGUID"
520 [ -z "$IFNAME" ] && IFNAME="$DEFAULT_IFNAME"
521 [ -z "$BUILD_SCM_URL" ] && BUILD_SCM_URL="$DEFAULT_BUILD_SCM_URL"
522 [ -z "$BUILD_BRANCH" ] && BUILD_BRANCH="$DEFAULT_BUILD_BRANCH"
523 [ -z "$TESTCONFIG" ] && TESTCONFIG="$DEFAULT_TESTCONFIG"
524 [ -z "$TESTMASTER" ] && TESTMASTER="$DEFAULT_TESTMASTER"
526 [ -n "$DRY_RUN" ] && MAILTO=""
528 if [ -n "$OVERBASE" ] ; then
529 sedargs="-e s,@DATE@,${DATE},g"
530 BASE=$(echo ${OVERBASE} | sed $sedargs)
532 sedargs="-e s,@DATE@,${DATE},g -e s,@FCDISTRO@,${FCDISTRO},g -e s,@PLDISTRO@,${PLDISTRO},g -e s,@PERSONALITY@,${PERSONALITY},g"
533 BASE=$(echo ${BASE} | sed $sedargs)
536 ### elaborate mail subject
537 if [ -n "$DO_BUILD" -a -n "$DO_TEST" ] ; then
538 MAIL_SUBJECT="complete"
539 elif [ -n "$DO_BUILD" ] ; then
540 MAIL_SUBJECT="package-only"
541 elif [ -n "$DO_TEST" ] ; then
542 MAIL_SUBJECT="test-only"
544 if [ -n "$OVERBASE" ] ; then
545 MAIL_SUBJECT="$MAIL_SUBJECT incremental run on"
547 MAIL_SUBJECT="$MAIL_SUBJECT fresh build"
550 ### compute WEBHOST from TESTBUILDURL
551 # this is to avoid having to change the builds configs everywhere
552 # simplistic way to extract hostname from a URL
553 WEBHOST=$(echo "$TESTBUILDURL" | cut -d/ -f 3)
555 if ! in_root_context ; then
557 echo "==================== Within vserver BEG $(date)"
559 echo "==================== Within vserver END $(date)"
563 # we run in the root context :
564 # (*) create or check for the vserver to use
565 # (*) copy this command in the vserver
568 if [ -n "$OVERBASE" ] ; then
569 ### Re-use a vserver (finish an unfinished build..)
570 if [ ! -d /vservers/${BASE} ] ; then
571 echo $COMMAND : cannot find vserver $BASE
574 # manage LOG - beware it might be a symlink so nuke it first
575 LOG=/vservers/${BASE}.log.txt
579 echo "XXXXXXXXXX $COMMAND: using existing vserver $BASE" $(date)
580 # start in case e.g. we just rebooted
581 vserver ${BASE} start || :
582 # retrieve environment from the previous run
583 FCDISTRO=$(vserver ${BASE} exec /build/getdistroname.sh)
584 BUILD_SCM_URL=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +build-SVNPATH +build-GITPATH)
585 # for efficiency, crop everything in one make run
586 tmp=/tmp/${BASE}-env.sh
587 vserver ${BASE} exec make --no-print-directory -C /build stage1=skip \
588 ++PLDISTRO ++PLDISTROTAGS ++PERSONALITY ++MAILTO ++WEBPATH ++TESTBUILDURL ++WEBROOT > $tmp
592 [ -n "$SSH_KEY" ] && setupssh ${BASE} ${SSH_KEY}
593 if echo $BUILD_SCM_URL | grep -q git ; then
594 vserver $BASE exec bash -c "cd /build; git pull; make tests-clean"
596 vserver $BASE exec svn update /build
598 # make sure we refresh the tests place in case it has changed
599 rm -f /build/MODULES/tests
600 options=(${options[@]} -d $PLDISTRO -t $PLDISTROTAGS -s $BUILD_SCM_URL)
601 [ -n "$PERSONALITY" ] && options=(${options[@]} -p $PERSONALITY)
602 [ -n "$MAILTO" ] && options=(${options[@]} -m $MAILTO)
603 [ -n "$WEBPATH" ] && options=(${options[@]} -w $WEBPATH)
604 [ -n "$TESTBUILDURL" ] && options=(${options[@]} -W $TESTBUILDURL)
605 [ -n "$WEBROOT" ] && options=(${options[@]} -r $WEBROOT)
608 # create vserver: check it does not exist yet
610 while [ -d /vservers/${BASE}${i} ] ; do
611 # we name subsequent builds <base>-n<i> so the logs and builds get sorted properly
612 [ -z ${i} ] && BASE=${BASE}-n
614 if [ $i -gt 100 ] ; then
615 echo "$COMMAND: Failed to create build vserver /vservers/${BASE}${i}"
621 # manage LOG - beware it might be a symlink so nuke it first
622 LOG=/vservers/${BASE}.log.txt
626 echo "XXXXXXXXXX $COMMAND: creating vserver $BASE" $(date)
629 ### extract the whole build - much simpler
630 tmpdir=/tmp/$COMMAND-$$
631 if echo $BUILD_SCM_URL | grep -q git ; then
632 GIT_REPO=$(echo $BUILD_SCM_URL | cut -d@ -f1)
633 GIT_TAG=$(echo $BUILD_SCM_URL | cut -s -d@ -f2)
634 GIT_TAG=${GIT_TAG:-master}
635 mkdir -p $tmpdir; git archive --remote=$GIT_REPO $GIT_TAG | tar -C $tmpdir -xf -
637 svn export $BUILD_SCM_URL $tmpdir
641 ./vbuild-init-vserver.sh $VERBOSE -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} -i ${IFNAME} ${BASE}
645 # Extract build again - in the vserver
646 [ -n "$SSH_KEY" ] && setupssh ${BASE} ${SSH_KEY}
647 if echo $BUILD_SCM_URL | grep -q git ; then
648 vserver $BASE exec bash -c "git clone --branch $BUILD_BRANCH $GIT_REPO /build; cd /build; git checkout $GIT_TAG"
650 if [ "x$BUILD_BRANCH" != "x$DEFAULT_BUILD_BRANCH" ]; then
651 vserver $BASE exec svn checkout ${BUILD_SCM_URL} /build
653 vserver $BASE exec svn checkout ${BUILD_SCM_URL}/branches/$BUILD_BRANCH /build
657 # install ssh key in vserver
658 echo "XXXXXXXXXX $COMMAND: preparation of vserver $BASE done" $(date)
660 # The log inside the vserver contains everything
661 LOG2=/vservers/${BASE}/log.txt
662 (echo "==================== BEG VSERVER Transcript of vserver creation" ; \
664 echo "==================== END VSERVER Transcript of vserver creation" ; \
665 echo "xxxxxxxxxx Messing with logs, symlinking $LOG2 to $LOG" ) >> $LOG2
666 ### not too nice : nuke the former log, symlink it to the new one
667 rm $LOG; ln -s $LOG2 $LOG
672 sedargs="-e s,@DATE@,${DATE},g -e s,@FCDISTRO@,${FCDISTRO},g -e s,@PLDISTRO@,${PLDISTRO},g -e s,@PERSONALITY@,${PERSONALITY},g"
673 WEBPATH=$(echo ${WEBPATH} | sed $sedargs)
674 webpublish mkdir -p ${WEBPATH}
676 # where to store the log for web access
677 WEBBASE=${WEBPATH}/${BASE}
678 WEBLOG=${WEBPATH}/${BASE}/log.txt
679 # compute the log URL - inserted in the mail messages for convenience
680 WEBBASE_URL=$(echo $WEBBASE | sed -e "s,//,/,g" -e "s,${WEBROOT},${TESTBUILDURL},")
682 if [ -n "$DO_BUILD" ] ; then
684 # invoke this command into the build directory of the vserver
685 cp $COMMANDPATH /vservers/${BASE}/build/
687 # invoke this command in the vserver for building (-T)
688 vserver ${BASE} exec chmod +x /build/$COMMAND
689 vserver ${BASE} exec /build/$COMMAND "${options[@]}" -b "${BASE}" "${MAKEVARS[@]}" "${MAKETARGETS[@]}"
692 # publish to the web so run_log can find them
694 webpublish rm -rf $WEBPATH/$BASE
695 webpublish mkdir -p $WEBPATH/$BASE/{RPMS,SRPMS}
696 webpublish_rsync_dir /vservers/$BASE/build/RPMS/ $WEBPATH/$BASE/RPMS/
697 [[ -n "$PUBLISH_SRPMS" ]] && webpublish_rsync_dir /vservers/$BASE/build/SRPMS/ $WEBPATH/$BASE/SRPMS/
698 # publish myplc-release if this exists
699 release=/vservers/$BASE/build/myplc-release
700 [ -f $release ] && webpublish_rsync_file $release $WEBPATH/$BASE
703 # create yum repo and sign packages.
704 if [ -n "$SIGNYUMREPO" ] ; then
705 # this script does not yet support signing on a remote (webhost) repo
706 sign_here=$(hostname) ; sign_web=$(webpublish hostname)
707 if [ "$hostname" = "$sign_here" ] ; then
710 echo "$COMMAND does not support signing on a remote yum repo"
711 echo "you might want to turn off the -y option, or run this on the web server box itself"
716 if [ -n "$DO_TEST" ] ; then
722 echo "==================== MAIN END $(date)"