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