e91f79477553b03065a4af05ccc5f303595234d2
[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 "Overwrite (-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         f?)             echo $distro;;
33         centos5)        echo c5;;
34         *)              echo xx;;
35     esac
36 }
37
38 # comment off for usual dailies
39 #MAJOR=5.0
40 #MINOR=rc01
41 MAJOR=4.2
42 MINOR=rc23
43 base_option=-b
44
45 while [[ -n "$@" ]] ; do
46     case "$1" in
47         -d) shift ; MAJOR_DISTROS="$MAJOR_DISTROS $1" ;;
48         -f) shift ; FCDISTROS="$FCDISTROS $1" ;;
49         -i) shift ; BITS="$BITS $1" ;;
50         -td) shift; TRUNK_DISTROS="$1" ;;
51         -tf) shift; TRUNK_FCDISTROS="$1" ;;
52         -vd) shift; VS_DISTROS="$1" ;;
53         -b) shift; BASE="$1" ;;
54         -bb) BUILD_BRANCH=true ;;
55         -bt) BUILD_TRUNK=true ;;
56         -o) base_option=-o ;;
57         -T) TEST=true ;;
58         -n) DRY_RUN=true ;;
59         -z) MINOR="" ;;
60         --) shift; extra_option="$@" ; shift $# ;;
61         *) usage ;;
62     esac
63     shift
64 done
65
66 FCDISTRO=centos5
67 DEFAULT_FCDISTROS="centos5"
68 DEFAULT_BASE="@DATE@"
69
70 function trunk_builds () {
71     DEFAULT_BITS="32 64"
72     DEFAULT_MAJOR_DISTROS=""
73     DEFAULT_VS_DISTROS=""
74 # 5.0 ready for planetlab distro only so far
75     DEFAULT_TRUNK_DISTROS="planetlab"
76 #    DEFAULT_TRUNK_DISTROS="onelab planetlab"
77     DEFAULT_TRUNK_FCDISTROS="f8 f9"
78 }
79
80 function branch_builds () {
81     DEFAULT_BITS="32 64"
82     DEFAULT_MAJOR_DISTROS="onelab planetlab"
83     DEFAULT_VS_DISTROS=""
84     DEFAULT_BITS="32"
85     DEFAULT_TRUNK_DISTROS=""
86     DEFAULT_TRUNK_FCDISTROS=""
87 }
88
89 function tagged_builds () {
90     DEFAULT_BITS="32 64"
91     DEFAULT_MAJOR_DISTROS="onelab planetlab"
92     DEFAULT_VS_DISTROS="onelab"
93     DEFAULT_TRUNK_DISTROS=""
94     DEFAULT_TRUNK_FCDISTROS=""
95 }
96
97 if [ -n "$BUILD_BRANCH" ] ; then
98     branch_builds
99     BUILDOPT="-s http://svn.planet-lab.org/svn/build/branches/${MAJOR}"
100 elif [ -n "$BUILD_TRUNK" ] ; then
101     trunk_builds
102     BUILDOPT=""
103 else
104     tagged_builds
105     BUILDOPT="-s http://svn.planet-lab.org/svn/build/tags/${MAJOR}-${MINOR}"
106 fi
107
108 [[ -n "$@" ]] && usage
109
110 # export any of these to override - this is for manual use only
111 if [ -z "$MAJOR_DISTROS" ] ;    then MAJOR_DISTROS=$DEFAULT_MAJOR_DISTROS ;     else manual=true ; fi
112 if [ -z "$FCDISTROS" ] ;        then FCDISTROS=$DEFAULT_FCDISTROS ;             else manual=true ; fi
113 if [ -z "$BITS" ] ;             then BITS=$DEFAULT_BITS ;                       else manual=true ; fi
114 if [ -z "$TRUNK_DISTROS" ] ;    then TRUNK_DISTROS=$DEFAULT_TRUNK_DISTROS ;     else manual=true ; fi
115 if [ -z "$TRUNK_FCDISTROS" ] ;  then TRUNK_FCDISTROS=$DEFAULT_TRUNK_FCDISTROS ; else manual=true ; fi
116 if [ -z "$VS_DISTROS" ] ;       then VS_DISTROS=$DEFAULT_VS_DISTROS ;           else manual=true ; fi
117 if [ -z "$BASE" ] ;             then BASE=$DEFAULT_BASE ;                       else manual=true ; fi
118 [ -n "$TEST" ] &&       { extra_option="$extra_option -T" ; }
119 [ -n "$DRY_RUN" ] &&    { manual=true ; }
120
121 ############################## ${MAJOR}
122 for bits in $BITS; do
123     for f in $FCDISTROS ; do 
124         for d in $MAJOR_DISTROS ; do
125             p=linux${bits}
126             s=$(shortname $d)
127             if [ -n "$BUILD_BRANCH" ] ; then
128                 buildname="${d}-${MAJOR}-${BASE}-${f}-${bits}"
129             elif [ -n "$BUILD_TRUNK" ] ; then
130                 buildname="${BASE}--${s}.${MAJOR}--${f}-${bits}"
131             else
132                 buildname="${d}-${MAJOR}-${MINOR}-${f}-${bits}"
133             fi
134             command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
135                 -d $d -p $p -f $f -t ${d}-tags-${MAJOR}.mk \
136                 ${base_option} $buildname $extra_option"
137             run $command
138         done
139     done
140 done
141
142 ############################## ${MAJOR}/centos5
143 # centos5 : for both archs, make the vserver rpms
144 # does not test, so skip if test is requested
145 if [ -z "$TEST" ] ; then
146     f=centos5
147     for d in $VS_DISTROS ; do
148         for bits in $BITS ; do
149             p=linux${bits}
150             s=$(shortname $d)
151             if [ -n "$BUILD_BRANCH" ] ; then 
152                 buildname="${d}-${MAJOR}-${BASE}-vs-${f}-${bits}"
153             elif [ -n "$BUILD_TRUNK" ] ; then
154                 buildname="${BASE}--${s}.${MAJOR}--vs-${f}-${bits}"
155             else
156                 buildname="${d}-${MAJOR}-${MINOR}-vs-${f}-${bits}"
157             fi
158             command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
159             -d $d -p $p -f $f -t ${d}-tags-${MAJOR}.mk \
160             ${base_option} $buildname -B $extra_option vserver"
161             run $command
162         done
163     done
164 fi
165
166 ############################## TRUNK
167 # raw - std planetlab x f8 x 32bits for deploying on alpha nodes
168 for bits in $BITS; do
169
170     for d in $TRUNK_DISTROS; do
171         ds=$(shortname $d)
172         p=linux${bits}
173         f=$FCDISTRO
174         fs=$(shortname $f)
175         buildname="${BASE}--tr${fs}-${ds}-${bits}"
176         command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
177          -d $d -p $p -f $f ${base_option} $buildname $extra_option"
178         run $command
179     done
180
181     for f in $TRUNK_FCDISTROS; do 
182         fs=$(shortname $f)      
183         p=linux${bits}
184         d=planetlab
185         ds=$(shortname $d)
186         buildname="${BASE}--tr${fs}-${ds}-${bits}"
187         command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
188          -d $d -p $p -f $f ${base_option} $buildname $extra_option"
189         run $command
190     done
191 done
192 ##############################