X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Fnightly-build.sh;h=1bb5a5c80af290743907c00e97e8cc50f0e7ede5;hb=d62d785d0fab260cb684f59dab05d01bf730912d;hp=07fb28fd4900781eab259e92b844082911387ab6;hpb=dcd994588a170e5d7dc2d0d333289c1aca4d2093;p=infrastructure.git diff --git a/scripts/nightly-build.sh b/scripts/nightly-build.sh index 07fb28f..1bb5a5c 100755 --- a/scripts/nightly-build.sh +++ b/scripts/nightly-build.sh @@ -8,171 +8,211 @@ ROOT=/build CHROOTBINDIR=/root/bin # default values, tunable with command-line options -CVSROOT=":pserver:anon@cvs.planet-lab.org:/cvs" +SVNPATH="svn+ssh://build@svn.one-lab.org/svn/build/trunk" DISTRO=onelab MAILTO="onelab-build@one-lab.org" TAGSFILE=onelab-tags.mk +TESTBUILDURL="http://build.one-lab.org/" +TESTBOXSSH=root@onelab-test.inria.fr +TESTSVNPATH="svn+ssh://build@svn.one-lab.org/svn/new_plc_api/trunk/plctest" +TESTSCRIPT=TestMain.py + #################### # plc chroot runs in UTC DATE=$(date -u +'%Y.%m.%d') ### in the root context function do_chroot () { - chroot /plc/devel/root su - build </dev/null ; do - [ -z ${i} ] && BASE=${BASE}. - i=$((${i}+1)) - if [ $i -gt 100 ] ; then - echo "$0: Failed to create release directory `pwd`/${BASE}${i}" - exit 1 - fi - done - BASE=${BASE}${i} + i= + while ! mkdir ${BASE}${i} 2>/dev/null ; do + [ -z ${i} ] && BASE=${BASE}. + i=$((${i}+1)) + if [ $i -gt 100 ] ; then + echo "$0: Failed to create release directory `pwd`/${BASE}${i}" + exit 1 + fi + done + BASE=${BASE}${i} } function use_base () { - [ ! -d $BASE ] && mkdir $BASE - if [ ! -d $BASE ] ; then - echo $COMMAND failed to create base $BASE - exit 1 - fi + [ ! -d $BASE ] && mkdir $BASE + if [ ! -d $BASE ] ; then + echo $COMMAND failed to create base $BASE + exit 1 + fi } function build () { - trap failure ERR INT - set -x + set -x + set -e + trap failure ERR INT - echo -n "============================== Starting $COMMAND on " - date + echo -n "============================== Starting $COMMAND:build on " + date - cd $ROOT - cvs -d $CVSROOT co -d $BASE build + cd $ROOT + svn co $SVNPATH $BASE # if TAGSTAG specified : update TAGSFILE with this tag - if [ -n "$TAGSTAG" ] ; then - cd $BASE - cvs up -r $TAGSTAG $TAGSFILE - cd - - fi + if [ -n "$TAGSTAG" ] ; then + cd $BASE + svn up -r $TAGSTAG $TAGSFILE + cd - + fi - show_env + show_env - echo "Running make IN build $(pwd)" - make ${MAKEOPTS[@]} TAGSFILE=${TAGSFILE} PLDISTRO=${DISTRO} ${MAKEVARS[@]} -C $BASE $MAKETARGETS + echo "Running make IN build $(pwd)" + make stage1=true ${MAKEOPTS[@]} TAGSFILE=${TAGSFILE} PLDISTRO=${DISTRO} ${MAKEVARS[@]} -C $BASE $MAKETARGETS + make ${MAKEOPTS[@]} TAGSFILE=${TAGSFILE} PLDISTRO=${DISTRO} ${MAKEVARS[@]} -C $BASE $MAKETARGETS +} - # only if successful - rm -f latest - ln -s $BASE latest +function runtest () { + set -x + set -e + trap failure ERR INT - success + echo -n "============================== Starting $COMMAND:runtest on " + date + + ### compute URL to the myplc package + build=$1; shift + buildname=$(basename $build) + cd $build + rpm=$(find RPMS -name myplc\*.rpm ) + url=${TESTBUILDURL}${DISTRO}/${buildname}/${rpm} + + ### checkout the test material + svn co ${TESTSVNPATH} plctest + # compute test directory name on test box + testdir=plctest-${buildname} + # rsync/push test material onto the test box + ssh ${TESTBOXSSH} mkdir -p ${testdir} + rsync -a -v plctest/ ${TESTBOXSSH}:${testdir} + # invoke test on testbox + ssh ${TESTBOXSSH} python -u ${testdir}/${TESTSCRIPT} ${url} + if [ "$?" != 0 ] ; then + failure + fi } function show_env () { - echo ROOT=$ROOT - echo BASE=$BASE - echo DISTRO=$DISTRO - echo MAKEVARS="${MAKEVARS[@]}" - echo MAKEOPTS="${MAKEOPTS[@]}" - echo TAGSFILE=$TAGSFILE - echo "XXXXXXXXXXXXXXXXXXXX Contents of $TAGSFILE" - cat $BASE/$TAGSFILE - echo "XXXXXXXXXXXXXXXXXXXX end contents" + echo ROOT=$ROOT + echo DISTRO=$DISTRO + echo BASE=$BASE + echo SVNPATH=$SVNPATH + echo MAKEVARS="${MAKEVARS[@]}" + echo MAKEOPTS="${MAKEOPTS[@]}" + echo TAGSFILE="$TAGSFILE" + echo TAGSTAG="$TAGSTAG" + echo "XXXXXXXXXXXXXXXXXXXX Contents of tags definition file $TAGSFILE" + cat $BASE/$TAGSFILE + echo "XXXXXXXXXXXXXXXXXXXX end tags definition" } function usage () { - echo "Usage: $COMMAND [option] make-targets" - echo "This is revision $REVISION" - echo "Supported options" - echo " -v verbose" - echo " -b BASE - may include %d then is replaced with current date" - echo " -u : uses directory given as BASE as is, even if already exists" - echo " -e : exits (does nothing) if BASE already exists" - echo " -c CVSROOT" - echo " -d DISTRO" - echo " -t TAGSFILE" - echo " -r TAGSTAG - a tag that refers to TAGSFILE - defaults to HEAD" - echo " -m MAILTO" - echo " -s MAKEVAR=value - spaces in value are not supported" - echo " -n passed to make" - exit 1 + echo "Usage: $COMMAND [option] make-targets" + echo "This is revision $REVISION" + echo "Supported options" + echo " -b BASE - may include @, then replaced with current date" + echo " -u : uses directory given as BASE as is, even if already exists" + echo " -d DISTRO" + echo " -t TAGSFILE" + echo " -r TAGSTAG - a tag that refers to TAGSFILE - defaults to HEAD" + echo " -s MAKEVAR=value - spaces in value are not supported" + echo " -n dry-run : -n passed to make - no mail sent" + echo " -m MAILTO" + echo " -s SVNPATH" + echo " -B : run build only" + echo " -T : run test only" + exit 1 } function main () { - if [ -d /plc/devel/data ] ; then - do_chroot "$@" - else - MAKEVARS=() - MAKEOPTS=() - while getopts "vc:t:r:m:d:b:s:uenh" opt ; do - case $opt in - v) set -x ;; - c) CVSROOT=$OPTARG ;; - t) TAGSFILE=$OPTARG ;; - r) TAGSTAG=$OPTARG ;; - m) MAILTO=$OPTARG ;; - d) DISTRO=$OPTARG ;; - b) BASE=$OPTARG ;; - u) USEOLD=true ;; - e) EXITIFOLD=true ;; - s) MAKEVARS=(${MAKEVARS[@]} $OPTARG) ;; - n) MAILTO="" ; MAKEOPTS=(${MAKEOPTS[@]} -n) ;; - h|*) usage ;; - esac - done - - ROOT=$ROOT/$DISTRO - - shift $(($OPTIND - 1)) - - MAKETARGETS="$@" - - cd $ROOT + if [ -d /plc/devel/data ] ; then + do_chroot "$@" + else + MAKEVARS=() + MAKEOPTS=() + DO_BUILD=true + DO_TEST=true + while getopts "b:ud:t:r:s:nm:s:BTh" opt ; do + case $opt in + b) BASE=$OPTARG ;; + u) USEOLD=true ;; + d) DISTRO=$OPTARG ;; + t) TAGSFILE=$OPTARG ;; + r) TAGSTAG=$OPTARG ;; + s) MAKEVARS=(${MAKEVARS[@]} $OPTARG) ;; + n) MAILTO="" ; MAKEOPTS=(${MAKEOPTS[@]} -n) ;; + m) MAILTO=$OPTARG ;; + s) SVNPATH=$OPTARG ;; + B) DO_TEST= ;; + T) DO_BUILD= ; USEOLD=true ;; + h|*) usage ;; + esac + done + + shift $(($OPTIND - 1)) + + ROOT=$ROOT/$DISTRO + cd $ROOT + + MAKETARGETS="$@" + ### set BASE from DISTRO, if unspecified - [ -z "$BASE" ] && BASE=${DISTRO} - - BASE=$(echo ${BASE} | sed -e "s,%d,${DATE},g") - - if [ -n "$EXITIFOLD" -a -d "$BASE" ] ; then - echo "$COMMAND: -e : exits on existing base directory $BASE" - BUILD=$ROOT/$BASE - failure - exit 1 - fi + [ -z "$BASE" ] && BASE=${DISTRO} + BASE=$(echo ${BASE} | sed -e "s,@,${DATE},g") - if [ -n "$USEOLD" ] ; then - use_base $BASE - else - BASE=${BASE}--${DATE} - create_base + if [ -n "$USEOLD" ] ; then + use_base $BASE + else + create_base + fi + BUILD=$ROOT/$BASE + + if [ -n "$DO_BUILD" ] ; then + build >> ${BUILD}/log-build.txt 2>&1 + fi + + if [ -n "$DO_TEST" ] ; then + runtest ${BUILD} >> ${BUILD}/log-build.txt 2>&1 + fi + + success >> ${BUILD}/log-build.txt 2>&1 + fi - BUILD=$ROOT/$BASE - - build >> ${BUILD}/log-build.txt 2>&1 - fi } ##########