X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vbuild-nightly.sh;h=22c90ae95aa916e3aae38c12ea1d529531127f58;hb=a0ad7bfec398b487bd60aa454773104b52fe2387;hp=d33d83cbe954c58fb6393a836e010e35305c57c5;hpb=3911c7d0ce16bb672789151ab5666c15115333f2;p=build.git diff --git a/vbuild-nightly.sh b/vbuild-nightly.sh index d33d83cb..22c90ae9 100755 --- a/vbuild-nightly.sh +++ b/vbuild-nightly.sh @@ -107,24 +107,41 @@ EOF echo "******************** END SUMMARY" } +### we might build on a box other than the actual web server +# utilities for handling the pushed material (rpms, logfiles, ...) +function webpublish_misses_dir () { ssh root@${WEBHOST} "bash -c \"test \! -d $1\"" ; } +function webpublish () { ssh root@${WEBHOST} "$@" ; } +function webpublish_rsync_dir () { rsync --archive --delete $VERBOSE $1 root@${WEBHOST}:$2 ; } +function webpublish_rsync_file () { rsync $VERBOSE $1 root@${WEBHOST}:$2 ; } +function webpublish_cp_local_to_remote () { scp $1 root@${WEBHOST}:$2 ; } +function webpublish_cp_stdin_to_file () { ssh root@${WEBHOST} cat \> $1; } +function webpublish_append_stdin_to_file () { ssh root@${WEBHOST} cat \>\> $1; } # Notify recipient of failure or success, manage various stamps function failure() { set -x # early stage ? - let's not create /build/@PLDISTRO@ - if [ ! -d ${WEBPATH} ] ; then + if webpublish_misses_dir $WEBPATH ; then + WEBHOST=localhost WEBPATH=/tmp - WEBLOG=/tmp/vbuild-early.log.txt + WEBBASE=/tmp/vbuild-early-$(date +%Y-%m-%d) + WEBLOG=/tmp/vbuild-early-$(date +%Y-%m-%d).log.txt fi - cp $LOG ${WEBLOG} - summary $LOG >> ${WEBLOG} - (echo -n "============================== $COMMAND: failure at " ; date ; tail --lines=1000 $WEBLOG) > ${WEBLOG}.ko + webpublish mkdir -p $WEBBASE ||: + webpublish_cp_local_to_remote $LOG $WEBLOG ||: + summary $LOG | webpublish_append_stdin_to_file $WEBLOG ||: + (echo -n "============================== $COMMAND: failure at " ; date ; \ + webpublish tail --lines=1000 $WEBLOG) | \ + webpublish_cp_stdin_to_file $WEBBASE.ko ||: if [ -n "$MAILTO" ] ; then ( \ - echo "See full build log at ${LOG_URL}" ; \ - echo "and tail version at ${LOG_URL}.ko" ; \ - echo "See complete set of testlogs at ${TESTLOGS_URL}" ; \ - tail --lines=1000 ${WEBLOG} ) | mail -s "Failures with ${MAIL_SUBJECT} ${BASE} on $(hostname)" $MAILTO + echo "Subject: Failures with $MAIL_SUBJECT $BASE on $(hostname)" ; \ + echo "See full build log at $WEBBASE_URL/log.txt" ; \ + echo "and tail version at $WEBBASE_URL.ko" ; \ + echo "See complete set of testlogs at $WEBBASE_URL/testlogs" ; \ + echo "........................................" ; \ + webpublish tail --lines=1000 $WEBLOG ) | \ + sendmail $MAILTO fi exit 1 } @@ -132,32 +149,35 @@ function failure() { function success () { set -x # early stage ? - let's not create /build/@PLDISTRO@ - if [ ! -d ${WEBPATH} ] ; then + if webpublish_misses_dir ${WEBPATH} ; then + WEBHOST=localhost WEBPATH=/tmp WEBLOG=/tmp/vbuild-early-$(date +%Y-%m-%d).log.txt fi - cp $LOG ${WEBLOG} - summary $LOG >> ${WEBLOG} + webpublish mkdir -p $WEBBASE + webpublish_cp_local_to_remote $LOG $WEBLOG + summary $LOG | webpublish_append_stdin_to_file $WEBLOG if [ -n "$DO_TEST" ] ; then ( \ echo "Successfully built and tested" ; \ - echo "See full build log at ${LOG_URL}" ; \ - echo "See complete set of testlogs at ${TESTLOGS_URL}" ; \ - ) > ${WEBLOG}.pass - rm -f ${WEBLOG}.pkg-ok ${WEBLOG}.ko + echo "See full build log at $WEBBASE_URL/log.txt" ; \ + echo "See complete set of testlogs at $WEBBASE_URL/testlogs" ; \ + ) | webpublish_cp_stdin_to_file $WEBBASE.pass + webpublish rm -f $WEBBASE.pkg-ok $WEBBASE.ko else ( \ echo "Successful package-only build, no test requested" ; \ - echo "See full build log at ${LOG_URL}" ; \ - ) > ${WEBLOG}.pkg-ok - rm -f ${WEBLOG}.ko + echo "See full build log at $WEBBASE_URL/log.txt" ; \ + ) | webpublish_cp_stdin_to_file $WEBBASE.pkg-ok + webpublish rm -f $WEBBASE.ko fi if [ -n "$MAILTO" ] ; then ( \ + echo "Subject: Success with ${MAIL_SUBJECT} ${BASE} on $(hostname)" ; \ echo "$PLDISTRO ($BASE) build for $FCDISTRO completed on $(date)" ; \ - echo "See full build log at ${LOG_URL}" ; \ - [ -n "$DO_TEST" ] && echo "See complete set of testlogs at ${TESTLOGS_URL}" ) \ - | mail -s "Success with ${MAIL_SUBJECT} ${BASE} on $(hostname)" $MAILTO + echo "See full build log at $WEBBASE_URL/log.txt" ; \ + [ -n "$DO_TEST" ] && echo "See complete set of testlogs at $WEBBASE_URL/testlogs" ) \ + | sendmail $MAILTO fi # XXX For some reason, we haven't been getting this email for successful builds. If this sleep # doesn't fix the problem, I'll remove it -- Sapan. @@ -222,8 +242,9 @@ function run_log () { TESTS_SYSTEM_SVNPATH=${TESTS_SVNPATH}/system ### the URL to the RPMS/ location + # f12 now has everything in i686; try i386 first as older fedoras have both url="" - for a in i386 x86_64; do + for a in i386 i686 x86_64; do archdir=/vservers/$BASE/build/RPMS/$a if [ -d $archdir ] ; then # where was that installed @@ -262,12 +283,13 @@ function run_log () { # gather logs in the vserver mkdir -p /vservers/$BASE/build/testlogs - ssh 2>&1 -n ${testmaster_ssh} tar -C ${testdir}/logs -cf - . | tar -C /vservers/$BASE/build/testlogs -xf - || true + ssh 2>&1 -n ${testmaster_ssh} tar -C ${testdir}/logs -cf - . | tar -C /vservers/$BASE/build/testlogs -xf - || : # push them to the build web chmod -R a+r /vservers/$BASE/build/testlogs/ - rsync --archive --delete /vservers/$BASE/build/testlogs/ $WEBPATH/$BASE/testlogs/ + webpublish_rsync_dir /vservers/$BASE/build/testlogs/ $WEBPATH/$BASE/testlogs/ if [ -z "$success" ] ; then + echo "Tests have failed - bailing out" failure fi @@ -278,7 +300,9 @@ function in_root_context () { rpm -q util-vserver > /dev/null } -# this part won't work with a remote(rsync) WEBPATH +# this part won't work if WEBHOST does not match the local host +# would need to be made webpublish_* compliant +# but do we really need this feature anyway ? function sign_node_packages () { echo "Signing node packages" @@ -340,6 +364,7 @@ function show_env () { # this does not help, it's not yet set when we run show_env #echo WEBPATH="$WEBPATH" echo TESTBUILDURL="$TESTBUILDURL" + echo WEBHOST="$WEBHOST" if in_root_context ; then echo PLDISTROTAGS="$PLDISTROTAGS" else @@ -388,7 +413,7 @@ function usage () { echo " the -f/-d/-p/-m/-s/-t options are uneffective in this case" echo " -c testconfig - defaults to $DEFAULT_TESTCONFIG" echo " -w webpath - defaults to $DEFAULT_WEBPATH" - echo " -W testbuildurl - defaults to $DEFAULT_TESTBUILDURL" + echo " -W testbuildurl - defaults to $DEFAULT_TESTBUILDURL; this is also used to get the hostname where to publish builds" echo " -r webroot - defaults to $DEFAULT_WEBROOT - the fs point where testbuildurl actually sits" echo " -M testmaster - defaults to $DEFAULT_TESTMASTER" echo " -y - sign yum repo in webpath" @@ -504,6 +529,11 @@ function main () { MAIL_SUBJECT="$MAIL_SUBJECT fresh build" fi + ### compute WEBHOST from TESTBUILDURL + # this is to avoid having to change the builds configs everywhere + # simplistic way to extract hostname from a URL + WEBHOST=$(echo "$TESTBUILDURL" | cut -d/ -f 3) + if ! in_root_context ; then # in the vserver echo "==================== Within vserver BEG $(date)" @@ -534,17 +564,24 @@ function main () { # update build [ -n "$SSH_KEY" ] && setupssh ${BASE} ${SSH_KEY} vserver ${BASE} exec svn update /build + # make sure we refresh the tests place in case it has changed + rm -f /build/tests_svnpath # get environment from the first run FCDISTRO=$(vserver ${BASE} exec /build/getdistroname.sh) - - PLDISTRO=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +PLDISTRO) - PLDISTROTAGS=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +PLDISTROTAGS) - build_SVNPATH=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +build-SVNPATH) - PERSONALITY=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +PERSONALITY) - MAILTO=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +MAILTO) - WEBPATH=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +WEBPATH) - TESTBUILDURL=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +TESTBUILDURL) - WEBROOT=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +WEBROOT) + # retrieve all in one run + tmp=/tmp/${BASE}-env.sh + vserver ${BASE} exec make --no-print-directory -C /build stage1=skip \ + ++PLDISTRO ++PLDISTROTAGS ++PERSONALITY ++MAILTO ++WEBPATH ++TESTBUILDURL ++WEBROOT > $tmp + # sh vars cannot have a minus + echo build_SVNPATH=$(vserver ${BASE} exec make --no-print-directory -C /build stage1=skip +build-SVNPATH) >> $tmp + . $tmp + rm -f $tmp + options=(${options[@]} -d $PLDISTRO -t $PLDISTROTAGS -s $build_SVNPATH) + [ -n "$PERSONALITY" ] && options=(${options[@]} -p $PERSONALITY) + [ -n "$MAILTO" ] && options=(${options[@]} -m $MAILTO) + [ -n "$WEBPATH" ] && options=(${options[@]} -w $WEBPATH) + [ -n "$TESTBUILDURL" ] && options=(${options[@]} -W $TESTBUILDURL) + [ -n "$WEBROOT" ] && options=(${options[@]} -r $WEBROOT) show_env else # create vserver: check it does not exist yet @@ -598,13 +635,13 @@ function main () { sedargs="-e s,@DATE@,${DATE},g -e s,@FCDISTRO@,${FCDISTRO},g -e s,@PLDISTRO@,${PLDISTRO},g -e s,@PERSONALITY@,${PERSONALITY},g" WEBPATH=$(echo ${WEBPATH} | sed $sedargs) - mkdir -p ${WEBPATH} + webpublish mkdir -p ${WEBPATH} # where to store the log for web access - WEBLOG=${WEBPATH}/${BASE}.log.txt + WEBBASE=${WEBPATH}/${BASE} + WEBLOG=${WEBPATH}/${BASE}/log.txt # compute the log URL - inserted in the mail messages for convenience - LOG_URL=$(echo ${WEBLOG} | sed -e "s,//,/,g" -e "s,${WEBROOT},${TESTBUILDURL},") - TESTLOGS_URL=$(echo ${WEBPATH}/${BASE}/testlogs | sed -e "s,//,/,g" -e "s,${WEBROOT},${TESTBUILDURL},") + WEBBASE_URL=$(echo $WEBBASE | sed -e "s,//,/,g" -e "s,${WEBROOT},${TESTBUILDURL},") if [ -n "$DO_BUILD" ] ; then @@ -617,16 +654,27 @@ function main () { fi # publish to the web so run_log can find them - rm -rf $WEBPATH/$BASE ; mkdir -p $WEBPATH/$BASE/{RPMS,SRPMS} - rsync --archive --delete $VERBOSE /vservers/$BASE/build/RPMS/ $WEBPATH/$BASE/RPMS/ - [[ -n "$PUBLISH_SRPMS" ]] && rsync --archive --delete $VERBOSE /vservers/$BASE/build/SRPMS/ $WEBPATH/$BASE/SRPMS/ + set +e + webpublish rm -rf $WEBPATH/$BASE + webpublish mkdir -p $WEBPATH/$BASE/{RPMS,SRPMS} + webpublish_rsync_dir /vservers/$BASE/build/RPMS/ $WEBPATH/$BASE/RPMS/ + [[ -n "$PUBLISH_SRPMS" ]] && webpublish_rsync_dir /vservers/$BASE/build/SRPMS/ $WEBPATH/$BASE/SRPMS/ # publish myplc-release if this exists release=/vservers/$BASE/build/myplc-release - [ -f $release ] && rsync $VERBOSE $release $WEBPATH/$BASE + [ -f $release ] && webpublish_rsync_file $release $WEBPATH/$BASE + set -e # create yum repo and sign packages. if [ -n "$SIGNYUMREPO" ] ; then - sign_node_packages + # this script does not yet support signing on a remote (webhost) repo + sign_here=$(hostname) ; sign_web=$(webpublish hostname) + if [ "$hostname" = "$sign_here" ] ; then + sign_node_packages + else + echo "$COMMAND does not support signing on a remote yum repo" + echo "you might want to turn off the -y option, or run this on the web server box itself" + exit 1 + fi fi if [ -n "$DO_TEST" ] ; then