]> git.saurik.com Git - wxWidgets.git/blob - wxPython/distrib/all/build-all
Use $ on variables!!!
[wxWidgets.git] / wxPython / distrib / all / build-all
1 #!/bin/bash
2 # ---------------------------------------------------------------------------
3 # Master build script for building all the installers and such on all the
4 # build machines in my lab, and then distributing the results as needed.
5 # ---------------------------------------------------------------------------
6
7 set -o errexit
8 #set -o xtrace
9
10 # ---------------------------------------------------------------------------
11 # Some control variables...
12
13 # the local spot that we put everything when done, before possibly copying
14 # to remote hosts
15 STAGING_DIR=./BUILD
16
17
18 # host name of the machine to use for windows builds
19 WIN_HOST=beast
20 # Where is the build dir from the remote machine's perspective?
21 WIN_BUILD=/c/BUILD
22
23
24 # Just like the above
25 OSX_HOST_panther=bigmac
26 OSX_HOST_jaguar=whopper
27 OSX_BUILD=/BUILD
28
29
30 # Alsmost the same... See below for hosts and other info
31 LINUX_BUILD=/tmp/BUILD
32
33
34 # Upload server locations
35 UPLOAD_HOST=starship.python.net
36 UPLOAD_DAILY_ROOT=/home/crew/robind/public_html/wxPython/daily
37 UPLOAD_PREVIEW_ROOT=/home/crew/robind/public_html/wxPython/preview
38
39
40
41 # ---------------------------------------------------------------------------
42 # functions
43
44 function usage {
45 echo ""
46 echo "Usage: $0 [command flags...]"
47 echo ""
48 echo "build types:"
49 echo " dryrun Do the build, but don't copy anywhere (default)"
50 echo " daily Do a daily build, copy to starship"
51 echo " release Do a normal release (cantidate) build, copy to starship"
52 echo ""
53 echo "optional command flags:"
54 echo " 2.2 Build for Python 2.2 (default=off)"
55 echo " 2.3 Build for Python 2.3 (default=on)"
56 echo " all Build for all supported Python versions"
57 echo ""
58 echo " skipsource Don't build the source archives, use the ones"
59 echo " already in the staging dir."
60 echo " onlysource Exit after building the source and docs archives"
61 echo " skipdocs Don't rebuild the docs"
62 echo " skipwin Don't do the remote Windows build"
63 echo " skiposx Don't do the remote OSX build"
64 echo " skiplinux Don't do the remote Linux build"
65 echo " skipclean Don't do the cleanup step on the remote builds"
66 echo " skipupload Don't upload the builds to starship"
67 echo ""
68
69
70 }
71
72 # ---------------------------------------------------------------------------
73
74 # Make sure we are running in the right directory. TODO: make this
75 # test more robust. Currenly we just test for the presence of
76 # 'wxPython' and 'wx' subdirs.
77 if [ ! -d wxPython -o ! -d wx ]; then
78 echo "Please run this script from the root wxPython directory."
79 exit 1
80 fi
81
82
83
84 # Set defaults and check the command line options
85 KIND=dryrun
86 PYVER=2.3
87 skipsource=no
88 onlysource=no
89 skipdocs=no
90 skipwin=no
91 skiposx=no
92 skiplinux=no
93 skipclean=no
94 skipupload=no
95
96 for flag in $*; do
97 case $flag in
98 dryrun) KIND=dryrun ;;
99 daily) KIND=daily ;;
100 release) KIND=release ;;
101
102 2.2) PYVER=2.2 ;;
103 2.3) PYVER=2.3 ;;
104 all) PYVER="2.2 2.3" ;;
105
106 skipsource) skipsource=yes ;;
107 onlysource) onlysource=yes ;;
108 skipdocs) skipdocs=yes ;;
109 skipwin) skipwin=yes ;;
110 skiposx) skiposx=yes ;;
111 skiplinux) skiplinux=yes ;;
112 skipclean) skipclean=yes ;;
113 skipupload) skipupload=yes ;;
114
115 help) usage; exit 1 ;;
116 *) echo "Unknown flag \"$flag\""
117 usage
118 exit 1
119 esac
120 done
121
122
123 # ensure the staging area exists
124 if [ ! -d $STAGING_DIR ]; then
125 mkdir -p $STAGING_DIR
126 fi
127
128 # Figure out the wxPython version number, possibly adjusted for being a daily build
129 if [ $KIND = daily ]; then
130 DAILY=`date +%Y%m%d` # should it include the hour too? 2-digit year?
131 echo $DAILY > DAILY_BUILD
132 fi
133 VERSION=`python -c "import setup;print setup.VERSION"`
134
135
136 #echo VERSION=$VERSION
137 #exit 0
138
139
140 echo "Getting started at " `date`
141
142 # ---------------------------------------------------------------------------
143 # Make the sources and other basic stuff.
144
145 if [ $skipsource != yes -o $onlysource = yes ]; then
146
147 # clean out the local dist dir
148 rm -f dist/*
149
150 if [ $skipdocs != yes ]; then
151 # Regenerate the reST docs
152 echo "Regenerating the reST docs..."
153 cd docs
154 for x in *.txt; do
155 docutils-html $x `basename $x .txt`.html
156 done
157 cd -
158
159 # build the doc and demo tarballs
160 distrib/makedemo
161 distrib/makedocs
162
163 # build the new docs too
164 docs/bin/everything
165 fi
166
167 # make the source tarball and srpm
168 distrib/makerpm 2.3 srpm
169
170 # Copy everything to the staging dir
171 echo "Moving stuff to $STAGING_DIR..."
172 mv dist/* $STAGING_DIR
173
174 if [ $skipdocs != yes ]; then
175 for doc in CHANGES BUILD INSTALL MigrationGuide default; do
176 cp docs/$doc.* $STAGING_DIR
177 done
178 fi
179
180 # cleanup
181 echo "Cleaning up..."
182 rm -f dist/*
183 fi
184
185 if [ $KIND = daily ]; then
186 rm DAILY_BUILD
187 fi
188
189 if [ $onlysource = yes ]; then
190 exit 0
191 fi
192
193 # ---------------------------------------------------------------------------
194 # Windows build
195
196 if [ $skipwin != yes ]; then
197 echo "-=-=- Starting Windows build..."
198
199 echo "Copying source file and build script..."
200 scp $STAGING_DIR/wxPython-src-$VERSION.tar.gz \
201 distrib/all/build-windows \
202 $WIN_HOST:$WIN_BUILD
203
204 echo "Running build script on $WIN_HOST..."
205 wxdir=$WIN_BUILD/wxPython-src-$VERSION
206 cmd=./build-windows
207 ssh $WIN_HOST "cd $WIN_BUILD && $cmd $wxdir $WIN_BUILD $skipclean $VERSION $PYVER && rm $cmd"
208
209 echo "Fetching the results..."
210 scp "$WIN_HOST:$WIN_BUILD/wxPython*-win32*" $STAGING_DIR
211 ssh $WIN_HOST "rm $WIN_BUILD/wxPython*-win32*"
212 fi
213
214
215 # ---------------------------------------------------------------------------
216 # OSX build
217
218 function DoOSXBuild {
219 local host=$1
220 local flavor=$2
221
222 # test if the target machine is online
223 if ping -q -c1 -w1 $host > /dev/null; then
224 echo "-----------------------------------------------------------------"
225 echo " The $host machine is online, OSX-$flavor build continuing..."
226 echo "-----------------------------------------------------------------"
227 else
228 echo "-----------------------------------------------------------------"
229 echo "The $host machine is offline, skipping the OSX-$flavor build."
230 echo "-----------------------------------------------------------------"
231 return 0
232 fi
233
234 echo "-=-=- Starting OSX-$flavor build on $host..."
235
236 echo "Copying source files and build script..."
237 ssh root@$host "mkdir -p $OSX_BUILD && rm -rf $OSX_BUILD/* || true"
238 #ssh root@$host "mkdir -p $OSX_BUILD || true"
239 scp $STAGING_DIR/wxPython-src-$VERSION.tar.gz \
240 $STAGING_DIR/wxPython-docs-$VERSION.tar.gz \
241 $STAGING_DIR/wxPython-demo-$VERSION.tar.gz \
242 distrib/all/build-osx \
243 root@$host:$OSX_BUILD
244
245 echo "Running build script on $host..."
246 wxdir=$OSX_BUILD/wxPython-src-$VERSION
247 cmd=./build-osx
248 ssh root@$host "cd $OSX_BUILD && $cmd $wxdir $OSX_BUILD $skipclean $VERSION $flavor $PYVER && rm $cmd"
249
250 echo "Fetching the results..."
251 scp "root@$host:$OSX_BUILD/wxPython*-osx*" $STAGING_DIR
252 ssh root@$host "rm $OSX_BUILD/wxPython*-osx*"
253
254 }
255
256
257 if [ $skiposx != yes ]; then
258
259 DoOSXBuild $OSX_HOST_jaguar jaguar
260 DoOSXBuild $OSX_HOST_panther panther
261
262 fi
263
264
265 # ---------------------------------------------------------------------------
266 # Linux build
267
268 # The remote Linux builds are different than those above. The source
269 # RPMs were already built in the source step, and so building the
270 # binary RPMs is a very simple followup step. But then add to that
271 # the fact that we need to build on more than one distro...
272
273 function DoLinuxBuild {
274 local host=$1
275 local reltag=$2
276 shift;shift
277 local pyver=$@
278
279 # test if the target machine is online
280 if ping -q -c1 -w1 $host > /dev/null; then
281 echo "-----------------------------------------------------------------"
282 echo " The $host machine is online, build continuing..."
283 echo "-----------------------------------------------------------------"
284 else
285 echo "-----------------------------------------------------------------"
286 echo "The $host machine is offline, skipping the binary RPM build."
287 echo "-----------------------------------------------------------------"
288 return 0
289 fi
290
291 echo "Copying source files and build script..."
292 ssh root@$host "mkdir -p $LINUX_BUILD && rm -rf $LINUX_BUILD/*"
293 scp $STAGING_DIR/wxPython-src* $STAGING_DIR/wxPython.spec\
294 distrib/all/build-linux \
295 root@$host:$LINUX_BUILD
296
297 echo "Running build script on $host..."
298 cmd=./build-linux
299 ssh root@$host "cd $LINUX_BUILD && ./build-linux $reltag $skipclean $VERSION $pyver"
300
301 echo "Fetching the results..."
302 scp "root@$host:$LINUX_BUILD/wxPython*.i[0-9]86.rpm" $STAGING_DIR
303 ssh root@$host "rm $LINUX_BUILD/wxPython*.i[0-9]86.rpm"
304
305 }
306
307 if [ $skiplinux != yes ]; then
308
309 DoLinuxBuild co-rh9 rh9 $PYVER
310 DoLinuxBuild co-fc2 fc2 2.3
311
312 fi
313
314
315 # ---------------------------------------------------------------------------
316 # Final disposition of build results...
317
318 chmod a+r $STAGING_DIR/*
319
320 if [ $KIND = dryrun ]; then
321 # we're done
322 echo "Finished at " `date`
323 exit 0
324 fi
325
326
327 if [ $KIND = daily ]; then
328
329 echo "Copying to the local file server..."
330 destdir=/stuff/temp/$VERSION
331 mkdir -p $destdir
332 cp $STAGING_DIR/* $destdir
333
334 if [ $skipupload != yes ]; then
335 destdir=$UPLOAD_DAILY_ROOT/$DAILY
336 echo "Copying to the starship at $destdir..."
337 ssh $UPLOAD_HOST "mkdir -p $destdir"
338 scp $STAGING_DIR/* $UPLOAD_HOST:/$destdir
339 ssh $UPLOAD_HOST "cd $destdir && ls -al"
340
341
342 # TODO: something to remove old builds from starship, keeping
343 # only N days worth
344
345 # Send email to wxPython-dev
346 DATE=`date`
347 TO=wxPython-dev@lists.wxwidgets.org
348
349 cat <<EOF | /usr/sbin/sendmail $TO
350 From: R'bot <rbot@wxpython.org>
351 To: $TO
352 Subject: $DAILY test build uploaded
353 Date: $DATE
354
355 Hi,
356
357 A new test build of wxPython has been uploaded to starship.
358
359 Version: $VERSION
360 URL: http://starship.python.net/crew/robind/wxPython/daily/$DAILY
361 Changes: http://starship.python.net/crew/robind/wxPython/daily/$DAILY/CHANGES.html
362
363 Have fun!
364 R'bot
365
366 EOF
367 fi
368
369 echo "Cleaning up staging dir..."
370 rm $STAGING_DIR/*
371 rmdir $STAGING_DIR
372
373 echo "Finished at " `date`
374 exit 0
375 fi
376
377
378 if [ $KIND = release ]; then
379
380 echo "Copying to the local file server..."
381 destdir=/stuff/Development/wxPython/dist/$VERSION
382 mkdir -p $destdir
383 cp $STAGING_DIR/* $destdir
384
385 if [ $skipupload != yes ]; then
386 echo "Copying to the starship..."
387 destdir=$UPLOAD_PREVIEW_ROOT/$VERSION
388 ssh $UPLOAD_HOST "mkdir -p $destdir"
389 scp $STAGING_DIR/* $UPLOAD_HOST:/$destdir
390
391 # Send email to wxPython-dev
392 DATE=`date`
393 TO=wxPython-dev@lists.wxwidgets.org
394
395 cat <<EOF | /usr/sbin/sendmail $TO
396 From: R'bot <rbot@wxpython.org>
397 To: $TO
398 Subject: $VERSION release candidate build uploaded
399 Date: $DATE
400
401 Hi,
402
403 A new RC build of wxPython has been uploaded to starship.
404
405 Version: $VERSION
406 URL: http://starship.python.net/crew/robind/wxPython/preview/$VERSION
407 Changes: http://starship.python.net/crew/robind/wxPython/preview/$VERSION/CHANGES.html
408
409 Have fun!
410 R'bot
411
412 EOF
413
414 fi
415
416 echo "Cleaning up staging dir..."
417 rm $STAGING_DIR/*
418 rmdir $STAGING_DIR
419
420 echo "Finished at " `date`
421 exit 0
422 fi
423
424
425 # ---------------------------------------------------------------------------