mkfedora : ready for new mirror layout & for centos, tentatively
[build.git] / vbuild-nightly.sh
index 436d037..a70547b 100755 (executable)
@@ -10,15 +10,15 @@ DEFAULT_PLDISTRO=planetlab
 DEFAULT_PERSONALITY=linux32
 DEFAULT_BASE="@DATE@--@PLDISTRO@-@FCDISTRO@-@PERSONALITY@"
 DEFAULT_SVNPATH="http://svn.planet-lab.org/svn/build/trunk"
+DEFAULT_TESTSVNPATH="http://svn.planet-lab.org/svn/tests/trunk/system/"
+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
+TESTBUILDURL="http://build32.one-lab.org/"
 TESTBOXSSH=root@onelab-test.inria.fr
-TESTSVNPATH="http://svn.planet-lab.org/svn/tests/trunk/system/"
 ####################
 # assuming vserver runs in UTC
 DATE=$(date +'%Y.%m.%d')
@@ -94,6 +94,7 @@ EOF
 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
@@ -106,6 +107,7 @@ function failure() {
 function success () {
     set -x
     WEBLOG=${WEBPATH}/${BASE}.log.txt
+    mkdir -p ${WEBPATH}
     cp $LOG ${WEBLOG}
     summary $LOG >> ${WEBLOG}
     touch ${WEBLOG}.ok
@@ -115,6 +117,34 @@ function success () {
     exit 0
 }
 
+# parses ifconfig's output to find out ip address and mask
+# will then be passed to vserver as e.g. --interface 138.96.250.126/255.255.0.0
+# default is to use lo, that's enough for local mirrors
+# use -i eth0 in case your fedora mirror is on a separate box on the network
+function vserverIfconfig () {
+    ifname=$1; shift
+    local result="" 
+    line=$(ifconfig $ifname 2> /dev/null | grep 'inet addr')
+    if [ -n "$line" ] ; then
+       set $line
+       for word in "$@" ; do
+           addr=$(echo $word | sed -e s,[aA][dD][dD][rR]:,,)
+           mask=$(echo $word | sed -e s,[mM][aA][sS][kK]:,,)
+           if [ "$word" != "$addr" ] ; then
+               result="${addr}"
+           elif [ "$word" != "$mask" ] ; then
+               result="${result}/${mask}"
+           fi
+       done
+    fi
+    if [ -z "$result" ] ; then 
+       echo "vserverIfconfig failed to locate $ifname"
+       exit 1
+    else
+       echo $result
+    fi
+}
+
 # run in the vserver - do not manage success/failure, will be done from the root ctx
 function build () {
     set -x
@@ -158,13 +188,13 @@ function runtest () {
     echo -n "============================== Starting $COMMAND:runtest on $(date)"
 
     ### the URL to the myplc package
-    rpm=$( (cd /vservers/$BASE/build/RPMS/i386 ; 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}
@@ -174,7 +204,6 @@ function runtest () {
     ssh ${TESTBOXSSH} svn co ${TESTSVNPATH} ${testdir}
     # invoke test on testbox - pass url and build url - so the tests can use vtest-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
@@ -222,8 +251,10 @@ function usage () {
     echo " -m mailto"
     echo " -a makevar=value - space in values are not supported"
     echo " -w webpath - defaults to $DEFAULT_WEBPATH"
+    echo " -i ifname - defaults to $DEFAULT_IFNAME - set to e.g. eth0 for non-local mirrors"
     echo " -B : run build only"
     echo " -T : run test only"
+    echo " -x testsvnpath - defaults to $DEFAULT_TESTSVNPATH"
     echo " -v : be verbose"
     echo " -7 : uses weekday-@FCDISTRO@ as base"
     exit 1
@@ -242,7 +273,7 @@ function main () {
     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 "nf:d:b:p:t:r:s:om:a:w:i:BTvh7" opt ; do
        case $opt in
            n) DRY_RUN="-n" ;;
            f) FCDISTRO=$OPTARG ;;
@@ -256,8 +287,10 @@ function main () {
            m) MAILTO=$OPTARG ;;
            a) MAKEVARS=(${MAKEVARS[@]} "$OPTARG") ;;
            w) WEBPATH=$OPTARG ;;
+           i) IFNAME=$OPTARG ;;
            B) DO_TEST= ;;
            T) DO_BUILD= ; OVERWRITEMODE=true ;;
+           x) TESTSVNPATH=$OPTARG ;;
            v) set -x ;;
            7) BASE="$(date +%a|tr A-Z a-z)-@FCDISTRO@" ;;
            h|*) usage ;;
@@ -274,7 +307,9 @@ function main () {
     [ -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"
 
     [ -n "$DRY_RUN" ] && MAILTO=""
        
@@ -338,7 +373,8 @@ function main () {
            svn export $SVNPATH $tmpdir
             # Create vserver
            cd $tmpdir
-           ./vbuild-init-vserver.sh -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} ${BASE}
+           localip=$(vserverIfconfig $IFNAME)
+           ./vbuild-init-vserver.sh -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} ${BASE} -- --interface $localip
            # cleanup
            cd -
            rm -rf $tmpdir