building rc23/umts
[infrastructure.git] / scripts / all-builds.sh
index a461d6d..e91f794 100755 (executable)
 #!/bin/bash
+# $Id$
 # this script is managed under subversion at 
-# http://svn.one-lab.org/infrastructure/scripts/all-builds.sh
-# it is triggered every night at 0:05 french time on build.one-lab.org aka blitz.inria.fr
+# http://svn.onelab.eu/infrastructure/scripts/all-builds.sh
+# it is triggered every night at 0:05 french time on build.onelab.eu aka blitz.inria.fr
 
 COMMAND=$(basename $0)
 
 function usage () {
-    echo "Usage: $COMMAND"
-    echo "In manual mode you should export either of these"
-    echo "PLDISTROS FCDISTROS BITS RETRY TEST DRY_RUN"
+    echo "Usage: $COMMAND [options [ -- vbuild-nightly-options ]]"
+    echo "In manual mode you should export the following vars (or use related option)"
+    echo "MAJOR_DISTROS (-d) TRUNK_DISTROS (-td) TRUNK_FCDISTROS (-tf) VS_DISTROS (-vd)"
+    echo "FCDISTROS (-f) BITS (-i) BASE (-b)"
+    echo "BUILD_BRANCH (-bb) BUILD_TRUNK (-bt)"
+    echo "Overwrite (-o) TEST (-T) DRY_RUN (-n)"
+    echo "Use at least one space for blanking a set of distros"
     exit 1
 }
 
-[[ -n "$@" ]] && usage
+function run () {
+    [ -n "$manual" ] && echo "$@" '; \'
+    if [ -z "$DRY_RUN" ] ; then
+       "$@"
+    fi
+}
+
+function shortname () {
+    distro=$1; shift
+    case $distro in
+       onelab)         echo 1l;;
+       planetlab)      echo pl;;
+       f?)             echo $distro;;
+       centos5)        echo c5;;
+       *)              echo xx;;
+    esac
+}
+
+# comment off for usual dailies
+#MAJOR=5.0
+#MINOR=rc01
+MAJOR=4.2
+MINOR=rc23
+base_option=-b
+
+while [[ -n "$@" ]] ; do
+    case "$1" in
+       -d) shift ; MAJOR_DISTROS="$MAJOR_DISTROS $1" ;;
+       -f) shift ; FCDISTROS="$FCDISTROS $1" ;;
+       -i) shift ; BITS="$BITS $1" ;;
+       -td) shift; TRUNK_DISTROS="$1" ;;
+       -tf) shift; TRUNK_FCDISTROS="$1" ;;
+       -vd) shift; VS_DISTROS="$1" ;;
+       -b) shift; BASE="$1" ;;
+       -bb) BUILD_BRANCH=true ;;
+       -bt) BUILD_TRUNK=true ;;
+       -o) base_option=-o ;;
+       -T) TEST=true ;;
+       -n) DRY_RUN=true ;;
+       -z) MINOR="" ;;
+       --) shift; extra_option="$@" ; shift $# ;;
+       *) usage ;;
+    esac
+    shift
+done
+
+FCDISTRO=centos5
+DEFAULT_FCDISTROS="centos5"
+DEFAULT_BASE="@DATE@"
 
-# tuned for allowing manual re-runs, mostly for tests
+function trunk_builds () {
+    DEFAULT_BITS="32 64"
+    DEFAULT_MAJOR_DISTROS=""
+    DEFAULT_VS_DISTROS=""
+# 5.0 ready for planetlab distro only so far
+    DEFAULT_TRUNK_DISTROS="planetlab"
+#    DEFAULT_TRUNK_DISTROS="onelab planetlab"
+    DEFAULT_TRUNK_FCDISTROS="f8 f9"
+}
+
+function branch_builds () {
+    DEFAULT_BITS="32 64"
+    DEFAULT_MAJOR_DISTROS="onelab planetlab"
+    DEFAULT_VS_DISTROS=""
+    DEFAULT_BITS="32"
+    DEFAULT_TRUNK_DISTROS=""
+    DEFAULT_TRUNK_FCDISTROS=""
+}
+
+function tagged_builds () {
+    DEFAULT_BITS="32 64"
+    DEFAULT_MAJOR_DISTROS="onelab planetlab"
+    DEFAULT_VS_DISTROS="onelab"
+    DEFAULT_TRUNK_DISTROS=""
+    DEFAULT_TRUNK_FCDISTROS=""
+}
 
-DEFAULT_PLDISTROS="planetlab onelab"
-DEFAULT_FCDISTROS="f8"
-DEFAULT_BITS="32 64"
+if [ -n "$BUILD_BRANCH" ] ; then
+    branch_builds
+    BUILDOPT="-s http://svn.planet-lab.org/svn/build/branches/${MAJOR}"
+elif [ -n "$BUILD_TRUNK" ] ; then
+    trunk_builds
+    BUILDOPT=""
+else
+    tagged_builds
+    BUILDOPT="-s http://svn.planet-lab.org/svn/build/tags/${MAJOR}-${MINOR}"
+fi
+
+[[ -n "$@" ]] && usage
 
 # export any of these to override - this is for manual use only
-if [ -z "$PLDISTROS" ] ; then PLDISTROS=$DEFAULT_PLDISTROS ; else manual=true ; fi
-if [ -z "$FCDISTROS" ] ; then FCDISTROS=$DEFAULT_FCDISTROS ; else manual=true ; fi
-if [ -z "$BITS" ] ;     then BITS=$DEFAULT_BITS ;           else manual=true ; fi
-[ -n "$RETRY" ] &&     { extra_option="$extra_option -o" ; manual=true ; }
-[ -n "$TEST" ] &&      { extra_option="$extra_option -T" ; manual=true ; }
+if [ -z "$MAJOR_DISTROS" ] ;   then MAJOR_DISTROS=$DEFAULT_MAJOR_DISTROS ;     else manual=true ; fi
+if [ -z "$FCDISTROS" ] ;       then FCDISTROS=$DEFAULT_FCDISTROS ;             else manual=true ; fi
+if [ -z "$BITS" ] ;            then BITS=$DEFAULT_BITS ;                       else manual=true ; fi
+if [ -z "$TRUNK_DISTROS" ] ;   then TRUNK_DISTROS=$DEFAULT_TRUNK_DISTROS ;     else manual=true ; fi
+if [ -z "$TRUNK_FCDISTROS" ] ; then TRUNK_FCDISTROS=$DEFAULT_TRUNK_FCDISTROS ; else manual=true ; fi
+if [ -z "$VS_DISTROS" ] ;      then VS_DISTROS=$DEFAULT_VS_DISTROS ;           else manual=true ; fi
+if [ -z "$BASE" ] ;            then BASE=$DEFAULT_BASE ;                       else manual=true ; fi
+[ -n "$TEST" ] &&      { extra_option="$extra_option -T" ; }
 [ -n "$DRY_RUN" ] &&   { manual=true ; }
 
-for d in $PLDISTROS ; do
+############################## ${MAJOR}
+for bits in $BITS; do
     for f in $FCDISTROS ; do 
-       for bits in $BITS; do
+       for d in $MAJOR_DISTROS ; do
            p=linux${bits}
-           command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org \
-               -f $f -p $p -d $d \
-               -t ${d}-tags-4.2.mk \
-               -b @DATE@--${d}.4.2--${f}-${bits} $extra_option"
-           [ -n "$manual" ] && echo $command
-           if [ -n "$DRY_RUN" ] ; then
-               echo "dry-run: skipped"
+           s=$(shortname $d)
+           if [ -n "$BUILD_BRANCH" ] ; then
+               buildname="${d}-${MAJOR}-${BASE}-${f}-${bits}"
+           elif [ -n "$BUILD_TRUNK" ] ; then
+               buildname="${BASE}--${s}.${MAJOR}--${f}-${bits}"
            else
-               $command
+               buildname="${d}-${MAJOR}-${MINOR}-${f}-${bits}"
            fi
+           command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
+               -d $d -p $p -f $f -t ${d}-tags-${MAJOR}.mk \
+               ${base_option} $buildname $extra_option"
+           run $command
        done
     done
 done
 
-# raw - std planetlab x f8 x 32bits for deploying on alpha nodes
-command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org -b @DATE@-trunk"
-if [ -n "$manual" ] ; then
-    echo $command
-    echo "manual/dry_run: skipped"
-else
-    $command
+############################## ${MAJOR}/centos5
+# centos5 : for both archs, make the vserver rpms
+# does not test, so skip if test is requested
+if [ -z "$TEST" ] ; then
+    f=centos5
+    for d in $VS_DISTROS ; do
+       for bits in $BITS ; do
+           p=linux${bits}
+           s=$(shortname $d)
+           if [ -n "$BUILD_BRANCH" ] ; then 
+               buildname="${d}-${MAJOR}-${BASE}-vs-${f}-${bits}"
+           elif [ -n "$BUILD_TRUNK" ] ; then
+               buildname="${BASE}--${s}.${MAJOR}--vs-${f}-${bits}"
+           else
+               buildname="${d}-${MAJOR}-${MINOR}-vs-${f}-${bits}"
+           fi
+           command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
+           -d $d -p $p -f $f -t ${d}-tags-${MAJOR}.mk \
+           ${base_option} $buildname -B $extra_option vserver"
+           run $command
+       done
+    done
 fi
 
-# the following gets skipped in any manual mode 
-# centos5 : for both archs, make the vserver rpms
-for d in onelab ; do
-    for bits in 32 64; do
+############################## TRUNK
+# raw - std planetlab x f8 x 32bits for deploying on alpha nodes
+for bits in $BITS; do
+
+    for d in $TRUNK_DISTROS; do
+       ds=$(shortname $d)
+       p=linux${bits}
+       f=$FCDISTRO
+       fs=$(shortname $f)
+       buildname="${BASE}--tr${fs}-${ds}-${bits}"
+       command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
+        -d $d -p $p -f $f ${base_option} $buildname $extra_option"
+       run $command
+    done
+
+    for f in $TRUNK_FCDISTROS; do 
+       fs=$(shortname $f)      
        p=linux${bits}
-       command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org \
-           -f centos5 -p $p -d $d \
-           -t ${d}-tags-4.2.mk \
-           -b @DATE@--${d}.4.2--c5vs-${bits} \
-           -B vserver"
-       if [ -n "$manual" ] ; then
-           echo $command
-           echo "manual/dry_run: skipped"
-       else
-           $command
-       fi
+       d=planetlab
+       ds=$(shortname $d)
+       buildname="${BASE}--tr${fs}-${ds}-${bits}"
+       command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
+        -d $d -p $p -f $f ${base_option} $buildname $extra_option"
+       run $command
     done
 done
+##############################