]> git.saurik.com Git - wxWidgets.git/blob - wxPython/distrib/all/build-all
Print start and stop time
[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 # host name of the machine to use for windows builds
18 WIN_HOST=cyclops
19
20 # local dir (from the poerspecitve of the master machine) of the shared
21 # build dir on the windows machine, plus how to mount it there. If the
22 # [u]mount commands are empty then WIN_SHARED will be used directly.
23 WIN_SHARED=./tmp/mnt
24 WIN_MOUNT="smbmount //$WIN_HOST/BUILD $WIN_SHARED -o credentials=/etc/samba/auth.cyclops.robind,dmask=755,fmask=644"
25 WIN_UMOUNT="smbumount $WIN_SHARED"
26
27 # Where is that dir from the remote machine's perspective?
28 WIN_SHARED_REMOTE=/c/BUILD
29
30
31
32 # Same as the above
33 OSX_HOST=bigmac
34 OSX_SHARED=./tmp/mnt/BUILD
35 OSX_MOUNT="smbmount //$OSX_HOST/robind ./tmp/mnt -o credentials=/etc/samba/auth.bigmac.robind,dmask=755,fmask=644"
36 OSX_UMOUNT="smbumount ./tmp/mnt"
37 OSX_SHARED_REMOTE=/Users/robind/BUILD
38
39
40
41 # Alsmost the same... See below
42 LINUX_HOST=rh9
43 LINUX_SHARED=/stuff/temp/BUILD
44 LINUX_MOUNT=
45 LINUX_UMOUNT=
46 LINUX_SHARED_REMOTE=/stuff/temp/BUILD
47
48
49 # Upload server locations
50 UPLOAD_HOST=starship.python.net
51 UPLOAD_DAILY_ROOT=/home/crew/robind/public_html/wxPython/daily
52 UPLOAD_PREVIEW_ROOT=/home/crew/robind/public_html/wxPython/preview
53
54
55
56 # ---------------------------------------------------------------------------
57 # functions
58
59 function usage {
60 echo ""
61 echo "Usage: $0 [command flags...]"
62 echo ""
63 echo "build types:"
64 echo " dryrun Do the build, but don't copy anywhere (default)"
65 echo " daily Do a daily build, copy to starship"
66 echo " release Do a normal release build, copy to starship"
67 echo ""
68 echo "optional command flags:"
69 echo " 2.2 Build for Python 2.2 (default=off)"
70 echo " 2.3 Build for Python 2.3 (default=on)"
71 echo " all Build for all supported Python versions"
72 echo ""
73 echo " skipsource Don't build the source archives, use the ones"
74 echo " already in the staging dir."
75 echo " onlysource Exit after building the source archives"
76 echo " skipwin Don't do the remote Windows build"
77 echo " skiposx Don't do the remote OSX build"
78 echo " skiplinux Don't do the remote Linux build"
79 echo " skipclean Don't do the cleanup step on the remote builds"
80 echo ""
81
82
83 }
84
85 # ---------------------------------------------------------------------------
86
87 # Make sure we are running in the right directory. TODO: make this
88 # test more robust. Currenly we just test for the presence of
89 # 'wxPython' and 'wx' subdirs.
90 if [ ! -d wxPython -o ! -d wx ]; then
91 echo "Please run this script from the root wxPython directory."
92 exit 1
93 fi
94
95
96
97 # Set defaults and check the command line options
98 KIND=dryrun
99 PYVER=2.3
100 skipsource=no
101 onlysource=no
102 skipwin=no
103 skiposx=no
104 skiplinux=no
105 skipclean=no
106
107 for flag in $*; do
108 case $flag in
109 dryrun) KIND=dryrun ;;
110 daily) KIND=daily ;;
111 release) KIND=release ;;
112
113 2.2) PYVER=2.2 ;;
114 2.3) PYVER=2.3 ;;
115 all) PYVER="2.2 2.3" ;;
116
117 skipsource) skipsource=yes ;;
118 onlysource) onlysource=yes ;;
119 skipwin) skipwin=yes ;;
120 skiposx) skiposx=yes ;;
121 skiplinux) skiplinux=yes ;;
122 skipclean) skipclean=yes ;;
123
124 help) usage; exit 1 ;;
125 *) echo "Unknown flag \"$flag\""
126 usage
127 exit 1
128 esac
129 done
130
131
132 # ensure the staging area exists
133 if [ ! -d $STAGING_DIR ]; then
134 mkdir -p $STAGING_DIR
135 fi
136
137 # Figure out the wxPython version number, possibly adjusted for being a daily build
138 if [ $KIND = daily ]; then
139 DAILY=`date +%Y%m%d` # should it include the hour too? 2-digit year?
140 echo $DAILY > DAILY_BUILD
141 fi
142 VERSION=`python -c "import setup;print setup.VERSION"`
143
144
145 #echo VERSION=$VERSION
146 #exit 0
147
148 echo "Getting started at " `date`
149
150 # ---------------------------------------------------------------------------
151 # Make the sources and other basic stuff.
152
153 if [ $skipsource != yes -o $onlysource = yes ]; then
154
155 # clean out the local dist dir
156 rm -f dist/*
157
158 # Regenerate the reST docs
159 echo "Regenerating the reST docs..."
160 cd docs
161 for x in *.txt; do
162 docutils-html $x `basename $x .txt`.html
163 done
164 cd -
165
166 # build the doc and demo tarballs
167 distrib/makedemo
168 distrib/makedocs
169
170 # make the source tarball
171 distrib/makerpm 2.3 skipclean skiprpm gtk2
172
173 # make the source RPMs
174 for ver in $PYVER; do
175 distrib/makerpm $ver skipclean skipcopy skiptar srpm
176 distrib/makerpm $ver skipclean skipcopy skiptar srpm gtk2
177 done
178
179 # Copy everything to the staging dir
180 echo "Moving stuff to $STAGING_DIR..."
181 rm -f dist/*.spec
182 mv dist/* $STAGING_DIR
183 for doc in CHANGES BUILD INSTALL MigrationGuide default; do
184 cp docs/$doc.* $STAGING_DIR
185 done
186
187 # cleanup
188 echo "Cleaning up..."
189 rm -f dist/*
190 rm -rf _build_rpm
191 fi
192
193 if [ $KIND = daily ]; then
194 rm DAILY_BUILD
195 fi
196
197 if [ $onlysource = yes ]; then
198 exit 0
199 fi
200
201 # ---------------------------------------------------------------------------
202 # Windows build
203
204 if [ $skipwin != yes ]; then
205 echo "-=-=- Starting Windows build..."
206
207 # mount the shared folder?
208 if [ -n "$WIN_MOUNT" ]; then
209 echo "Mounting shared folder..."
210 $WIN_MOUNT
211 fi
212
213 # Copy the src file
214 echo "Copying source file..."
215 cp $STAGING_DIR/wxPythonSrc-$VERSION.tar.gz $WIN_SHARED
216
217 # Untar it on the remote machine, and then run the build script
218 echo "Unarchiving source file on $WIN_HOST..."
219 ssh $WIN_HOST "cd $WIN_SHARED_REMOTE && tar xzf wxPythonSrc-$VERSION.tar.gz && rm wxPythonSrc-$VERSION.tar.gz"
220
221 echo "Running build script on $WIN_HOST..."
222 wxdir=$WIN_SHARED_REMOTE/wxPythonSrc-$VERSION
223 cmd=$wxdir/wxPython/distrib/all/build-windows
224 ssh $WIN_HOST "cd $wxdir && $cmd $wxdir $WIN_SHARED_REMOTE $skipclean $VERSION $PYVER"
225
226 echo "Fetching the results..."
227 cp $WIN_SHARED/wxPythonWIN32* $STAGING_DIR
228 ssh $WIN_HOST "cd $WIN_SHARED_REMOTE && rm wxPythonWIN32*"
229
230 # unmount?
231 if [ -n "$WIN_UMOUNT" ]; then
232 echo "Unmounting shared folder..."
233 $WIN_UMOUNT
234 fi
235 fi
236
237
238 # ---------------------------------------------------------------------------
239 # OSX build
240
241 if [ $skiposx != yes ]; then
242 echo "-=-=- Starting OSX build..."
243
244 # mount the shared folder?
245 if [ -n "$OSX_MOUNT" ]; then
246 echo "Mounting shared folder..."
247 $OSX_MOUNT
248 fi
249
250 # Copy the src file
251 echo "Copying source files..."
252 cp $STAGING_DIR/wxPythonSrc-$VERSION.tar.gz $OSX_SHARED
253 cp $STAGING_DIR/wxPythonDocs-$VERSION.tar.gz $OSX_SHARED
254 cp $STAGING_DIR/wxPythonDemo-$VERSION.tar.gz $OSX_SHARED
255
256 # Untar it on the remote machine, and then run the build script
257 echo "Unarchiving source file on $OSX_HOST..."
258 ssh root@$OSX_HOST "cd $OSX_SHARED_REMOTE && tar xzf wxPythonSrc-$VERSION.tar.gz && rm wxPythonSrc-$VERSION.tar.gz"
259
260 echo "Running build script on $OSX_HOST..."
261 wxdir=$OSX_SHARED_REMOTE/wxPythonSrc-$VERSION
262 cmd=$wxdir/wxPython/distrib/all/build-osx
263 ssh root@$OSX_HOST "cd $wxdir && $cmd $wxdir $OSX_SHARED_REMOTE $skipclean $VERSION $PYVER"
264
265 echo "Fetching the results..."
266 cp $OSX_SHARED/wxPythonOSX* $STAGING_DIR
267 ssh root@$OSX_HOST "cd $OSX_SHARED_REMOTE && rm wxPythonOSX*"
268
269 # unmount?
270 if [ -n "$OSX_UMOUNT" ]; then
271 echo "Unmounting shared folder..."
272 $OSX_UMOUNT
273 fi
274 fi
275
276
277 # ---------------------------------------------------------------------------
278 # Linux build
279
280 # This build is optional, check if the target machine is up and
281 # running
282 if [ $skiplinux != yes ]; then
283 if ping -q -c1 -w1 $LINUX_HOST > /dev/null; then
284 # the ping succeeded
285 skiplinux=no
286 else
287 # the ping failed, skip the build
288 skiplinux=yes
289 echo "-----------------------------------------------------------------"
290 echo "The $LINUX_HOST machine is offline, skipping the binary RPM build."
291 echo "-----------------------------------------------------------------"
292 fi
293 fi
294
295
296 if [ $skiplinux != yes ]; then
297 echo "-=-=- Starting Linux build..."
298
299 # The remote linux build is a bit different than the others. The
300 # SRPMs will have already been built in the initial source
301 # building steps, the only thing that the remote build needs to
302 # do is an "rpmbuild --rebuild" for each package. So we'll just
303 # copy the build script over and execute it, there is no need to
304 # unpack the tarball and most of the other steps...
305
306
307 echo "Copying source files..."
308 mkdir -p $LINUX_SHARED
309 cp $STAGING_DIR/wxPython*.src.rpm $LINUX_SHARED
310
311 scp distrib/all/build-linux root@$LINUX_HOST:/tmp > /dev/null
312 ssh root@$LINUX_HOST "cd /tmp && ./build-linux /tmp/wx $LINUX_SHARED_REMOTE $skipclean $VERSION $PYVER"
313
314 echo "Fetching the results..."
315 cp $LINUX_SHARED/wxPythonGTK*.i[0-9]86.rpm $STAGING_DIR
316 rm -r $LINUX_SHARED
317 fi
318
319
320
321
322 # ---------------------------------------------------------------------------
323 # Final disposition of build results...
324
325 chmod a+r $STAGING_DIR/*
326
327 if [ $KIND = dryrun ]; then
328 # we're done
329 echo "Finished at " `date`
330 exit 0
331 fi
332
333
334 if [ $KIND = daily ]; then
335
336 destdir=$UPLOAD_DAILY_ROOT/$DAILY
337 echo "Copying to the starship at $destdir..."
338 ssh $UPLOAD_HOST "mkdir -p $destdir"
339 scp $STAGING_DIR/* $UPLOAD_HOST:/$destdir
340 ssh $UPLOAD_HOST "cd $destdir && ls -al"
341
342
343 echo "Cleaning up staging dir..."
344 rm $STAGING_DIR/*
345 rmdir $STAGING_DIR
346
347 # TODO: something to remove old builds from starship, keeping
348 # only N days worth
349
350 # TODO: Send email to wxPython-dev?
351 DATE=`date`
352 TO=wxPython-dev@lists.wxwidgets.org
353
354 cat <<EOF | /usr/sbin/sendmail $TO
355 From: R'bot <rbot@wxpython.org>
356 To: $TO
357 Subject: New test build uploaded
358 Date: $DATE
359
360 Hi,
361
362 A new test build of wxPython has been uploaded to starship.
363
364 Version: $VERSION
365 Pythons: $PYVER
366 URL: http://starship.python.net/crew/robind/wxPython/daily/$DAILY
367
368 Have fun!
369 R'bot
370
371 EOF
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 echo "Copying to the starship..."
386 destdir=$UPLOAD_PREVIEW_ROOT/$VERSION
387 ssh $UPLOAD_HOST "mkdir -p $destdir"
388 scp $STAGING_DIR/* $UPLOAD_HOST:/$destdir
389
390 echo "Cleaning up staging dir..."
391 rm $STAGING_DIR/*
392 rmdir $STAGING_DIR
393
394 echo "Finished at " `date`
395 exit 0
396 fi
397
398
399 # ---------------------------------------------------------------------------