X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vbuild-nightly.sh;h=8e86a3da00e85a1629d836027eb3303b7e38c69e;hb=79402a67035dc5bff06925be82dd273094125cec;hp=746075f1f1900e4da4330ecce537ea3298d582e3;hpb=caf550a3f4d57e8fbf0545743ee76fcd04ae03b7;p=build.git diff --git a/vbuild-nightly.sh b/vbuild-nightly.sh index 746075f1..8e86a3da 100755 --- a/vbuild-nightly.sh +++ b/vbuild-nightly.sh @@ -5,47 +5,125 @@ COMMANDPATH=$0 COMMAND=$(basename $0) # default values, tunable with command-line options -DEFAULT_FCDISTRO=fc6 +DEFAULT_FCDISTRO=f8 DEFAULT_PLDISTRO=planetlab -DEFAULT_BASE="@DATE@--@PLDISTRO@-@FCDISTRO@" +DEFAULT_PERSONALITY=linux32 +DEFAULT_BASE="@DATE@--@PLDISTRO@-@FCDISTRO@-@PERSONALITY@" DEFAULT_SVNPATH="http://svn.planet-lab.org/svn/build/trunk" - -DEFAULT_MAILTO_onelab="onelab-build@one-lab.org" -# tmp - send all mails to onelab -#DEFAULT_MAILTO_planetlab="devel@planet-lab.org" -DEFAULT_MAILTO_planetlab=$DEFAULT_MAILTO_onelab +DEFAULT_TESTCONFIG="default" +DEFAULT_IFNAME=eth0 # web publishing results DEFAULT_WEBPATH="/build/@PLDISTRO@/" +# default gpg path used in signing yum repo +DEFAULT_GPGPATH="/etc/planetlab" +# default email to use in gpg secring +DEFAULT_GPGUID="root@$( /bin/hostname )" + # for the test part TESTBUILDURL="http://build.one-lab.org/" -TESTBOX=onelab-test.inria.fr -TESTBOXSSH=root@onelab-test.inria.fr -TESTSVNPATH="http://svn.planet-lab.org/svn/tests/system" -TESTSCRIPT=TestMain.py +TESTBOXSSH=root@testbox.one-lab.org #################### # assuming vserver runs in UTC -DATE=$(date -u +'%Y.%m.%d') +DATE=$(date +'%Y.%m.%d') + +# temporary - wrap a quick summary of suspicious stuff +# this is to focus on installation that go wrong +# use with care, a *lot* of other things can go bad as well +function summary () { + from=$1; shift + echo "******************** BEG SUMMARY" + python - $from <>>',line, + # an 'installing' line with messages afterwards : needs to be echoed + elif m_installing_err.match(line): + (installing,error)=m_installing_err.match(line).groups() + print '>>>',installing + print '>>>',error + echo=True + # closing an 'installing' section + elif m_installing_end.match(line): + echo=False + # any 'installing' line + elif m_installing_any.match(line): + if echo: + installing=m_installing_any.match(line).group(1) + print '>>>',installing + echo=False + # print lines when echo is true + else: + if echo: print '>>>',line, + f.close() + except: + print 'Failed to analyze',filename + +for arg in sys.argv[1:]: + summary(arg) +EOF + echo "******************** END SUMMARY" +} + # Notify recipient of failure or success, manage various stamps function failure() { set -x + WEBLOG=${WEBPATH}/${BASE}.log.txt + mkdir -p ${WEBPATH} + cp $LOG ${WEBLOG} + summary $LOG >> ${WEBLOG} + (echo -n "============================== $COMMAND: failure at " ; date ; tail -c 30k $WEBLOG) > ${WEBLOG}.ko if [ -n "$MAILTO" ] ; then - tail -c 8k $LOG | mail -s "Failures for build ${BASE}" $MAILTO + tail -c 30k ${WEBLOG} | mail -s "Failures for build ${BASE}" $MAILTO fi - cp $LOG ${WEBPATH}/${BASE}.log.txt - (echo -n "============================== $COMMAND: failure at" ; date ; tail -c 20k $LOG) > ${WEBPATH}/${BASE}.bko.txt exit 1 } function success () { set -x + WEBLOG=${WEBPATH}/${BASE}.log.txt + mkdir -p ${WEBPATH} + cp $LOG ${WEBLOG} + summary $LOG >> ${WEBLOG} + if [ -n "$DO_TEST" ] ; then + echo "Successfully built and tested - see testlogs for details" > ${WEBLOG}.pass + rm -f ${WEBLOG}.ok + else + echo "Successfully built"> ${WEBLOG}.ok + fi if [ -n "$MAILTO" ] ; then - (echo "http://build.one-lab.org/$PLDISTRO/$BASE" ; echo "Completed on $(date)" ) | mail -s "Successfull build for ${BASE}" $MAILTO + (echo "$PLDISTRO ($BASE) build for $FCDISTRO completed on $(date)" ) | mail -s "Successful build for ${BASE}" $MAILTO fi - cp $LOG ${WEBPATH}/${BASE}.log.txt - touch ${WEBPATH}/${BASE}.bok.txt exit 0 } @@ -57,24 +135,31 @@ function build () { echo -n "============================== Starting $COMMAND:build on " date - cd / - + cd /build # if TAGSRELEASE specified : update PLDISTROTAGS with this tag if [ -n "$TAGSRELEASE" ] ; then - cd build svn up -r $TAGSRELEASE $PLDISTROTAGS - cd - fi show_env echo "Running make IN $(pwd)" - make stage1=true "${MAKEOPTS[@]}" PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${PLDISTRO} "${MAKEVARS[@]}" -C /build - # in case we use an older build that does not know about versions - set +e - make "${MAKEOPTS[@]}" PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${PLDISTRO} "${MAKEVARS[@]}" -C /build versions - set -e - make "${MAKEOPTS[@]}" PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${PLDISTRO} "${MAKEVARS[@]}" -C /build $MAKETARGETS + + # stuff our own variable settings + MAKEVARS=("PLDISTRO=${PLDISTRO}" "${MAKEVARS[@]}") + MAKEVARS=("PLDISTROTAGS=${PLDISTROTAGS}" "${MAKEVARS[@]}") + MAKEVARS=("NIGHTLY_BASE=${BASE}" "${MAKEVARS[@]}") + MAKEVARS=("NIGHTLY_PERSONALITY=${PERSONALITY}" "${MAKEVARS[@]}") + MAKEVARS=("build-SVNPATH=${SVNPATH}" "${MAKEVARS[@]}") + + # stage1 + make -C /build $DRY_RUN "${MAKEVARS[@]}" stage1=true + # versions + make -C /build $DRY_RUN "${MAKEVARS[@]}" versions + # store tests_svnpath + make -C /build $DRY_RUN "${MAKEVARS[@]}" stage1=true tests_svnpath + # actual stuff + make -C /build $DRY_RUN "${MAKEVARS[@]}" $MAKETARGETS } @@ -86,42 +171,72 @@ function runtest () { trap failure ERR INT echo -n "============================== Starting $COMMAND:runtest on $(date)" - here=$(pwd) - ### the URL to the myplc package - cd /vservers/$BASE/build/RPMS/i386 - rpm=$(ls myplc-[0-9]*.rpm) - if [ ${#rpm[@]} != 1 ] ; then - echo "$COMMAND: Cannot locate rpm for testing" + # where to find TESTS_SVNPATH + stamp=/vservers/$BASE/build/tests_svnpath + if [ ! -f $stamp ] ; then + echo "$COMMAND: Cannot figure TESTS_SVNPATH from missing $stamp" failure exit 1 fi - url=${TESTBUILDURL}${PLDISTRO}/${BASE}/RPMS/i386/${rpm} + TESTS_SVNPATH=$(cat $stamp) + # xxx - Thierry - need to rework the test framework in tests/system so it can work + # with the entire tests/ module checked out, rather than only tests/system/ + # ugly workaround for now + SYSTEM_SVNPATH=${TESTS_SVNPATH}/system + + ### the URL to the RPMS/ location + url="" + for a in i386 x86_64; do + archdir=/vservers/$BASE/build/RPMS/$a + if [ -d $archdir ] ; then + url=$(echo $archdir | sed -e "s,/vservers/$BASE/build,${TESTBUILDURL}${PLDISTRO}/${BASE},") + break + fi + done - # checkout the system test (formerly known as plctest) - cd /build - svn export $TESTSVNPATH system-test - - # compute test directory name on test box - testdir=system-test-${BASE} - # rsync/push test material onto the test box - ssh ${TESTBOXSSH} mkdir -p ${testdir} - rsync -a -v system-test/ ${TESTBOXSSH}:${testdir} - # invoke test on testbox - ssh ${TESTBOXSSH} python -u ${testdir}/${TESTSCRIPT} ${url} - #invoke make install from build to the testbox - # looks suspicious : we'd need this *during* myplc run, not at the end - # in addition we are not in the vserver here so running make can have weird effects - # make install PLCHOST=${TESTBOX} - - if [ "$?" != 0 ] ; then + if [ -z "$url" ] ; then + echo "$COMMAND: Cannot locate arch URL for testing" + failure + exit 1 + fi + + # test directory name on test box + testdir=${BASE} + # clean it + ssh -n ${TESTBOXSSH} rm -rf ${testdir} + # check it out + ssh -n ${TESTBOXSSH} svn co ${SYSTEM_SVNPATH} ${testdir} + # check out the entire tests/ module (with system/ duplicated) as a subdir - see xxx above + ssh -n ${TESTBOXSSH} svn co ${TESTS_SVNPATH} ${testdir}/tests + # invoke test on testbox - pass url and build url - so the tests can use vtest-init-vserver.sh + configs="" + for config in ${TESTCONFIG} ; do + configs="$configs --config $config" + done + + # need to proceed despite of set -e + success=true + ssh 2>&1 -n ${TESTBOXSSH} ${testdir}/runtest --build ${SVNPATH} --url ${url} $configs --all || success= + + # gather logs in the vserver + mkdir -p /vservers/$BASE/build/testlogs + ssh 2>&1 -n ${TESTBOXSSH} tar -C ${testdir}/logs -cf - . | tar -C /vservers/$BASE/build/testlogs -xf - || true + # push them to the build web + rsync --archive --delete /vservers/$BASE/build/testlogs/ $WEBPATH/$BASE/testlogs/ + chmod -R a+r $WEBPATH/$BASE/testlogs/ + + if [ -z "$success" ] ; then failure fi - cd $here echo -n "============================== End $COMMAND:runtest on $(date)" } +function in_root_context () { + rpm -q util-vserver > /dev/null +} + function show_env () { set +x echo FCDISTRO=$FCDISTRO @@ -129,12 +244,12 @@ function show_env () { echo BASE=$BASE echo SVNPATH=$SVNPATH echo MAKEVARS="${MAKEVARS[@]}" - echo MAKEOPTS="${MAKEOPTS[@]}" + echo DRY_RUN="$DRY_RUN" echo PLDISTROTAGS="$PLDISTROTAGS" echo TAGSRELEASE="$TAGSRELEASE" echo -n "(might be unexpanded)" echo WEBPATH="$WEBPATH" - if [ -d /vservers ] ; then + if in_root_context ; then echo PLDISTROTAGS="$PLDISTROTAGS" else echo "XXXXXXXXXXXXXXXXXXXX Contents of tags definition file /build/$PLDISTROTAGS" @@ -148,21 +263,28 @@ function usage () { echo "Usage: $COMMAND [option] make-targets" echo "This is $REVISION" echo "Supported options" - echo " -n dry-run : -n passed to make - vserver gets created though - no mail sent" - echo " -f FCDISTRO - defaults to $DEFAULT_FCDISTRO" - echo " -d PLDISTRO - defaults to $DEFAULT_PLDISTRO" - echo " -b BASE - defaults to $DEFAULT_BASE" + echo " -f fcdistro - defaults to $DEFAULT_FCDISTRO" + echo " -d pldistro - defaults to $DEFAULT_PLDISTRO" + echo " -p personality - defaults to $DEFAULT_PERSONALITY" + echo " -b base - defaults to $DEFAULT_BASE" echo " @NAME@ replaced as appropriate" - echo " -t PLDISTROTAGS - defaults to \${PLDISTRO}-tags.mk" - echo " -r TAGSRELEASE - a release number that refers to PLDISTROTAGS - defaults to HEAD" - echo " -s SVNPATH - where to fetch the build module" - echo " -o : overwrite - re-run in base directory, do not create vserver" - echo " -m MAILTO" - echo " -a MAKEVAR=value - space in values are not supported" - echo " -w WEBPATH - defaults to $DEFAULT_WEBPATH" + echo " -t pldistrotags - defaults to \${PLDISTRO}-tags.mk" + echo " -r tagsrelease - a release number that refers to PLDISTROTAGS - defaults to HEAD" + echo " -s svnpath - where to fetch the build module" + echo " -c testconfig - defaults to $DEFAULT_TESTCONFIG" + echo " -w webpath - defaults to $DEFAULT_WEBPATH" + echo " -y create (and sign) yum repo in webpath" + echo " -g path to gpg secring used to sign rpms. Defaults to $DEFAULT_GPGPATH" + echo " -u gpg email used in secring. Defaults to $DEFAULT_GPGUID" + echo " -m mailto - no default" + echo " -O : overwrite - re-run in base directory, do not re-create vserver" echo " -B : run build only" echo " -T : run test only" + echo " -n dry-run : -n passed to make - vserver gets created though - no mail sent" echo " -v : be verbose" + echo " -7 : uses weekday-@FCDISTRO@ as base" + echo " -a makevar=value - space in values are not supported" + echo " -i ifname - defaults to $DEFAULT_IFNAME - used to determine local IP" exit 1 } @@ -170,59 +292,66 @@ function main () { set -e - # preserve arguments for passing them again later - declare -a argv - for arg in "$@"; do argv=(${argv[@]} "$arg") ; done - # parse arguments MAKEVARS=() - MAKEOPTS=() + DRY_RUN= DO_BUILD=true DO_TEST=true - while getopts "nf:d:b:t:r:s:om:a:w:BTvh" opt ; do + while getopts "f:d:p:b:t:r:s:x:c:w:g:u:m:OBTnyv7a:i:" opt ; do case $opt in - n) DRY_RUN="true" ; MAKEOPTS=(${MAKEOPTS[@]} -n) ;; f) FCDISTRO=$OPTARG ;; d) PLDISTRO=$OPTARG ;; + p) PERSONALITY=$OPTARG ;; b) BASE=$OPTARG ;; t) PLDISTROTAGS=$OPTARG ;; r) TAGSRELEASE=$OPTARG ;; s) SVNPATH=$OPTARG ;; - o) USEOLD=true ;; - m) MAILTO=$OPTARG ;; - a) MAKEVARS=(${MAKEVARS[@]} "$OPTARG") ;; + c) TESTCONFIG="$TESTCONFIG $OPTARG" ;; w) WEBPATH=$OPTARG ;; + y) MKYUMREPO=$OPTARG;; + g) GPGPATH=$OPTARG;; + u) GPGUID=$OPTARG;; + m) MAILTO=$OPTARG ;; + O) OVERWRITEMODE=true ;; B) DO_TEST= ;; - T) DO_BUILD= ; USEOLD=true ;; + T) DO_BUILD= ; OVERWRITEMODE=true ;; + n) DRY_RUN="-n" ;; v) set -x ;; + 7) BASE="$(date +%a|tr A-Z a-z)-@FCDISTRO@" ;; + a) MAKEVARS=(${MAKEVARS[@]} "$OPTARG") ;; + i) IFNAME=$OPTARG ;; h|*) usage ;; esac done - shift $(($OPTIND - 1)) + # preserve options for passing them again later, together with expanded base + declare -a options + toshift=$(($OPTIND - 1)) + arg=1; while [ $arg -le $toshift ] ; do options=(${options[@]} "$1") ; shift; arg=$(($arg+1)) ; done + MAKETARGETS="$@" # set defaults [ -z "$FCDISTRO" ] && FCDISTRO=$DEFAULT_FCDISTRO [ -z "$PLDISTRO" ] && PLDISTRO=$DEFAULT_PLDISTRO + [ -z "$PERSONALITY" ] && PERSONALITY=$DEFAULT_PERSONALITY [ -z "$PLDISTROTAGS" ] && PLDISTROTAGS="${PLDISTRO}-tags.mk" [ -z "$BASE" ] && BASE="$DEFAULT_BASE" [ -z "$WEBPATH" ] && WEBPATH="$DEFAULT_WEBPATH" + [ -z "$GPGPATH" ] && GPGPATH="$DEFAULT_GPGPATH" + [ -z "$GPGUID" ] && GPGUID="$DEFAULT_GPGUID" + [ -z "$IFNAME" ] && IFNAME="$DEFAULT_IFNAME" [ -z "$SVNPATH" ] && SVNPATH="$DEFAULT_SVNPATH" - # - if [ "$PLDISTRO" = "onelab" ] ; then - [ -z "$MAILTO" ] && MAILTO="$DEFAULT_MAILTO_onelab" - else - [ -z "$MAILTO" ] && MAILTO="$DEFAULT_MAILTO_planetlab" - fi + [ -z "$TESTCONFIG" ] && TESTCONFIG="$DEFAULT_TESTCONFIG" + [ -n "$DRY_RUN" ] && MAILTO="" ### set BASE from DISTRO, if unspecified - sedargs="-e s,@DATE@,${DATE},g -e s,@FCDISTRO@,${FCDISTRO},g -e s,@PLDISTRO@,${PLDISTRO},g" + sedargs="-e s,@DATE@,${DATE},g -e s,@FCDISTRO@,${FCDISTRO},g -e s,@PLDISTRO@,${PLDISTRO},g -e s,@PERSONALITY@,${PERSONALITY},g" BASE=$(echo ${BASE} | sed $sedargs) WEBPATH=$(echo ${WEBPATH} | sed $sedargs) - if [ ! -d /vservers ] ; then + if ! in_root_context ; then # in the vserver echo "==================== Within vserver BEG $(date)" build @@ -235,7 +364,7 @@ function main () { # (*) copy this command in the vserver # (*) invoke it - if [ -n "$USEOLD" ] ; then + if [ -n "$OVERWRITEMODE" ] ; then ### Re-use a vserver (finish an unfinished build..) if [ ! -d /vservers/${BASE} ] ; then echo $COMMAND : cannot find vserver $BASE @@ -248,6 +377,8 @@ function main () { set -x echo "XXXXXXXXXX $COMMAND: using existing vserver $BASE" $(date) show_env + # start in case e.g. we just rebooted + vserver ${BASE} start || : # update build vserver ${BASE} exec svn update /build else @@ -277,7 +408,7 @@ function main () { svn export $SVNPATH $tmpdir # Create vserver cd $tmpdir - ./vbuild-init-vserver.sh ${BASE} ${FCDISTRO} ${PLDISTRO} + ./vbuild-init-vserver.sh -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} -i ${IFNAME} ${BASE} # cleanup cd - rm -rf $tmpdir @@ -288,9 +419,9 @@ function main () { # The log inside the vserver contains everything LOG2=/vservers/${BASE}/log.txt - (echo "==================== Transcript of vserver creation -- BEG $(date)" ; \ + (echo "==================== BEG VSERVER Transcript of vserver creation" ; \ cat $LOG ; \ - echo "==================== Transcript of vserver creation -- END $(date)" ; \ + echo "==================== END VSERVER Transcript of vserver creation" ; \ echo "xxxxxxxxxx Messing with logs, symlinking $LOG2 to $LOG" ) >> $LOG2 ### not too nice : nuke the former log, symlink it to the new one rm $LOG; ln -s $LOG2 $LOG @@ -303,14 +434,87 @@ function main () { cp $COMMANDPATH /vservers/${BASE}/build/ # invoke this command in the vserver for building (-T) - vserver ${BASE} exec /build/$COMMAND "${argv[@]}" -b "${BASE}" + vserver ${BASE} exec chmod +x /build/$COMMAND + vserver ${BASE} exec /build/$COMMAND "${options[@]}" -b "${BASE}" $MAKETARGETS fi # publish to the web so runtest can find them rm -rf $WEBPATH/$BASE ; mkdir -p $WEBPATH/$BASE/{RPMS,SRPMS} rsync --archive --delete --verbose /vservers/$BASE/build/RPMS/ $WEBPATH/$BASE/RPMS/ rsync --archive --delete --verbose /vservers/$BASE/build/SRPMS/ $WEBPATH/$BASE/SRPMS/ - + # publish myplc-release + rsync --verbose /vservers/$BASE/build/myplc-release $WEBPATH/$BASE + + # create yum repo and sign packages. + if [ -n $MKYUMREPO ] ; then + echo "Signing signing node packages" + + ### availability of repo indexing tools + # old one - might be needed for old-style nodes + type -p yum-arch > /dev/null && have_yum_arch="true" + # new one + type -p createrepo > /dev/null && have_createrepo="true" + + repository=$WEBPATH/$BASE/RPMS/ + # the rpms that need signing + new_rpms= + # and the corresponding stamps + new_stamps= + # is there a need to refresh yum metadata + need_yum_arch= + need_createrepo= + + # right after installation, no package is present + # but we still need to create index + [ -n "$have_yum_arch" -a ! -f $repository/headers/header.info ] && need_yum_arch=true + [ -n "$have_createrepo" -a ! -f $repository/repodata/repomd.xml ] && need_createrepo=true + + for package in $(find $repository/ -name '*.rpm') ; do + stamp=$repository/signed-stamps/$(basename $package).signed + # If package is newer than signature stamp + if [ $package -nt $stamp ] ; then + new_rpms="$new_rpms $package" + new_stamps="$new_stamps $stamp" + fi + # Or than yum-arch headers + [ -n "$have_yum_arch" ] && [ $package -nt $repository/headers/header.info ] && need_yum_arch=true + # Or than createrepo database + [ -n "$have_createrepo" ] && [ $package -nt $repository/repodata/repomd.xml ] && need_createrepo=true + done + + if [ -n "$new_rpms" ] ; then + # Create a stamp once the package gets signed + mkdir $repository/signed-stamps 2> /dev/null + + # Sign RPMS. setsid detaches rpm from the terminal, + # allowing the (hopefully blank) GPG password to be + # entered from stdin instead of /dev/tty. + echo | setsid rpm \ + --define "_signature gpg" \ + --define "_gpg_path $GPGPATH" \ + --define "_gpg_name $GPGUID" \ + --resign $new_rpms && touch $new_stamps + fi + + # Update repository index / yum metadata. + + if [ -n "$need_yum_arch" ] ; then + # yum-arch sometimes leaves behind + # .oldheaders and .olddata directories accidentally. + rm -rf $repository/{.oldheaders,.olddata} + yum-arch $repository + fi + + if [ -n "$need_createrepo" ] ; then + if [ -f $repository/yumgroups.xml ] ; then + createrepo --quiet -g yumgroups.xml $repository + else + createrepo --quiet $repository + fi + fi + + fi + if [ -n "$DO_TEST" ] ; then runtest fi