9845bcda8250cf262685ba086bd4eb8e2a8fa290
[infrastructure.git] / scripts / all-builds.sh
1 #!/bin/bash
2 # $Id$
3 # this script is managed under subversion at 
4 # http://svn.onelab.eu/infrastructure/scripts/all-builds.sh
5 # it is triggered every night at 0:05 french time on build.onelab.eu aka blitz.inria.fr
6
7 COMMAND=$(basename $0)
8
9 function usage () {
10     echo "Usage: $COMMAND [options [ -- vbuild-nightly-options ]]"
11     echo "In manual mode you should export the following vars (or use related option)"
12     echo "MAJOR_DISTROS (-d) TRUNK_DISTROS (-td) TRUNK_FCDISTROS (-tf) VS_DISTROS (-vd)"
13     echo "FCDISTROS (-f) BITS (-i) BASE (-b)"
14     echo "BUILD_BRANCH (-bb) BUILD_TRUNK (-bt)"
15     echo "RETRY (-O) TEST (-T) DRY_RUN (-n)"
16     echo "Use at least one space for blanking a set of distros"
17     exit 1
18 }
19
20 function run () {
21     [ -n "$manual" ] && echo "$@" '; \'
22     if [ -z "$DRY_RUN" ] ; then
23         "$@"
24     fi
25 }
26
27 function shortname () {
28     distro=$1; shift
29     case $distro in
30         onelab)         echo 1l;;
31         planetlab)      echo pl;;
32         *)              echo xx;;
33     esac
34 }
35
36 # comment off for usual dailies
37 MAJOR=5.0
38 MINOR=rc01
39 base_option=-b
40
41 while [[ -n "$@" ]] ; do
42     case "$1" in
43         -d) shift ; MAJOR_DISTROS="$MAJOR_DISTROS $1" ;;
44         -f) shift ; FCDISTROS="$FCDISTROS $1" ;;
45         -i) shift ; BITS="$BITS $1" ;;
46         -td) shift; TRUNK_DISTROS="$1" ;;
47         -tf) shift; TRUNK_FCDISTROS="$1" ;;
48         -vd) shift; VS_DISTROS="$1" ;;
49         -b) shift; BASE="$1" ;;
50         -bb) BUILD_BRANCH=true ;;
51         -bt) BUILD_TRUNK=true ;;
52         -O) base_option=-o ;;
53         -T) TEST=true ;;
54         -n) DRY_RUN=true ;;
55         -z) MINOR="" ;;
56         --) shift; extra_option="$@" ; shift $# ;;
57         *) usage ;;
58     esac
59     shift
60 done
61
62 FCDISTRO=centos5
63 DEFAULT_FCDISTROS="centos5"
64 DEFAULT_BASE="@DATE@"
65
66 function trunk_builds () {
67     DEFAULT_BITS="32 64"
68     DEFAULT_MAJOR_DISTROS=""
69     DEFAULT_VS_DISTROS=""
70 # 5.0 ready for planetlab distro only so far
71     DEFAULT_TRUNK_DISTROS="planetlab"
72 #    DEFAULT_TRUNK_DISTROS="onelab planetlab"
73     DEFAULT_TRUNK_FCDISTROS="f8 f9"
74 }
75
76 function branch_builds () {
77     DEFAULT_BITS="32 64"
78     DEFAULT_MAJOR_DISTROS="onelab planetlab"
79     DEFAULT_VS_DISTROS=""
80     DEFAULT_BITS="32"
81     DEFAULT_TRUNK_DISTROS=""
82     DEFAULT_TRUNK_FCDISTROS=""
83 }
84
85 function tagged_builds () {
86     DEFAULT_BITS="32 64"
87     DEFAULT_MAJOR_DISTROS="onelab planetlab"
88     DEFAULT_VS_DISTROS="onelab"
89     DEFAULT_TRUNK_DISTROS=""
90     DEFAULT_TRUNK_FCDISTROS=""
91 }
92
93 if [ -n "$BUILD_BRANCH" ] ; then
94     branch_builds
95     BUILDOPT="-s http://svn.planet-lab.org/svn/build/branches/${MAJOR}"
96 elif [ -n "$BUILD_TRUNK" ] ; then
97     trunk_builds
98     BUILDOPT=""
99 else
100     tagged_builds
101     BUILDOPT="-s http://svn.planet-lab.org/svn/build/tags/${MAJOR}-${MINOR}"
102 fi
103
104 [[ -n "$@" ]] && usage
105
106 # export any of these to override - this is for manual use only
107 if [ -z "$MAJOR_DISTROS" ] ;    then MAJOR_DISTROS=$DEFAULT_MAJOR_DISTROS ;     else manual=true ; fi
108 if [ -z "$FCDISTROS" ] ;        then FCDISTROS=$DEFAULT_FCDISTROS ;             else manual=true ; fi
109 if [ -z "$BITS" ] ;             then BITS=$DEFAULT_BITS ;                       else manual=true ; fi
110 if [ -z "$TRUNK_DISTROS" ] ;    then TRUNK_DISTROS=$DEFAULT_TRUNK_DISTROS ;     else manual=true ; fi
111 if [ -z "$TRUNK_FCDISTROS" ] ;  then TRUNK_FCDISTROS=$DEFAULT_TRUNK_FCDISTROS ; else manual=true ; fi
112 if [ -z "$VS_DISTROS" ] ;       then VS_DISTROS=$DEFAULT_VS_DISTROS ;           else manual=true ; fi
113 if [ -z "$BASE" ] ;             then BASE=$DEFAULT_BASE ;                       else manual=true ; fi
114 [ -n "$TEST" ] &&       { extra_option="$extra_option -T" ; }
115 [ -n "$DRY_RUN" ] &&    { manual=true ; }
116
117 ############################## ${MAJOR}
118 for bits in $BITS; do
119     for f in $FCDISTROS ; do 
120         for d in $MAJOR_DISTROS ; do
121             p=linux${bits}
122             s=$(shortname $d)
123             if [ -n "$BUILD_BRANCH" ] ; then
124                 buildname="${d}-${MAJOR}-${BASE}-${f}-${bits}"
125             elif [ -n "$BUILD_TRUNK" ] ; then
126                 buildname="${BASE}--${s}.${MAJOR}--${f}-${bits}"
127             else
128                 buildname="${d}-${MAJOR}-${MINOR}-${f}-${bits}"
129             fi
130             command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
131                 -d $d -p $p -f $f -t ${d}-tags-${MAJOR}.mk \
132                 ${base_option} $buildname $extra_option"
133             run $command
134         done
135     done
136 done
137
138 ############################## ${MAJOR}/centos5
139 # centos5 : for both archs, make the vserver rpms
140 # does not test, so skip if test is requested
141 if [ -z "$TEST" ] ; then
142     f=centos5
143     for d in $VS_DISTROS ; do
144         for bits in $BITS ; do
145             p=linux${bits}
146             s=$(shortname $d)
147             if [ -n "$BUILD_BRANCH" ] ; then 
148                 buildname="${d}-${MAJOR}-${BASE}-vs-${f}-${bits}"
149             elif [ -n "$BUILD_TRUNK" ] ; then
150                 buildname="${BASE}--${s}.${MAJOR}--vs-${f}-${bits}"
151             else
152                 buildname="${d}-${MAJOR}-${MINOR}-vs-${f}-${bits}"
153             fi
154             command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
155             -d $d -p $p -f $f -t ${d}-tags-${MAJOR}.mk \
156             ${base_option} $buildname -B $extra_option vserver"
157             run $command
158         done
159     done
160 fi
161
162 ############################## TRUNK
163 # raw - std planetlab x f8 x 32bits for deploying on alpha nodes
164 for bits in $BITS; do
165
166     for d in $TRUNK_DISTROS; do
167         p=linux${bits}
168         s=$(shortname $d)
169         f=$FCDISTRO
170         buildname="${BASE}--tr${f}-${s}-${bits}"
171         command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
172          -f $f -d $d -p $p ${base_option} $buildname $extra_option"
173         run $command
174     done
175
176     for f in $TRUNK_FCDISTROS; do 
177         p=linux${bits}
178         d=planetlab
179         s=$(shortname $d)
180         buildname="${BASE}--tr${f}-${s}-${bits}"
181         command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
182          -d $d -p $p -f $f ${base_option} $buildname $extra_option"
183         run $command
184     done
185 done
186 ##############################