building rc23/umts
[infrastructure.git] / scripts / all-builds.sh
index fe9543a..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
-/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org -B -f f8      -p linux64 -d planetlab 
+# 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
 
-# centos : do both archs, full version not tested, on onelab
-for bits in 32 64; do
-    /root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org -B -f centos5 -p linux${bits} -d onelab -b @DATE@--c51lab-full-${bits}
+COMMAND=$(basename $0)
+
+function usage () {
+    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
+}
+
+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@"
+
+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=""
+}
+
+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 "$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 ; }
+
+############################## ${MAJOR}
+for bits in $BITS; do
+    for f in $FCDISTROS ; do 
+       for d in $MAJOR_DISTROS ; do
+           p=linux${bits}
+           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
+               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
+
+############################## ${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
+
+############################## 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 d in planetlab onelab; do
-    for f in f7 f8; do 
-       /root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org    -f $f      -p linux32 -d $d 
+    for f in $TRUNK_FCDISTROS; do 
+       fs=$(shortname $f)      
+       p=linux${bits}
+       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
+##############################