**** Merged from MCS ****
[mono-project.git] / mcs / tools / tinderbox / tinderbox.sh
blob3b99163d99c2c12e59b8a7ece1800df43e25dbd6
1 #!/bin/bash
3 # TOPDIR: set this to the directory containing
4 # your 'mono' and 'mcs' directories. Do NOT use '~' here.
5 TOPDIR=$HOME/mono
7 # BACKUP: initially this directory should contain a working install of mono.
8 # this directory should minimally contain the 'bin' and 'lib' dirs.
9 # after each successful build, the results are placed in here.
10 BACKUP=$TOPDIR/install.bak
12 # INSTALL: this is used as the install directory for
13 # the various stages of the build.
14 INSTALL=$TOPDIR/install
16 # SENDMAIL: uncomment this line if you want to send notifications.
17 # be careful to check the recipients below before running this script!
18 SENDMAIL=$TOPDIR/mcs/tools/tinderbox/smtp
20 # EMAIL_*: notification addresses. please change these before running!
21 EMAIL_FATAL="piersh@friskit.com"
22 EMAIL_MESSAGE="mono-patches@lists.ximian.com"
23 #EMAIL_MESSAGE="piersh@friskit.com"
24 #EMAIL_MESSAGE="mono-hackers-list@ximian.com"
25 EMAIL_FROM="piersh@friskit.com"
26 EMAIL_CC="-c mono-hackers-list@lists.ximian.com"
27 EMAIL_HOST="zeus.sfhq.friskit.com"
29 LOGBASE=$TOPDIR/.build.log
30 LOG=$LOGBASE.txt
31 LOGPREV=$LOGBASE.prev
32 LOGFATAL=$LOGBASE.fatal
33 LOGDATE=$TOPDIR/.build.date
34 LOGLOG=$TOPDIR/.build.log.log
35 BUILDMSG=$TOPDIR/.build.msg
36 export LOGDATE
38 DELAY_SUCCESS=5m # wait after a successful build
39 DELAY_CHECK_BROKEN=5m # wait while verifying the build is broken
40 DELAY_STILL_BROKEN=3m # wait while waiting for fix
41 DELAY_BROKEN=5m # wait after notification sent
43 FILTER_LOG="sed -e 's/^in <0x[0-9a-z]*>//' -e 's/:[0-9]*): WARNING \*\*:/): WARNING **/' -e 's/^\[[0-9][0-9]*:[0-9][0-9]*\] - .*//' -e 's/^[0-9][0-9]* - Member cache//' -e 's/^[0-9][0-9]* - Misc counter//' -e 's/: [0-9]* Trace\/breakpoint/ : Trace\/breakpoint/' -e 's/Needed to allocate blacklisted block at 0x[0-9a-f]*//'"
45 function fatal ()
47 $SENDMAIL -h $EMAIL_HOST -f $EMAIL_FROM -t $EMAIL_FATAL -a $LOGFATAL -s "[MONOBUILD] FATAL ERROR (`uname -s -m`)"
48 echo FATAL: `date` >> $LOGLOG
49 echo FATAL ERROR
50 exit 1
53 function build_mono ()
55 # try to build
57 echo building...
59 cd $TOPDIR
61 rm -f $LOGFATAL
62 touch $LOGFATAL
64 [ -f $LOG ] && mv $LOG $LOGPREV
65 touch $LOG
67 # restore tools from backup
68 rm -fr $INSTALL
69 cp -a $BACKUP $INSTALL
71 # update from CVS
72 cvs -z3 update -APd mcs mono 2>&1 | tee -a $LOG
73 [ $PIPESTATUS == "0" ] || return 1
75 # clean mcs
76 cd $TOPDIR/mcs
77 make -f makefile.gnu clean 2>&1 | tee -a $LOG
78 [ $PIPESTATUS == "0" ] || return 1
80 # build JAY
81 cd $TOPDIR/mcs/jay
82 make -f makefile.gnu 2>&1 | tee -a $LOG
83 [ $PIPESTATUS == "0" ] || return 1
85 # build MCS compiler
86 cd $TOPDIR/mcs/mcs
87 make -f makefile.gnu 2>&1 | tee -a $LOG
88 [ $PIPESTATUS == "0" ] || return 1
90 # build CORLIB with old tools
91 cd $TOPDIR/mcs/class/corlib
92 make -f makefile.gnu 2>&1 | tee -a $LOG
93 [ $PIPESTATUS == "0" ] || return 1
95 # copy new MCS and CORLIB to build tools
96 cp -f $TOPDIR/mcs/class/lib/corlib.dll $INSTALL/lib/
97 cp -f $TOPDIR/mcs/mcs/mcs.exe $INSTALL/bin/
101 cd $TOPDIR/mono
103 # configure mono build
104 rm -f config.cache
105 ./autogen.sh --prefix=$INSTALL 2>&1 | tee -a $LOG
106 [ $PIPESTATUS == "0" ] || return 1
108 # clean mono
109 make clean 2>&1 | tee -a $LOG
110 [ $PIPESTATUS == "0" ] || return 1
112 # build mono
113 make 2>&1 | tee -a $LOG
114 [ $PIPESTATUS == "0" ] || return 1
116 # install runtime
117 cd $TOPDIR/mono/mono
118 make install 2>&1 | tee -a $LOG
119 [ $PIPESTATUS == "0" ] || return 1
123 # clean/make runtime libraries/tools
124 cd $TOPDIR/mcs
125 make -f makefile.gnu clean 2>&1 | tee -a $LOG
126 [ $PIPESTATUS == "0" ] || return 1
128 make -f makefile.gnu 2>&1 | tee -a $LOG
129 [ $PIPESTATUS == "0" ] || return 1
133 # retrieve runtime libraries
134 cd $TOPDIR/mono/runtime
135 rm -f *.dll *.exe
137 # install everything
138 cd $TOPDIR/mono
139 make install 2>&1 | tee -a $LOG
140 [ $PIPESTATUS == "0" ] || return 1
143 # test mcs self-build
144 cd $TOPDIR/mcs/mcs
145 make -f makefile.gnu clean 2>&1 | tee -a $LOG
146 [ $PIPESTATUS == "0" ] || return 1
147 make -f makefile.gnu 2>&1 | tee -a $LOG
148 [ $PIPESTATUS == "0" ] || return 1
151 # test corlib self-build
152 cd $TOPDIR/mcs/class/corlib
153 make -f makefile.gnu clean 2>&1 | tee -a $LOG
154 [ $PIPESTATUS == "0" ] || return 1
155 make -f makefile.gnu 2>&1 | tee -a $LOG
156 [ $PIPESTATUS == "0" ] || return 1
159 # it worked, backup build tools
160 rm -fr $BACKUP
161 cp -a $INSTALL $BACKUP
163 return 0
166 function compare_logs ()
168 touch $LOG $LOGPREV
169 echo Comparing build logs
170 eval $FILTER_LOG $LOG > $LOG.tmp
171 eval $FILTER_LOG $LOGPREV > $LOGPREV.tmp
172 diff -b --brief $LOG.tmp $LOGPREV.tmp
175 function build_fixed ()
177 echo "Build fixed: `date`" > $BUILDMSG
178 echo "Previous breakage: `cat .build.date.last_fail`" >> $BUILDMSG
179 echo "Previous build: `cat .build.date.last_success`" >> $BUILDMSG
180 echo >> $BUILDMSG
182 $SENDMAIL -h $EMAIL_HOST -f $EMAIL_FROM -t $EMAIL_MESSAGE $EMAIL_CC -s "[MONOBUILD] fixed (`uname -s -m`)" -m $BUILDMSG
183 rm -f $BUILDMSG
186 function build_failed ()
188 echo "Build broken: `date`" > $BUILDMSG
189 echo "Broken since: `cat .build.date.last_fail`" >> $BUILDMSG
190 echo "Previous build: `cat .build.date.last_success`" >> $BUILDMSG
191 echo >> $BUILDMSG
193 sed -e 's/$/ /' < $LOG > errors.txt
194 tail -25 errors.txt >> $BUILDMSG
195 rm -f errors.txt.gz
196 gzip errors.txt
198 $SENDMAIL -h $EMAIL_HOST -f $EMAIL_FROM -t $EMAIL_MESSAGE $EMAIL_CC -a errors.txt.gz -s "[MONOBUILD] broken (`uname -s -m`)" -m $BUILDMSG
199 rm -f $BUILDMSG errors.txt.gz
202 function stabilize ()
204 cd $TOPDIR
205 while ! compare_logs ; do
207 date > $LOGDATE.last_fail
208 echo "|||||||||||||||||||||||||"
209 echo "|||||| LOGS DIFFER ||||||"
210 echo "|||||||||||||||||||||||||"
211 echo CHECK: `date` >> $LOGLOG
213 echo sleeping for $DELAY_CHECK_BROKEN
214 sleep $DELAY_CHECK_BROKEN
216 if build_mono ; then
217 return 0
220 cd $TOPDIR
222 done
223 return 1
226 [ -f $LOGPREV ] && mv $LOGPREV $LOG
228 while [ 1 ] ; do
230 cd $TOPDIR
232 if build_mono ; then
234 cd $TOPDIR
236 echo "|||||||||||||||||||||||||"
237 echo "|||| BUILD SUCCEEDED ||||"
238 echo "|||||||||||||||||||||||||"
239 echo SUCCESS: `date` >> $LOGLOG
240 date > $LOGDATE.last_success
241 echo sleeping for $DELAY_SUCCESS
242 sleep $DELAY_SUCCESS
244 else
246 if ! stabilize ; then
248 build_failed
250 echo "||||||||||||||||||||||"
251 echo "|||| BUILD BROKEN ||||"
252 echo "||||||||||||||||||||||"
253 echo BROKEN: `date` >> $LOGLOG
254 date > $LOGDATE.last_fail
255 echo sleeping for $DELAY_BROKEN
256 sleep $DELAY_BROKEN
258 until build_mono ; do
260 cd $TOPDIR
261 echo "||||||||||||||||||||||||||||"
262 echo "|||| BUILD STILL BROKEN ||||"
263 echo "||||||||||||||||||||||||||||"
264 echo STILL BROKEN: `date` >> $LOGLOG
265 date > $LOGDATE.last_fail
266 echo sleeping for $DELAY_STILL_BROKEN
267 sleep $DELAY_STILL_BROKEN
269 done
271 cd $TOPDIR
272 build_fixed
273 echo "|||||||||||||||||||||"
274 echo "|||| BUILD FIXED ||||"
275 echo "|||||||||||||||||||||"
276 echo FIXED: `date` >> $LOGLOG
277 date > $LOGDATE.last_success
278 echo sleeping for $DELAY_SUCCESS
279 sleep $DELAY_SUCCESS
285 done