Disable the use of BerkeleyDB 4.6 on platforms that appear to have
[python.git] / Misc / build.sh
blobfd0e3378896566e40d548c7e3002f095124d0e54
1 #!/bin/sh
3 ## Script to build and test the latest python from svn. It basically
4 ## does this:
5 ## svn up ; ./configure ; make ; make test ; make install ; cd Doc ; make
6 ##
7 ## Logs are kept and rsync'ed to the host. If there are test failure(s),
8 ## information about the failure(s) is mailed.
9 ##
10 ## This script is run on the PSF's machine as user neal via crontab.
12 ## Yes, this script would probably be easier in python, but then
13 ## there's a bootstrap problem. What if Python doesn't build?
15 ## This script should be fairly clean Bourne shell, ie not too many
16 ## bash-isms. We should try to keep it portable to other Unixes.
17 ## Even though it will probably only run on Linux. I'm sure there are
18 ## several GNU-isms currently (date +%s and readlink).
20 ## Perhaps this script should be broken up into 2 (or more) components.
21 ## Building doc is orthogonal to the rest of the python build/test.
24 ## FIXME: we should detect test hangs (eg, if they take more than 45 minutes)
26 ## FIXME: we should run valgrind
27 ## FIXME: we should run code coverage
29 ## Utilities invoked in this script include:
30 ## basename, date, dirname, expr, grep, readlink, uname
31 ## cksum, make, mutt, rsync, svn
33 ## remember where did we started from
34 DIR=`dirname $0`
35 if [ "$DIR" = "" ]; then
36 DIR="."
39 ## make directory absolute
40 DIR=`readlink -f $DIR`
41 FULLPATHNAME="$DIR/`basename $0`"
42 ## we want Misc/..
43 DIR=`dirname $DIR`
45 ## Configurable options
47 FAILURE_SUBJECT="Python Regression Test Failures"
48 #FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com"
49 FAILURE_MAILTO="python-checkins@python.org"
50 #FAILURE_CC="optional--uncomment and set to desired address"
52 REMOTE_SYSTEM="neal@dinsdale.python.org"
53 REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/"
54 RESULT_FILE="$DIR/build/index.html"
55 INSTALL_DIR="/tmp/python-test/local"
56 RSYNC_OPTS="-aC -e ssh"
58 # Always run the installed version of Python.
59 PYTHON=$INSTALL_DIR/bin/python
61 # Python options and regression test program that should always be run.
62 REGRTEST_ARGS="-E -tt $INSTALL_DIR/lib/python2.6/test/regrtest.py"
64 REFLOG="build/reflog.txt.out"
65 # These tests are not stable and falsely report leaks sometimes.
66 # The entire leak report will be mailed if any test not in this list leaks.
67 # Note: test_XXX (none currently) really leak, but are disabled
68 # so we don't send spam. Any test which really leaks should only
69 # be listed here if there are also test cases under Lib/test/leakers.
70 LEAKY_TESTS="test_(asynchat|cmd_line|popen2|socket|smtplib|sys|threadsignals|urllib2_localnet|httpservers)"
72 # Skip these tests altogether when looking for leaks. These tests
73 # do not need to be stored above in LEAKY_TESTS too.
74 # test_compiler almost never finishes with the same number of refs
75 # since it depends on other modules, skip it.
76 # test_logging causes hangs, skip it.
77 LEAKY_SKIPS="-x test_compiler test_logging"
79 # Change this flag to "yes" for old releases to only update/build the docs.
80 BUILD_DISABLED="no"
82 ## utility functions
83 current_time() {
84 date +%s
87 update_status() {
88 now=`current_time`
89 time=`expr $now - $3`
90 echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE
93 place_summary_first() {
94 testf=$1
95 sed -n '/^[0-9][0-9]* tests OK\./,$p' < $testf \
96 | egrep -v '\[[0-9]+ refs\]' > $testf.tmp
97 echo "" >> $testf.tmp
98 cat $testf >> $testf.tmp
99 mv $testf.tmp $testf
102 count_failures () {
103 testf=$1
104 n=`grep -ic " failed:" $testf`
105 if [ $n -eq 1 ] ; then
106 n=`grep " failed:" $testf | sed -e 's/ .*//'`
108 echo $n
111 mail_on_failure() {
112 if [ "$NUM_FAILURES" != "0" ]; then
113 dest=$FAILURE_MAILTO
114 # FAILURE_CC is optional.
115 if [ "$FAILURE_CC" != "" ]; then
116 dest="$dest -c $FAILURE_CC"
118 if [ "x$3" != "x" ] ; then
119 (echo "More important issues:"
120 echo "----------------------"
121 egrep -v "$3" < $2
122 echo ""
123 echo "Less important issues:"
124 echo "----------------------"
125 egrep "$3" < $2)
126 else
127 cat $2
128 fi | mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $dest
132 ## setup
133 cd $DIR
134 mkdir -p build
135 rm -f $RESULT_FILE build/*.out
136 rm -rf $INSTALL_DIR
138 ## create results file
139 TITLE="Automated Python Build Results"
140 echo "<html>" >> $RESULT_FILE
141 echo " <head>" >> $RESULT_FILE
142 echo " <title>$TITLE</title>" >> $RESULT_FILE
143 echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE
144 echo " </head>" >> $RESULT_FILE
145 echo "<body>" >> $RESULT_FILE
146 echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE
147 echo "<table>" >> $RESULT_FILE
148 echo " <tr>" >> $RESULT_FILE
149 echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE
150 echo " </tr><tr>" >> $RESULT_FILE
151 echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE
152 echo " </tr><tr>" >> $RESULT_FILE
153 echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE
154 echo " </tr>" >> $RESULT_FILE
155 echo "</table>" >> $RESULT_FILE
156 echo "<ul>" >> $RESULT_FILE
158 ## update, build, and test
159 ORIG_CHECKSUM=`cksum $FULLPATHNAME`
160 F=svn-update.out
161 start=`current_time`
162 svn update >& build/$F
163 err=$?
164 update_status "Updating" "$F" $start
165 if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then
166 ## FIXME: we should check if this file has changed.
167 ## If it has changed, we should re-run the script to pick up changes.
168 if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then
169 exec $FULLPATHNAME $@
172 F=svn-stat.out
173 start=`current_time`
174 svn stat >& build/$F
175 ## ignore some of the diffs
176 NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F`
177 update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start
179 F=configure.out
180 start=`current_time`
181 ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F
182 err=$?
183 update_status "Configuring" "$F" $start
184 if [ $err = 0 ]; then
185 F=make.out
186 start=`current_time`
187 make >& build/$F
188 err=$?
189 warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"`
190 update_status "Building ($warnings warnings)" "$F" $start
191 if [ $err = 0 ]; then
192 ## make install
193 F=make-install.out
194 start=`current_time`
195 make install >& build/$F
196 update_status "Installing" "$F" $start
198 if [ ! -x $PYTHON ]; then
199 ln -s ${PYTHON}2.* $PYTHON
202 ## make and run basic tests
203 F=make-test.out
204 start=`current_time`
205 $PYTHON $REGRTEST_ARGS -u urlfetch >& build/$F
206 NUM_FAILURES=`count_failures build/$F`
207 place_summary_first build/$F
208 update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start
209 mail_on_failure "basics" build/$F
211 F=make-test-opt.out
212 start=`current_time`
213 $PYTHON -O $REGRTEST_ARGS -u urlfetch >& build/$F
214 NUM_FAILURES=`count_failures build/$F`
215 place_summary_first build/$F
216 update_status "Testing opt ($NUM_FAILURES failures)" "$F" $start
217 mail_on_failure "opt" build/$F
219 ## run the tests looking for leaks
220 F=make-test-refleak.out
221 start=`current_time`
222 ## ensure that the reflog exists so the grep doesn't fail
223 touch $REFLOG
224 $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network,urlfetch $LEAKY_SKIPS >& build/$F
225 LEAK_PAT="($LEAKY_TESTS|sum=0)"
226 NUM_FAILURES=`egrep -vc "$LEAK_PAT" $REFLOG`
227 place_summary_first build/$F
228 update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start
229 mail_on_failure "refleak" $REFLOG "$LEAK_PAT"
231 ## now try to run all the tests
232 F=make-testall.out
233 start=`current_time`
234 ## skip curses when running from cron since there's no terminal
235 ## skip sound since it's not setup on the PSF box (/dev/dsp)
236 $PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F
237 NUM_FAILURES=`count_failures build/$F`
238 place_summary_first build/$F
239 update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
240 mail_on_failure "all" build/$F
246 ## make doc
247 cd $DIR/Doc
248 F="make-doc.out"
249 start=`current_time`
250 # XXX(nnorwitz): For now, keep the code that checks for a conflicted file until
251 # after the first release of 2.6a1 or 3.0a1. At that point, it will be clear
252 # if there will be a similar problem with the new doc system.
254 # Doc/commontex/boilerplate.tex is expected to always have an outstanding
255 # modification for the date. When a release is cut, a conflict occurs.
256 # This allows us to detect this problem and not try to build the docs
257 # which will definitely fail with a conflict.
258 #CONFLICTED_FILE=commontex/boilerplate.tex
259 #conflict_count=`grep -c "<<<" $CONFLICTED_FILE`
260 conflict_count=0
261 if [ $conflict_count != 0 ]; then
262 echo "Conflict detected in $CONFLICTED_FILE. Doc build skipped." > ../build/$F
263 err=1
264 else
265 make update html >& ../build/$F
266 err=$?
268 update_status "Making doc" "$F" $start
269 if [ $err != 0 ]; then
270 NUM_FAILURES=1
271 mail_on_failure "doc" ../build/$F
274 echo "</ul>" >> $RESULT_FILE
275 echo "</body>" >> $RESULT_FILE
276 echo "</html>" >> $RESULT_FILE
278 ## copy results
279 rsync $RSYNC_OPTS build/html/* $REMOTE_SYSTEM:$REMOTE_DIR
280 cd ../build
281 rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/