4 # this tool derives from the PL code, from the lxc-userspace module
5 # can be obtained through rpm/yum
6 # it is used here as a replacement for 'vserver <> exec'
7 # that is used throughout this code
10 COMMAND=$(basename $0)
12 # default values, tunable with command-line options
14 DEFAULT_PLDISTRO=planetlab
15 DEFAULT_PERSONALITY=linux64
16 DEFAULT_BASE="@DATE@--@PLDISTRO@-@FCDISTRO@-@PERSONALITY@"
17 DEFAULT_BUILD_SCM_URL="git://git.onelab.eu/build"
20 # default gpg path used in signing yum repo
21 DEFAULT_GPGPATH="/etc/planetlab"
22 # default email to use in gpg secring
23 DEFAULT_GPGUID="root@$( /bin/hostname )"
25 DEFAULT_TESTCONFIG="default"
26 # for passing args to run_log
29 # for publishing results, and the tests settings
31 y=$(hostname|sed -e s,inria,,)
33 if [ "$x" != "$y" ] ; then
34 DEFAULT_WEBPATH="/build/@PLDISTRO@/"
35 DEFAULT_TESTBUILDURL="http://build.onelab.eu/"
36 # this is where the buildurl is pointing towards
37 DEFAULT_WEBROOT="/build/"
38 DEFAULT_TESTMASTER="testmaster.onelab.eu"
40 DEFAULT_WEBPATH="/build/@FCDISTRO@/@PLDISTRO@/"
41 DEFAULT_TESTBUILDURL="http://build.planet-lab.org/"
42 # this is where the buildurl is pointing towards
43 DEFAULT_WEBROOT="/build/"
44 DEFAULT_TESTMASTER="manager.test.planet-lab.org"
48 # assuming vm runs in UTC
49 DATE=$(date +'%Y.%m.%d')
51 # still using /vservers for legacy reasons
52 # as far as the build & test infra, we could adopt a new name
53 # but the PL code still uses this name for now, so let's keep it simple
56 echo /vservers/$slice/rootfs
60 echo /vservers/$slice.log.txt
63 # wrap a quick summary of suspicious stuff
64 # this is to focus on installation that go wrong
65 # use with care, a *lot* of other things can go bad as well
68 echo "******************** BEG SUMMARY"
71 # read a full log and tries to extract the interesting stuff
74 m_show_line=re.compile(".* (BEG|END) (RPM|LXC).*|.*'boot'.*|\* .*| \* .*|.*is not installed.*|.*PROPFIND.*|.* (BEG|END).*:run_log.*|.* Within LXC (BEG|END) .*|.* MAIN (BEG|END).*")
75 m_installing_any=re.compile('\r (Installing:[^\]]*]) ')
76 m_installing_err=re.compile('\r (Installing:[^\]]*])(..+)')
77 m_installing_end=re.compile('Installed:.*')
78 m_installing_doc1=re.compile("(.*)install-info: No such file or directory for /usr/share/info/\S+(.*)")
79 m_installing_doc2=re.compile("(.*)grep: /usr/share/info/dir: No such file or directory(.*)")
81 def summary (filename):
90 for line in f.xreadlines():
91 # first off : discard warnings related to doc
92 if m_installing_doc1.match(line):
93 (begin,end)=m_installing_doc1.match(line).groups()
95 if m_installing_doc2.match(line):
96 (begin,end)=m_installing_doc2.match(line).groups()
98 # unconditionnally show these lines
99 if m_show_line.match(line):
101 # an 'installing' line with messages afterwards : needs to be echoed
102 elif m_installing_err.match(line):
103 (installing,error)=m_installing_err.match(line).groups()
104 print '>>>',installing
107 # closing an 'installing' section
108 elif m_installing_end.match(line):
110 # any 'installing' line
111 elif m_installing_any.match(line):
113 installing=m_installing_any.match(line).group(1)
114 print '>>>',installing
116 # print lines when echo is true
118 if echo: print '>>>',line,
121 print 'Failed to analyze',filename
123 for arg in sys.argv[1:]:
126 echo "******************** END SUMMARY"
129 ### we might build on a box other than the actual web server
130 # utilities for handling the pushed material (rpms, logfiles, ...)
131 function webpublish_misses_dir () { ssh root@${WEBHOST} "bash -c \"test \! -d $1\"" ; }
132 function webpublish () { ssh root@${WEBHOST} "$@" ; }
133 function webpublish_cp_local_to_remote () { scp $1 root@${WEBHOST}:$2 ; }
134 function webpublish_cp_stdin_to_file () { ssh root@${WEBHOST} cat \> $1; }
135 function webpublish_append_stdin_to_file () { ssh root@${WEBHOST} cat \>\> $1; }
136 # provide remote dir as first argument, so any number of local files can be passed next
137 function webpublish_rsync_dir () { rsync --archive --delete $VERBOSE $2 root@${WEBHOST}:$1 ; }
138 function webpublish_rsync_files () {
140 rsync --archive $VERBOSE "$@" root@${WEBHOST}:"$remote" ;
143 # Notify recipient of failure or success, manage various stamps
146 # early stage ? - let's not create /build/@PLDISTRO@
147 if test -z "$WEBLOG" ; then
150 WEBBASE=/tmp/vbuild-early-$(date +%Y-%m-%d)
151 WEBLOG=/tmp/vbuild-early-$(date +%Y-%m-%d).log.txt
153 webpublish mkdir -p $WEBBASE ||:
154 webpublish_cp_local_to_remote $LOG $WEBLOG ||:
155 summary $LOG | webpublish_append_stdin_to_file $WEBLOG ||:
156 (echo -n "============================== $COMMAND: failure at " ; date ; \
157 webpublish tail --lines=1000 $WEBLOG) | \
158 webpublish_cp_stdin_to_file $WEBBASE.ko ||:
159 if [ -n "$MAILTO" ] ; then
161 echo "Subject: KO ${BASE} ${MAIL_SUBJECT}" ; \
162 echo "To: $MAILTO" ; \
163 echo "see build results at $WEBBASE_URL" ; \
164 echo "including full build log at $WEBBASE_URL/log.txt" ; \
165 echo "and complete test logs at $WEBBASE_URL/testlogs" ; \
166 echo "........................................" ; \
167 webpublish tail --lines=1000 $WEBLOG ) | \
173 function success () {
175 # early stage ? - let's not create /build/@PLDISTRO@
176 if test -z "$WEBLOG" ; then
179 WEBLOG=/tmp/vbuild-early-$(date +%Y-%m-%d).log.txt
181 webpublish mkdir -p $WEBBASE
182 webpublish_cp_local_to_remote $LOG $WEBLOG
183 summary $LOG | webpublish_append_stdin_to_file $WEBLOG
184 if [ -n "$DO_TEST" ] ; then
187 echo "Successfully built and tested" ; \
188 echo "see build results at $WEBBASE_URL" ; \
189 echo "including full build log at $WEBBASE_URL/log.txt" ; \
190 echo "and complete test logs at $WEBBASE_URL/testlogs" ; \
191 ) | webpublish_cp_stdin_to_file $WEBBASE.pass
192 webpublish rm -f $WEBBASE.pkg-ok $WEBBASE.ko
194 short_message="PKGOK"
196 echo "Successful package-only build, no test requested" ; \
197 echo "see build results at $WEBBASE_URL" ; \
198 echo "including full build log at $WEBBASE_URL/log.txt" ; \
199 ) | webpublish_cp_stdin_to_file $WEBBASE.pkg-ok
200 webpublish rm -f $WEBBASE.ko
202 if [ -n "$MAILTO" ] ; then
204 echo "Subject: $short_message ${BASE} ${MAIL_SUBJECT}" ; \
205 echo "To: $MAILTO" ; \
206 echo "$PLDISTRO ($BASE) build for $FCDISTRO completed on $(date)" ; \
207 echo "see build results at $WEBBASE_URL" ; \
208 echo "including full build log at $WEBBASE_URL/log.txt" ; \
209 [ -n "$DO_TEST" ] && echo "and complete test logs at $WEBBASE_URL/testlogs" ) \
212 # XXX For some reason, we haven't been getting this email for successful builds. If this sleep
213 # doesn't fix the problem, I'll remove it -- Sapan.
218 # run in the vm - do not manage success/failure, will be done from the root ctx
223 echo -n "============================== Starting $COMMAND:build on "
229 echo "Running make IN $(pwd)"
231 # stuff our own variable settings
232 MAKEVARS=("build-GITPATH=${BUILD_SCM_URL}" "${MAKEVARS[@]}")
233 MAKEVARS=("PLDISTRO=${PLDISTRO}" "${MAKEVARS[@]}")
234 MAKEVARS=("PLDISTROTAGS=${PLDISTROTAGS}" "${MAKEVARS[@]}")
235 MAKEVARS=("PERSONALITY=${PERSONALITY}" "${MAKEVARS[@]}")
236 MAKEVARS=("MAILTO=${MAILTO}" "${MAKEVARS[@]}")
237 MAKEVARS=("WEBPATH=${WEBPATH}" "${MAKEVARS[@]}")
238 MAKEVARS=("TESTBUILDURL=${TESTBUILDURL}" "${MAKEVARS[@]}")
239 MAKEVARS=("WEBROOT=${WEBROOT}" "${MAKEVARS[@]}")
241 MAKEVARS=("BASE=${BASE}" "${MAKEVARS[@]}")
244 /build/latex-first-run.sh || :
247 make -C /build $DRY_RUN "${MAKEVARS[@]}" stage1=true
249 make -C /build $DRY_RUN "${MAKEVARS[@]}" versions
251 make -C /build $DRY_RUN "${MAKEVARS[@]}" "${MAKETARGETS[@]}"
255 # this was formerly run in the myplc-devel chroot but now is run in the root context,
256 # this is so that the .ssh config gets done manually, and once and for all
257 function run_log () {
262 echo "============================== BEG $COMMAND:run_log on $(date)"
264 ### the URL to the RPMS/<arch> location
265 # f12 now has everything in i686; try i386 first as older fedoras have both
267 for a in i386 i686 x86_64; do
268 archdir=$(rootdir $BASE)/build/RPMS/$a
269 if [ -d $archdir ] ; then
270 # where was that installed
271 url=$(echo $archdir | sed -e "s,$(rootdir $BASE)/build,${WEBPATH}/${BASE},")
272 url=$(echo $url | sed -e "s,${WEBROOT},${TESTBUILDURL},")
277 if [ -z "$url" ] ; then
278 echo "$COMMAND: Cannot locate arch URL for testing"
283 testmaster_ssh="root@${TESTMASTER}"
285 # test directory name on test box
289 ssh -n ${testmaster_ssh} rm -rf ${testdir} ${testdir}.git
291 # check it out in the build
292 lxcsu -ro $BASE make -C /build tests-module
294 # push it onto the testmaster - just the 'system' subdir is enough
295 rsync --verbose --archive $(rootdir $BASE)/build/MODULES/tests/system/ ${testmaster_ssh}:${BASE}
296 # toss the build in the bargain, so the tests don't need to mess with extracting it
297 rsync --verbose --archive $(rootdir $BASE)/build/MODULES/build ${testmaster_ssh}:${BASE}/
299 # invoke test on testbox - pass url and build url - so the tests can use vtest-init-lxc.sh
300 run_log_env="-p $PERSONALITY -d $PLDISTRO -f $FCDISTRO"
302 # need to proceed despite of set -e
304 # passing the build_scm_url should not be needed anymore
305 ssh 2>&1 -n ${testmaster_ssh} ${testdir}/run_log --build ${BUILD_SCM_URL} --url ${url} $run_log_env $RUN_LOG_EXTRAS $VERBOSE --all || success=
307 # gather logs in the build vm
308 mkdir -p $(rootdir $BASE)/build/testlogs
309 rsync --verbose --archive ${testmaster_ssh}:$BASE/logs/ $(rootdir $BASE)/build/testlogs
310 # push them to the build web
311 chmod -R a+r $(rootdir $BASE)/build/testlogs/
312 webpublish_rsync_dir $WEBPATH/$BASE/testlogs/ $(rootdir $BASE)/build/testlogs/
314 echo "============================== END $COMMAND:run_log on $(date)"
316 if [ -z "$success" ] ; then
317 echo "Tests have failed - bailing out"
323 function in_root_context () {
324 rpm -q libvirt > /dev/null
327 # this part won't work if WEBHOST does not match the local host
328 # would need to be made webpublish_* compliant
329 # but do we really need this feature anyway ?
330 function sign_node_packages () {
332 echo "Signing node packages"
336 repository=$WEBPATH/$BASE/RPMS/
337 # the rpms that need signing
339 # and the corresponding stamps
342 for package in $(find $repository/ -name '*.rpm') ; do
343 stamp=$repository/signed-stamps/$(basename $package).signed
344 # If package is newer than signature stamp
345 if [ $package -nt $stamp ] ; then
346 new_rpms="$new_rpms $package"
347 new_stamps="$new_stamps $stamp"
349 # Or than createrepo database
350 [ $package -nt $repository/repodata/repomd.xml ] && need_createrepo=true
353 if [ -n "$new_rpms" ] ; then
354 # Create a stamp once the package gets signed
355 mkdir $repository/signed-stamps 2> /dev/null
357 # Sign RPMS. setsid detaches rpm from the terminal,
358 # allowing the (hopefully blank) GPG password to be
359 # entered from stdin instead of /dev/tty.
361 --define "_signature gpg" \
362 --define "_gpg_path $GPGPATH" \
363 --define "_gpg_name $GPGUID" \
364 --resign $new_rpms && touch $new_stamps
367 # Update repository index / yum metadata.
368 if [ -n "$need_createrepo" ] ; then
369 echo "Indexing node packages after signing"
370 if [ -f $repository/yumgroups.xml ] ; then
371 createrepo --quiet -g yumgroups.xml $repository
373 createrepo --quiet $repository
378 function show_env () {
380 echo FCDISTRO=$FCDISTRO
381 echo PLDISTRO=$PLDISTRO
382 echo PERSONALITY=$PERSONALITY
384 echo BUILD_SCM_URL=$BUILD_SCM_URL
385 echo MAKEVARS="${MAKEVARS[@]}"
386 echo DRY_RUN="$DRY_RUN"
387 echo PLDISTROTAGS="$PLDISTROTAGS"
388 # this does not help, it's not yet set when we run show_env
389 #echo WEBPATH="$WEBPATH"
390 echo TESTBUILDURL="$TESTBUILDURL"
391 echo WEBHOST="$WEBHOST"
392 if in_root_context ; then
393 echo PLDISTROTAGS="$PLDISTROTAGS"
395 if [ -f /build/$PLDISTROTAGS ] ; then
396 echo "XXXXXXXXXXXXXXXXXXXX Contents of tags definition file /build/$PLDISTROTAGS"
397 cat /build/$PLDISTROTAGS
398 echo "XXXXXXXXXXXXXXXXXXXX end tags definition"
400 echo "XXXXXXXXXXXXXXXXXXXX Cannot find tags definition file /build/$PLDISTROTAGS, assuming remote pldistro"
406 function setupssh () {
410 if [ -f ${sshkey} ] ; then
411 SSHDIR=$(rootdir ${base})/root/.ssh
413 cp $sshkey ${SSHDIR}/thekey
415 echo " IdentityFile ~/.ssh/thekey"; \
416 echo " StrictHostKeyChecking no" ) > ${SSHDIR}/config
418 chmod 400 ${SSHDIR}/*
420 echo "WARNING : could not find provided ssh key $sshkey - ignored"
425 echo "Usage: $COMMAND [option] [var=value...] make-targets"
426 echo "Supported options"
427 echo " -f fcdistro - defaults to $DEFAULT_FCDISTRO"
428 echo " -d pldistro - defaults to $DEFAULT_PLDISTRO"
429 echo " -p personality - defaults to $DEFAULT_PERSONALITY"
430 echo " -m mailto - no default"
431 echo " -s build_scm_url - git URL where to fetch the build module - defaults to $DEFAULT_BUILD_SCM_URL"
432 echo " define GIT tag or branch name appending @tagname to url"
433 echo " -t pldistrotags - defaults to \${PLDISTRO}-tags.mk"
434 echo " -b base - defaults to $DEFAULT_BASE"
435 echo " @NAME@ replaced as appropriate"
436 echo " -o base: (overwrite) do not re-create vm, re-use base instead"
437 echo " the -f/-d/-p/-m/-s/-t options are uneffective in this case"
438 echo " -c testconfig - defaults to $DEFAULT_TESTCONFIG"
439 echo " -y {pl,pg} - passed to run_log"
440 echo " -e step - passed to run_log"
441 echo " -X : passes --lxc to run_log"
442 echo " -S : passes --vs to run_log"
443 echo " -x <run_log_args> - a hook to pass other arguments to run_log"
444 echo " -w webpath - defaults to $DEFAULT_WEBPATH"
445 echo " -W testbuildurl - defaults to $DEFAULT_TESTBUILDURL; this is also used to get the hostname where to publish builds"
446 echo " -r webroot - defaults to $DEFAULT_WEBROOT - the fs point where testbuildurl actually sits"
447 echo " -M testmaster - defaults to $DEFAULT_TESTMASTER"
448 echo " -Y - sign yum repo in webpath"
449 echo " -g gpg_path - to the gpg secring used to sign rpms. Defaults to $DEFAULT_GPGPATH"
450 echo " -u gpg_uid - email used in secring. Defaults to $DEFAULT_GPGUID"
451 echo " -K sshkey - specify ssh key to use when reaching git over ssh"
452 echo " -S - do not publish source rpms"
453 echo " -B - run build only"
454 echo " -T - run test only"
455 echo " -n - dry-run: -n passed to make - vm gets created though - no mail sent"
456 echo " -v - be verbose"
457 echo " -7 - uses weekday-@FCDISTRO@ as base"
458 echo " -i ifname - defaults to $DEFAULT_IFNAME - used to determine local IP"
459 echo " --build-branch branch - build using the branch from build module"
478 OPTS=$(getopt -o "f:d:p:m:s:t:b:o:c:y:e:XSx:w:W:r:M:Yg:u:K:SBTnv7i:P:h" -l "build-branch:" -- $@)
486 -f) FCDISTRO=$2; shift 2 ;;
487 -d) PLDISTRO=$2; shift 2 ;;
488 -p) PERSONALITY=$2; shift 2 ;;
489 -m) MAILTO=$2; shift 2 ;;
490 -s) BUILD_SCM_URL=$2; shift 2 ;;
491 -t) PLDISTROTAGS=$2; shift 2 ;;
492 -b) BASE=$2; shift 2 ;;
493 -o) OVERBASE=$2; shift 2 ;;
494 -c) TESTCONFIG="$TESTCONFIG $2"; shift 2 ;;
495 ########## passing stuff to run_log
496 # -y foo -> run_log -y foo
497 -y) RUN_LOG_EXTRAS="$RUN_LOG_EXTRAS --rspec-style $2"; shift 2 ;;
498 # -e foo -> run_log -e foo
499 -e) RUN_LOG_EXTRAS="$RUN_LOG_EXTRAS --exclude $2"; shift 2 ;;
500 # -X -> run_log --lxc
501 -X) RUN_LOG_EXTRAS="$RUN_LOG_EXTRAS --lxc"; shift;;
503 -S) RUN_LOG_EXTRAS="$RUN_LOG_EXTRAS --vs"; shift;;
504 # more general form to pass args to run_log
505 # -x foo -> run_log foo
506 -x) RUN_LOG_EXTRAS="$RUN_LOG_EXTRAS $2"; shift 2;;
508 -w) WEBPATH=$2; shift 2 ;;
509 -W) TESTBUILDURL=$2; shift 2 ;;
510 -r) WEBROOT=$2; shift 2 ;;
511 -M) TESTMASTER=$2; shift 2 ;;
512 -Y) SIGNYUMREPO=true; shift ;;
513 -g) GPGPATH=$2; shift 2 ;;
514 -u) GPGUID=$2; shift 2 ;;
515 -K) SSH_KEY=$2; shift 2 ;;
516 -S) PUBLISH_SRPMS="" ; shift ;;
517 -B) DO_TEST= ; shift ;;
518 -T) DO_BUILD= ; shift;;
519 -n) DRY_RUN="-n" ; shift ;;
520 -v) set -x ; VERBOSE="-v" ; shift ;;
521 -7) BASE="$(date +%a|tr A-Z a-z)-@FCDISTRO@" ; shift ;;
522 -i) IFNAME=$2; shift 2 ;;
523 -P) PREINSTALLED="-P $2"; shift 2;;
529 # preserve options for passing them again later, together with expanded base
532 # allow var=value stuff;
533 for target in "$@" ; do
534 # check if contains '='
535 target1=$(echo $target | sed -e s,=,,)
536 if [ "$target" = "$target1" ] ; then
537 MAKETARGETS=(${MAKETARGETS[@]} "$target")
539 MAKEVARS=(${MAKEVARS[@]} "$target")
544 [ -z "$FCDISTRO" ] && FCDISTRO=$DEFAULT_FCDISTRO
545 [ -z "$PLDISTRO" ] && PLDISTRO=$DEFAULT_PLDISTRO
546 [ -z "$PERSONALITY" ] && PERSONALITY=$DEFAULT_PERSONALITY
547 [ -z "$PLDISTROTAGS" ] && PLDISTROTAGS="${PLDISTRO}-tags.mk"
548 [ -z "$BASE" ] && BASE="$DEFAULT_BASE"
549 [ -z "$WEBPATH" ] && WEBPATH="$DEFAULT_WEBPATH"
550 [ -z "$TESTBUILDURL" ] && TESTBUILDURL="$DEFAULT_TESTBUILDURL"
551 [ -z "$WEBROOT" ] && WEBROOT="$DEFAULT_WEBROOT"
552 [ -z "$GPGPATH" ] && GPGPATH="$DEFAULT_GPGPATH"
553 [ -z "$GPGUID" ] && GPGUID="$DEFAULT_GPGUID"
554 [ -z "$IFNAME" ] && IFNAME="$DEFAULT_IFNAME"
555 [ -z "$BUILD_SCM_URL" ] && BUILD_SCM_URL="$DEFAULT_BUILD_SCM_URL"
556 [ -z "$TESTCONFIG" ] && TESTCONFIG="$DEFAULT_TESTCONFIG"
557 [ -z "$TESTMASTER" ] && TESTMASTER="$DEFAULT_TESTMASTER"
559 [ -n "$DRY_RUN" ] && MAILTO=""
561 # elaborate the extra args to be passed to run_log
562 for config in ${TESTCONFIG} ; do
563 RUN_LOG_EXTRAS="$RUN_LOG_EXTRAS --config $config"
567 if [ -n "$OVERBASE" ] ; then
568 sedargs="-e s,@DATE@,${DATE},g"
569 BASE=$(echo ${OVERBASE} | sed $sedargs)
571 sedargs="-e s,@DATE@,${DATE},g -e s,@FCDISTRO@,${FCDISTRO},g -e s,@PLDISTRO@,${PLDISTRO},g -e s,@PERSONALITY@,${PERSONALITY},g"
572 BASE=$(echo ${BASE} | sed $sedargs)
575 ### elaborate mail subject
576 if [ -n "$DO_BUILD" -a -n "$DO_TEST" ] ; then
578 elif [ -n "$DO_BUILD" ] ; then
579 MAIL_SUBJECT="pkg-only"
580 elif [ -n "$DO_TEST" ] ; then
581 MAIL_SUBJECT="test-only"
583 if [ -n "$OVERBASE" ] ; then
584 MAIL_SUBJECT="${MAIL_SUBJECT} rerun"
586 MAIL_SUBJECT="${MAIL_SUBJECT} fresh"
588 short_hostname=$(hostname | cut -d. -f1)
589 MAIL_SUBJECT="on ${short_hostname} - ${MAIL_SUBJECT}"
591 ### compute WEBHOST from TESTBUILDURL
592 # this is to avoid having to change the builds configs everywhere
593 # simplistic way to extract hostname from a URL
594 WEBHOST=$(echo "$TESTBUILDURL" | cut -d/ -f 3)
596 if ! in_root_context ; then
598 echo "==================== Within LXC BEG $(date)"
600 echo "==================== Within LXC END $(date)"
604 # we run in the root context :
605 # (*) create or check for the vm to use
606 # (*) copy this command in the vm
609 if [ -n "$OVERBASE" ] ; then
610 ### Re-use a vm (finish an unfinished build..)
611 if [ ! -d $(rootdir ${BASE}) ] ; then
612 echo $COMMAND : cannot find vm $BASE
615 # manage LOG - beware it might be a symlink so nuke it first
616 LOG=$(logfile ${BASE})
620 echo "XXXXXXXXXX $COMMAND: using existing vm $BASE" $(date)
621 # start in case e.g. we just rebooted
622 virsh --connect lxc:/// start ${BASE} || :
623 # retrieve environment from the previous run
624 FCDISTRO=$(lxcsu -ro ${BASE} /build/getdistroname.sh)
625 BUILD_SCM_URL=$(lxcsu -ro ${BASE} make --no-print-directory -C /build stage1=skip +build-GITPATH)
626 # for efficiency, crop everything in one make run
627 tmp=/tmp/${BASE}-env.sh
628 lxcsu -ro ${BASE} make --no-print-directory -C /build stage1=skip \
629 ++PLDISTRO ++PLDISTROTAGS ++PERSONALITY ++MAILTO ++WEBPATH ++TESTBUILDURL ++WEBROOT > $tmp
633 [ -n "$SSH_KEY" ] && setupssh ${BASE} ${SSH_KEY}
634 lxcsu -ro $BASE bash -c "cd /build; git pull; make tests-clean"
635 # make sure we refresh the tests place in case it has changed
636 rm -f /build/MODULES/tests
637 options=(${options[@]} -d $PLDISTRO -t $PLDISTROTAGS -s $BUILD_SCM_URL)
638 [ -n "$PERSONALITY" ] && options=(${options[@]} -p $PERSONALITY)
639 [ -n "$MAILTO" ] && options=(${options[@]} -m $MAILTO)
640 [ -n "$WEBPATH" ] && options=(${options[@]} -w $WEBPATH)
641 [ -n "$TESTBUILDURL" ] && options=(${options[@]} -W $TESTBUILDURL)
642 [ -n "$WEBROOT" ] && options=(${options[@]} -r $WEBROOT)
645 # create vm: check it does not exist yet
647 while [ -d $(rootdir ${BASE})${i} ] ; do
648 # we name subsequent builds <base>-n<i> so the logs and builds get sorted properly
649 [ -z ${i} ] && BASE=${BASE}-n
651 if [ $i -gt 100 ] ; then
652 echo "$COMMAND: Failed to create build vm $(rootdir ${BASE})${i}"
658 # manage LOG - beware it might be a symlink so nuke it first
659 LOG=$(logfile ${BASE})
663 echo "XXXXXXXXXX $COMMAND: creating vm $BASE" $(date)
666 ### extract the whole build - much simpler
667 tmpdir=/tmp/$COMMAND-$$
668 GIT_REPO=$(echo $BUILD_SCM_URL | cut -d@ -f1)
669 GIT_TAG=$(echo $BUILD_SCM_URL | cut -s -d@ -f2)
670 GIT_TAG=${GIT_TAG:-master}
671 mkdir -p $tmpdir; git archive --remote=$GIT_REPO $GIT_TAG | tar -C $tmpdir -xf -
675 ./vbuild-init-lxc.sh $VERBOSE -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} -i ${IFNAME} ${PREINSTALLED} ${BASE}
679 # Extract build again - in the vm
680 [ -n "$SSH_KEY" ] && setupssh ${BASE} ${SSH_KEY}
681 lxcsu -ro $BASE bash -c "git clone $GIT_REPO /build; cd /build; git checkout $GIT_TAG"
683 echo "XXXXXXXXXX $COMMAND: preparation of vm $BASE done" $(date)
685 # The log inside the vm contains everything
686 LOG2=$(rootdir ${BASE})/log.txt
687 (echo "==================== BEG LXC Transcript of vm creation" ; \
689 echo "==================== END LXC Transcript of vm creation" ; \
690 echo "xxxxxxxxxx Messing with logs, symlinking $LOG2 to $LOG" ) >> $LOG2
691 ### not too nice : nuke the former log, symlink it to the new one
692 rm $LOG; ln -s $LOG2 $LOG
697 sedargs="-e s,@DATE@,${DATE},g -e s,@FCDISTRO@,${FCDISTRO},g -e s,@PLDISTRO@,${PLDISTRO},g -e s,@PERSONALITY@,${PERSONALITY},g"
698 WEBPATH=$(echo ${WEBPATH} | sed $sedargs)
699 webpublish mkdir -p ${WEBPATH}
701 # where to store the log for web access
702 WEBBASE=${WEBPATH}/${BASE}
703 WEBLOG=${WEBPATH}/${BASE}/log.txt
704 # compute the log URL - inserted in the mail messages for convenience
705 WEBBASE_URL=$(echo $WEBBASE | sed -e "s,//,/,g" -e "s,${WEBROOT},${TESTBUILDURL},")
707 if [ -n "$DO_BUILD" ] ; then
709 # invoke this command into the build directory of the vm
710 cp $COMMANDPATH $(rootdir ${BASE})/build/
712 # invoke this command in the vm for building (-T)
713 lxcsu -ro ${BASE} chmod +x /build/$COMMAND
714 lxcsu -ro ${BASE} /build/$COMMAND "${options[@]}" -b "${BASE}" "${MAKEVARS[@]}" "${MAKETARGETS[@]}"
717 # publish to the web so run_log can find them
719 webpublish rm -rf $WEBPATH/$BASE
720 # guess if we've been doing any debian-related build
721 if [ ! -f $(rootdir $BASE)/etc/debian_version ] ; then
722 webpublish mkdir -p $WEBPATH/$BASE/{RPMS,SRPMS}
723 webpublish_rsync_dir $WEBPATH/$BASE/RPMS/ $(rootdir $BASE)/build/RPMS/
724 [[ -n "$PUBLISH_SRPMS" ]] && webpublish_rsync_dir $WEBPATH/$BASE/SRPMS/ $(rootdir $BASE)/build/SRPMS/
726 # run scanpackages so we can use apt-get on this
727 # (not needed on fedora b/c this is done by the regular build already)
728 lxcsu -ro $BASE bash -c "(cd /build ; dpkg-scanpackages DEBIAN/ | gzip -9c > Packages.gz)"
729 webpublish mkdir -p $WEBPATH/$BASE/DEBIAN
730 webpublish_rsync_files $WEBPATH/$BASE/DEBIAN/ $(rootdir $BASE)/build/DEBIAN/*.deb
731 webpublish_rsync_files $WEBPATH/$BASE/ $(rootdir $BASE)/build/Packages.gz
733 # publish myplc-release if this exists
734 release=$(rootdir $BASE)/build/myplc-release
735 [ -f $release ] && webpublish_rsync_files $WEBPATH/$BASE $release
738 # create yum repo and sign packages.
739 if [ -n "$SIGNYUMREPO" ] ; then
740 # this script does not yet support signing on a remote (webhost) repo
741 sign_here=$(hostname) ; sign_web=$(webpublish hostname)
742 if [ "$hostname" = "$sign_here" ] ; then
745 echo "$COMMAND does not support signing on a remote yum repo"
746 echo "you might want to turn off the -y option, or run this on the web server box itself"
751 if [ -n "$DO_TEST" ] ; then
757 echo "==================== MAIN END $(date)"