COMMAND=$(basename $0)
# default values, tunable with command-line options
-DEFAULT_FCDISTRO=f7
+DEFAULT_FCDISTRO=f8
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"
+DEFAULT_TESTSVNPATH="http://svn.planet-lab.org/svn/tests/trunk/system/"
+DEFAULT_TESTCONFIG="default"
+DEFAULT_IFNAME=eth0
# web publishing results
DEFAULT_WEBPATH="/build/@PLDISTRO@/"
# 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/trunk/system/"
-TESTSCRIPT=TestMain.py
+TESTBOXSSH=root@testbox.one-lab.org
####################
# assuming vserver runs in UTC
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"
}
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 20k $WEBLOG) > ${WEBLOG}.ko
+ (echo -n "============================== $COMMAND: failure at " ; date ; tail -c 30k $WEBLOG) > ${WEBLOG}.ko
if [ -n "$MAILTO" ] ; then
- tail -c 20k ${WEBPATH}/${BASE}.log.txt | mail -s "Failures for build ${BASE}" $MAILTO
+ tail -c 30k ${WEBLOG} | mail -s "Failures for build ${BASE}" $MAILTO
fi
exit 1
}
function success () {
set -x
WEBLOG=${WEBPATH}/${BASE}.log.txt
+ mkdir -p ${WEBPATH}
cp $LOG ${WEBLOG}
summary $LOG >> ${WEBLOG}
- touch ${WEBLOG}.ok
+ 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 "$PLDISTRO ($BASE) build for $FCDISTRO 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
exit 0
}
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)"
+
+ # stuff our own variable settings
+ MAKEVARS=("PLDISTRO=${PLDISTRO}" "${MAKEVARS[@]}")
+ MAKEVARS=("PLDISTROTAGS=${PLDISTROTAGS}" "${MAKEVARS[@]}")
+ MAKEVARS=("NIGHTLY_BASE=${BASE}" "${MAKEVARS[@]}")
+ MAKEVARS=("NIGHTLY_PERSONALITY=${PERSONALITY}" "${MAKEVARS[@]}")
+
# stage1
- make -C /build "${MAKEOPTS[@]}" PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${PLDISTRO} "${MAKEVARS[@]}" stage1=true
+ make -C /build $DRY_RUN "${MAKEVARS[@]}" stage1=true
# versions
- make -C /build "${MAKEOPTS[@]}" PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${PLDISTRO} "${MAKEVARS[@]}" NIGHTLY_BASE=${BASE} versions
+ make -C /build $DRY_RUN "${MAKEVARS[@]}" versions
# actual stuff
- make -C /build "${MAKEOPTS[@]}" PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${PLDISTRO} "${MAKEVARS[@]}" $MAKETARGETS
+ make -C /build $DRY_RUN "${MAKEVARS[@]}" $MAKETARGETS
}
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=$( find /vservers/$BASE/build/RPMS -name 'myplc-[0-9]*' )
if [ ${#rpm[@]} != 1 ] ; then
echo "$COMMAND: Cannot locate rpm for testing"
failure
exit 1
fi
- url=${TESTBUILDURL}${PLDISTRO}/${BASE}/RPMS/i386/${rpm}
+ url=$(echo $rpm | sed -e "s,/vservers/$BASE/build,${TESTBUILDURL}${PLDISTRO}/${BASE},")
- # compute test directory name on test box
- testdir=test-${BASE}
+ # test directory name on test box
+ testdir=${BASE}
# clean it
ssh ${TESTBOXSSH} rm -rf ${testdir}
# check it out
ssh ${TESTBOXSSH} svn co ${TESTSVNPATH} ${testdir}
- # invoke test on testbox
- ssh 2>&1 ${TESTBOXSSH} python -u ${testdir}/${TESTSCRIPT} ${url}
- # still missing - need to populate /var/www/html/install-rpms on the myplc
-
- if [ "$?" != 0 ] ; then
+ # 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 ${TESTBOXSSH} ${testdir}/runtest --build ${SVNPATH} --url ${url} $configs --all || success=
+
+ # gather logs in the vserver
+ mkdir -p /vservers/$BASE/build/testlogs
+ ssh 2>&1 ${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)"
}
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 "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 " -p personality - defaults to $DEFAULT_PERSONALITY"
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 " -x testsvnpath - defaults to $DEFAULT_TESTSVNPATH"
+ echo " -c testconfig - defaults to $DEFAULT_TESTCONFIG"
echo " -w webpath - defaults to $DEFAULT_WEBPATH"
+ 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
}
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:p:t:r:s:om:a:w:BTvh7" opt ; do
+ while getopts "f:d:p:b:t:r:s:x:c:w:m:OBTnv7a:i:" opt ; do
case $opt in
- n) DRY_RUN="true" ; MAKEOPTS=(${MAKEOPTS[@]} -n) ;;
f) FCDISTRO=$OPTARG ;;
d) PLDISTRO=$OPTARG ;;
p) PERSONALITY=$OPTARG ;;
t) PLDISTROTAGS=$OPTARG ;;
r) TAGSRELEASE=$OPTARG ;;
s) SVNPATH=$OPTARG ;;
- o) USEOLD=true ;;
- m) MAILTO=$OPTARG ;;
- a) MAKEVARS=(${MAKEVARS[@]} "$OPTARG") ;;
+ x) TESTSVNPATH=$OPTARG ;;
+ c) TESTCONFIG="$TESTCONFIG $OPTARG" ;;
w) WEBPATH=$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 "$PLDISTROTAGS" ] && PLDISTROTAGS="${PLDISTRO}-tags.mk"
[ -z "$BASE" ] && BASE="$DEFAULT_BASE"
[ -z "$WEBPATH" ] && WEBPATH="$DEFAULT_WEBPATH"
+ [ -z "$IFNAME" ] && IFNAME="$DEFAULT_IFNAME"
[ -z "$SVNPATH" ] && SVNPATH="$DEFAULT_SVNPATH"
+ [ -z "$TESTSVNPATH" ] && TESTSVNPATH="$DEFAULT_TESTSVNPATH"
+ [ -z "$TESTCONFIG" ] && TESTCONFIG="$DEFAULT_TESTCONFIG"
- # 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
# (*) 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
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
svn export $SVNPATH $tmpdir
# Create vserver
cd $tmpdir
- ./vbuild-init-vserver.sh -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} ${BASE}
+ ./vbuild-init-vserver.sh -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} -i ${IFNAME} ${BASE}
# cleanup
cd -
rm -rf $tmpdir
# invoke this command in the vserver for building (-T)
vserver ${BASE} exec chmod +x /build/$COMMAND
- vserver ${BASE} exec /build/$COMMAND "${argv[@]}" -b "${BASE}"
+ 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
if [ -n "$DO_TEST" ] ; then
runtest