only append info to files
[build.git] / vbuild-nightly.sh
index 4193045..840a909 100755 (executable)
@@ -5,16 +5,12 @@ COMMANDPATH=$0
 COMMAND=$(basename $0)
 
 # default values, tunable with command-line options
-DEFAULT_FCDISTRO=fc6
+DEFAULT_FCDISTRO=f7
 DEFAULT_PLDISTRO=planetlab
 DEFAULT_PERSONALITY=linux32
 DEFAULT_BASE="@DATE@--@PLDISTRO@-@FCDISTRO@-@PERSONALITY@"
 DEFAULT_SVNPATH="http://svn.planet-lab.org/svn/build/trunk"
 
-# NOTE: do not think we want to put email addresses into scripts
-# that can be harvested by spambots. --mef
-DEFAULT_MAILTO="onelab-build@one-lab.org"
-
 # web publishing results
 DEFAULT_WEBPATH="/build/@PLDISTRO@/"
 
@@ -23,7 +19,6 @@ 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/trunk/system/"
-TESTSCRIPT=TestMain.py
 ####################
 # assuming vserver runs in UTC
 DATE=$(date +'%Y.%m.%d')
@@ -34,7 +29,63 @@ DATE=$(date +'%Y.%m.%d')
 function summary () {
     from=$1; shift
     echo "******************** BEG SUMMARY" 
-    tr -d '\r' < $from | egrep 'BEG RPM|not installed|Installing:.*([eE]rror|[wW]arning)' 
+    python - $from <<EOF
+#!/usr/bin/env python
+# read a full log and tries to extract the interesting stuff
+
+import sys,re
+m_show_line=re.compile(".* BEG (RPM|VSERVER).*|.*'boot'.*|\* .*|.*is not installed.*")
+m_installing_any=re.compile('\r  (Installing:[^\]]*]) ')
+m_installing_err=re.compile('\r  (Installing:[^\]]*])(..+)')
+m_installing_end=re.compile('Installed:.*')
+m_installing_doc1=re.compile("(.*)install-info: No such file or directory for /usr/share/info/\S+(.*)")
+m_installing_doc2=re.compile("(.*)grep: /usr/share/info/dir: No such file or directory(.*)")
+
+def summary (filename):
+
+    try:
+        if filename=="-":
+            filename="stdin"
+            f=sys.stdin
+        else:
+            f=open(filename)
+        echo=False
+        for line in f.xreadlines():
+            # first off : discard warnings related to doc
+            if m_installing_doc1.match(line):
+                (begin,end)=m_installing_doc1.match(line).groups()
+                line=begin+end
+            if m_installing_doc2.match(line):
+                (begin,end)=m_installing_doc2.match(line).groups()
+                line=begin+end
+            # unconditionnally show these lines
+            if m_show_line.match(line):
+                print '>>>',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" 
 }
 
@@ -72,24 +123,21 @@ 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
+    # stage1
+    make -C /build "${MAKEOPTS[@]}" PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${PLDISTRO} "${MAKEVARS[@]}" stage1=true 
+    # versions
+    make -C /build "${MAKEOPTS[@]}" PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${PLDISTRO} "${MAKEVARS[@]}" NIGHTLY_BASE=${BASE} versions
+    # actual stuff
+    make -C /build "${MAKEOPTS[@]}" PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${PLDISTRO} "${MAKEVARS[@]}" $MAKETARGETS
 
 }
 
@@ -101,11 +149,9 @@ 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)
+    rpm=$( (cd /vservers/$BASE/build/RPMS/i386 ; ls myplc-[0-9]*.rpm) )
     if [ ${#rpm[@]} != 1 ] ; then
        echo "$COMMAND: Cannot locate rpm for testing"
        failure
@@ -113,34 +159,20 @@ function runtest () {
     fi
     url=${TESTBUILDURL}${PLDISTRO}/${BASE}/RPMS/i386/${rpm}
 
-    # checkout the system test (formerly known as plctest)
-    cd /vservers/${BASE}/build
-    rm -rf TESTS
-    svn export $TESTSVNPATH TESTS
-    # dont trust retcod
-    if [ ! -d TESTS ] ; then 
-       echo "$COMMAND: could not svn export $SVNPATH - check url"
-       exit 1
-    fi
-
-  # compute test directory name on test box
-    testdir=plctest-${BASE}
-  # rsync/push test material onto the test box - clean first
+    # compute test directory name on test box
+    testdir=test-${BASE}
+    # clean it
     ssh ${TESTBOXSSH} rm -rf ${testdir}
-    ssh ${TESTBOXSSH} mkdir -p ${testdir}
-    rsync -a -v TESTS/ ${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}
+    # check it out
+    ssh ${TESTBOXSSH} svn co ${TESTSVNPATH} ${testdir}
+    # invoke test on testbox - pass url and build url - so the tests can use myplc-init-vserver.sh
+    ssh 2>&1 ${TESTBOXSSH} python -u ${testdir}/runtest --build ${SVNPATH} --url ${url} --all
+    # still missing - need to populate /var/www/html/install-rpms on the myplc
        
     if [ "$?" != 0 ] ; then
        failure
     fi
     
-    cd $here
     echo -n "============================== End $COMMAND:runtest on $(date)"
 }
 
@@ -171,20 +203,22 @@ function usage () {
     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 " -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 " -m mailto"
+    echo " -a makevar=value - space in values are not supported"
+    echo " -w webpath - defaults to $DEFAULT_WEBPATH"
     echo " -B : run build only"
     echo " -T : run test only"
     echo " -v : be verbose"
+    echo " -7 : uses weekday-@FCDISTRO@ as base"
     exit 1
 }
 
@@ -201,24 +235,24 @@ function main () {
     MAKEOPTS=()
     DO_BUILD=true
     DO_TEST=true
-    PERSONALITY=$DEFAULT_PERSONALITY
-    while getopts "nf:d:b:t:r:s:om:a:w:BTvhp:" opt ; do
+    while getopts "nf:d:b:p:t:r:s:om:a:w:BTvh7" 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 ;;
+           o) OVERWRITEMODE=true ;;
            m) MAILTO=$OPTARG ;;
            a) MAKEVARS=(${MAKEVARS[@]} "$OPTARG") ;;
            w) WEBPATH=$OPTARG ;;
            B) DO_TEST= ;;
-           T) DO_BUILD= ; USEOLD=true ;;
-           p) PERSONALITY=$OPTARG ;;
+           T) DO_BUILD= ; OVERWRITEMODE=true ;;
            v) set -x ;;
+           7) BASE="$(date +%a|tr A-Z a-z)-@FCDISTRO@" ;;
            h|*) usage ;;
        esac
     done
@@ -229,17 +263,12 @@ function main () {
     # 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 "$SVNPATH" ] && SVNPATH="$DEFAULT_SVNPATH"
 
-    # NOTE: suggest that by default no email is sent and that the user
-    # should explicitly invoke this script with the -m arg to pass in
-    # the appropriate email address. --mef
-    if [ "$PLDISTRO" = "onelab" ] ; then
-       [ -z "$MAILTO" ] && MAILTO="$DEFAULT_MAILTO"
-    fi
     [ -n "$DRY_RUN" ] && MAILTO=""
        
     ### set BASE from DISTRO, if unspecified
@@ -260,7 +289,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
@@ -302,7 +331,7 @@ function main () {
            svn export $SVNPATH $tmpdir
             # Create vserver
            cd $tmpdir
-           ./vbuild-init-vserver.sh ${BASE} ${FCDISTRO} ${PLDISTRO} ${PERSONALITY}
+           ./vbuild-init-vserver.sh -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} ${BASE}
            # cleanup
            cd -
            rm -rf $tmpdir