04e8a6ce4ed4416795616e0a718b604099efcc20
[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) 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=rc21
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         -vd) shift; VS_DISTROS="$1" ;;
47         -b) shift; BASE="$1" ;;
48         -bb) BUILD_BRANCH=true ;;
49         -bt) BUILD_TRUNK=true ;;
50         -O) RETRY=true ;;
51         -T) TEST=true ;;
52         -n) DRY_RUN=true ;;
53         -z) MINOR="" ;;
54         *) usage ;;
55     esac
56     shift
57 done
58
59 DEFAULT_FCDISTROS="f8"
60 DEFAULT_BITS="32 64"
61 DEFAULT_BASE="@DATE@"
62
63 function trunk_builds () {
64     DEFAULT_MAJOR_DISTROS=""
65     DEFAULT_VS_DISTROS=""
66 # 5.0 ready for planetlab distro only so far
67     DEFAULT_TRUNK_DISTROS="planetlab"
68 #    DEFAULT_TRUNK_DISTROS="onelab planetlab"
69 }
70
71 function branch_builds () {
72     DEFAULT_MAJOR_DISTROS="onelab planetlab"
73     DEFAULT_VS_DISTROS=""
74     DEFAULT_BITS="32"
75     DEFAULT_TRUNK_DISTROS=""
76 }
77
78 function tagged_builds () {
79     DEFAULT_MAJOR_DISTROS="onelab planetlab"
80     DEFAULT_VS_DISTROS="onelab"
81     DEFAULT_TRUNK_DISTROS=""
82 }
83
84 if [ -n "$BUILD_BRANCH" ] ; then
85     branch_builds
86     BUILDOPT="-s http://svn.planet-lab.org/svn/build/branches/${MAJOR}"
87 elif [ -n "$BUILD_TRUNK" ] ; then
88     trunk_builds
89     BUILDOPT=""
90 else
91     tagged_builds
92     BUILDOPT="-s http://svn.planet-lab.org/svn/build/tags/${MAJOR}-${MINOR}"
93 fi
94
95 [[ -n "$@" ]] && usage
96
97 # export any of these to override - this is for manual use only
98 if [ -z "$MAJOR_DISTROS" ] ;    then MAJOR_DISTROS=$DEFAULT_MAJOR_DISTROS ;     else manual=true ; fi
99 if [ -z "$FCDISTROS" ] ;        then FCDISTROS=$DEFAULT_FCDISTROS ;             else manual=true ; fi
100 if [ -z "$BITS" ] ;             then BITS=$DEFAULT_BITS ;                       else manual=true ; fi
101 if [ -z "$TRUNK_DISTROS" ] ;    then TRUNK_DISTROS=$DEFAULT_TRUNK_DISTROS ;     else manual=true ; fi
102 if [ -z "$VS_DISTROS" ] ;       then VS_DISTROS=$DEFAULT_VS_DISTROS ;           else manual=true ; fi
103 if [ -z "$BASE" ] ;             then BASE=$DEFAULT_BASE ;                       else manual=true ; fi
104 [ -n "$RETRY" ] &&      { extra_option="$extra_option -O" ; manual=true ; }
105 [ -n "$TEST" ] &&       { extra_option="$extra_option -T" ; manual=true ; }
106 [ -n "$DRY_RUN" ] &&    { manual=true ; }
107
108 ############################## ${MAJOR}
109 for bits in $BITS; do
110     for f in $FCDISTROS ; do 
111         for d in $MAJOR_DISTROS ; do
112             p=linux${bits}
113             s=$(shortname $d)
114             if [ -n "$BUILD_BRANCH" ] ; then
115                 buildname="${d}-${MAJOR}-@DATE@.1lab-${f}-${bits}"
116             elif [ -n "$BUILD_TRUNK" ] ; then
117                 buildname="${BASE}--${s}.${MAJOR}--${f}-${bits}"
118             else
119                 buildname="${d}-${MAJOR}-${MINOR}.1lab-${f}-${bits}"
120             fi
121             command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
122                 -d $d -p $p -f $f -t ${d}-tags-${MAJOR}.mk \
123                 -b $buildname $extra_option"
124             run $command
125         done
126     done
127 done
128
129 ############################## ${MAJOR}/centos5
130 # centos5 : for both archs, make the vserver rpms
131 # does not test, so skip if test is requested
132 if [ -z "$TEST" ] ; then
133     f=centos5
134     for d in $VS_DISTROS ; do
135         for bits in $BITS ; do
136             p=linux${bits}
137             s=$(shortname $d)
138             if [ -n "$BUILD_BRANCH" ] ; then 
139                 buildname="${d}-${MAJOR}-@DATE@.1lab-${f}-${bits}"
140             elif [ -n "$BUILD_TRUNK" ] ; then
141                 buildname="${BASE}--${s}.${MAJOR}--${f}-${bits}"
142             else
143                 buildname="${d}-${MAJOR}-${MINOR}.1lab-${f}-${bits}"
144             fi
145             command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
146             -d $d -p $p -f $f -t ${d}-tags-${MAJOR}.mk \
147             -b $buildname -B vserver"
148             run $command
149         done
150     done
151 fi
152
153 ############################## TRUNK
154 # raw - std planetlab x f8 x 32bits for deploying on alpha nodes
155 for d in $TRUNK_DISTROS; do
156     for bits in $BITS; do
157         p=linux${bits}
158         s=$(shortname $d)
159         buildname="${BASE}--tr${s}-${bits}"
160         command="/root/bin/vbuild-nightly.sh -m onelab-build@one-lab.org ${BUILDOPT} \
161          -d $d -p $p -b $buildname $extra_option"
162         run $command
163     done
164 done
165
166 ##############################