1 | """Create a distribution of ANUGA from latest revision |
---|
2 | |
---|
3 | This script is assumed to be run in the root directory of anuga |
---|
4 | from a working sandpit connected to svn |
---|
5 | |
---|
6 | It will create a distribution of ANUGA from the version which is |
---|
7 | currently checked out. |
---|
8 | |
---|
9 | To use the latest version run |
---|
10 | |
---|
11 | svn up |
---|
12 | |
---|
13 | before running this script. To use a specific revision (2187, say) run |
---|
14 | |
---|
15 | svn up -r 2187 |
---|
16 | |
---|
17 | first assuming that create_distribution.py (this script) and anything |
---|
18 | it depends on still work for that revision. |
---|
19 | |
---|
20 | This script works only on Linux! |
---|
21 | """ |
---|
22 | |
---|
23 | from os import sep, system |
---|
24 | from os.path import join |
---|
25 | from tempfile import mktemp |
---|
26 | from sys import platform, stdout |
---|
27 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
28 | from anuga.abstract_2d_finite_volumes.util import get_revision_number |
---|
29 | from anuga.abstract_2d_finite_volumes.util import store_version_info |
---|
30 | from anuga.config import major_revision |
---|
31 | |
---|
32 | from dirs_to_distribute import dirmap |
---|
33 | from anuga.utilities.data_audit_wrapper import IP_verified |
---|
34 | |
---|
35 | if platform == 'win32': |
---|
36 | msg = 'This script is not written for Windows.'+\ |
---|
37 | 'Please run it on a Unix platform' |
---|
38 | raise Exception, msg |
---|
39 | |
---|
40 | |
---|
41 | # line separator |
---|
42 | lsep = '----------------------------------------------------------------------' |
---|
43 | |
---|
44 | |
---|
45 | # Get svn revision number and create |
---|
46 | # file with version info for release. |
---|
47 | # This will mean that the version currently checked out is |
---|
48 | # the one which will be released. |
---|
49 | |
---|
50 | svn_revision = get_revision_number() |
---|
51 | revision = '%s_%s' %(major_revision, svn_revision) |
---|
52 | print 'Creating ANUGA revision %s' %revision |
---|
53 | |
---|
54 | distro_filename = 'anuga-%s.tgz' %revision |
---|
55 | |
---|
56 | #----------------------------------- |
---|
57 | # Create directory for this release. |
---|
58 | # It will be named like |
---|
59 | # anuga_release_1.0beta_4824 |
---|
60 | #----------------------------------- |
---|
61 | release_area = '~/anuga_releases' |
---|
62 | s = 'mkdir %s' %release_area |
---|
63 | try: |
---|
64 | print s |
---|
65 | system(s) |
---|
66 | except: |
---|
67 | pass |
---|
68 | |
---|
69 | |
---|
70 | release_dir = release_area + '/anuga_release_%s' %revision |
---|
71 | s = 'mkdir %s' %release_dir |
---|
72 | try: |
---|
73 | print s |
---|
74 | system(s) |
---|
75 | except: |
---|
76 | pass |
---|
77 | |
---|
78 | #----------------------------------------------------- |
---|
79 | # Create temporary area for svn to export source files |
---|
80 | #----------------------------------------------------- |
---|
81 | distro_dir = mktemp() |
---|
82 | s = 'mkdir %s' %distro_dir |
---|
83 | print s |
---|
84 | system(s) |
---|
85 | |
---|
86 | |
---|
87 | #--------------------------------------------------- |
---|
88 | # Get the ANUGA directories flagged for distribution |
---|
89 | #--------------------------------------------------- |
---|
90 | |
---|
91 | for source in dirmap: |
---|
92 | |
---|
93 | destination = join(distro_dir, dirmap[source]) |
---|
94 | s = 'svn export -r %d --quiet %s %s' %(svn_revision, |
---|
95 | source, |
---|
96 | destination) |
---|
97 | |
---|
98 | print s |
---|
99 | system(s) |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | #----------------------------- |
---|
104 | # Get validation_files as well |
---|
105 | #----------------------------- |
---|
106 | #s = 'mkdir %s/anuga_validation' %distro_dir |
---|
107 | #system(s) |
---|
108 | # |
---|
109 | #s = 'svn export -r %d --quiet anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\ |
---|
110 | # %(svn_revision, distro_dir) |
---|
111 | #print s |
---|
112 | #system(s) |
---|
113 | |
---|
114 | #s = 'svn export -r %d --quiet anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\ |
---|
115 | # %(svn_revision, distro_dir) |
---|
116 | #print s |
---|
117 | #syst |
---|
118 | |
---|
119 | #s = 'svn export -r %d --quiet anuga_validation/automated_validation_tests %s/anuga_validation/automated_validation_tests'\ |
---|
120 | # %(svn_revision, distro_dir) |
---|
121 | #print s |
---|
122 | #system(s) |
---|
123 | |
---|
124 | # FIXME: Other validations in here as they appear! |
---|
125 | |
---|
126 | |
---|
127 | #--------------------------- |
---|
128 | # Get demos from user manual |
---|
129 | #--------------------------- |
---|
130 | #s = 'svn export -r %d --quiet anuga_core/documentation/user_manual/demos %s/anuga_demos'\ |
---|
131 | # %(svn_revision, distro_dir) |
---|
132 | #print s |
---|
133 | #system(s) |
---|
134 | |
---|
135 | |
---|
136 | |
---|
137 | # Store file with revision info for use with get_revision_number |
---|
138 | store_version_info(destination_path=distro_dir+'/anuga', verbose=True) |
---|
139 | |
---|
140 | |
---|
141 | #--------------------------- |
---|
142 | # IP Data Audit |
---|
143 | #--------------------------- |
---|
144 | print 'Verifying data IP' |
---|
145 | if not IP_verified(distro_dir, verbose=True): |
---|
146 | msg = 'Files have not been verified for IP.\n' |
---|
147 | msg += 'Each data file must have a license file with it.' |
---|
148 | raise Exception, msg |
---|
149 | |
---|
150 | |
---|
151 | #------------------ |
---|
152 | # Zip everything up |
---|
153 | #------------------ |
---|
154 | s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename) |
---|
155 | print s |
---|
156 | system(s) |
---|
157 | |
---|
158 | #---------------------------- |
---|
159 | # Move distro to release area |
---|
160 | #---------------------------- |
---|
161 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
162 | print s |
---|
163 | system(s) |
---|
164 | |
---|
165 | #--------- |
---|
166 | # Clean up |
---|
167 | #--------- |
---|
168 | s = '/bin/rm -rf %s/*' %(distro_dir) |
---|
169 | print s |
---|
170 | system(s) |
---|
171 | |
---|
172 | |
---|
173 | #----------------------------- |
---|
174 | # Copy and rename anuga_viewer |
---|
175 | #----------------------------- |
---|
176 | #s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s/anuga_viewer-%s.tgz' %(distro_dir, revision) |
---|
177 | #print s |
---|
178 | #system(s) |
---|
179 | |
---|
180 | #---------------------------- |
---|
181 | # Move viewer to release area |
---|
182 | #---------------------------- |
---|
183 | #s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
184 | #print s |
---|
185 | #system(s) |
---|
186 | |
---|
187 | |
---|
188 | |
---|
189 | #---------------------------------------------- |
---|
190 | # Compile and bundle up the LaTeX documentation |
---|
191 | #---------------------------------------------- |
---|
192 | print |
---|
193 | print lsep |
---|
194 | print 'Preparing User Manual (see update_anuga_user_manual.log)' |
---|
195 | print lsep |
---|
196 | s = 'cd anuga_core/documentation/user_manual;' |
---|
197 | s += 'python update_anuga_user_manual.py --no_html' |
---|
198 | print s |
---|
199 | system(s + ' 1>update_anuga_user_manual.log 2>/dev/null') |
---|
200 | |
---|
201 | release_name = 'anuga_user_manual-%s.pdf' %revision |
---|
202 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\ |
---|
203 | %(release_dir, release_name) |
---|
204 | print s |
---|
205 | system(s) |
---|
206 | |
---|
207 | release_name = 'anuga_installation_guide-%s.pdf' %revision |
---|
208 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name) |
---|
209 | print s |
---|
210 | system(s) |
---|
211 | |
---|
212 | release_name = 'anuga_whats_new-%s.pdf' %revision |
---|
213 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s' %(release_dir, release_name) |
---|
214 | print s |
---|
215 | system(s) |
---|
216 | |
---|
217 | |
---|
218 | #---------------------------- |
---|
219 | # Print list of release files |
---|
220 | #---------------------------- |
---|
221 | print 'Done' |
---|
222 | print |
---|
223 | print |
---|
224 | print lsep |
---|
225 | print 'The release files are in %s:' %release_dir |
---|
226 | system('ls -la %s' %release_dir) |
---|
227 | print lsep |
---|
228 | print |
---|
229 | print |
---|
230 | |
---|
231 | |
---|
232 | #------------------------------------- |
---|
233 | # Copy release to various destinations |
---|
234 | #------------------------------------- |
---|
235 | answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]') |
---|
236 | if answer.lower() != 'n': |
---|
237 | |
---|
238 | print 'Uploading to sourceforge' |
---|
239 | |
---|
240 | import os, os.path |
---|
241 | release_dir = os.path.expanduser(release_dir) |
---|
242 | os.chdir(release_dir) |
---|
243 | print 'Reading from', os.getcwd() |
---|
244 | |
---|
245 | |
---|
246 | s = 'rsync -avP -e ssh *.* uniomni@frs.sourceforge.net:uploads/' |
---|
247 | print s |
---|
248 | os.system(s) |
---|
249 | |
---|
250 | |
---|
251 | |
---|
252 | #from ftplib import FTP |
---|
253 | #ftp = FTP('upload.sourceforge.net') |
---|
254 | #print ftp.login() # Anonymous |
---|
255 | #print ftp.cwd('incoming') |
---|
256 | # |
---|
257 | #for filename in os.listdir('.'): |
---|
258 | # print 'Uploading %s... ' %filename, |
---|
259 | # stdout.flush() |
---|
260 | # |
---|
261 | # fid=open(filename, 'rb') |
---|
262 | # print ftp.storbinary('STOR %s' %filename, fid) |
---|
263 | # fid.close() |
---|
264 | # |
---|
265 | #print 'FTP done' |
---|
266 | #print ftp.quit() |
---|
267 | |
---|
268 | print |
---|
269 | print lsep |
---|
270 | print ' ********************* NOTE *************************' |
---|
271 | print lsep |
---|
272 | print 'To complete this release you must log into' |
---|
273 | print 'http://sourceforge.net/projects/anuga as ANUGA admin' |
---|
274 | print 'and complete the process by selecting File Releases ' |
---|
275 | print 'in the admin menu there.' |
---|
276 | print lsep |
---|
277 | print |
---|
278 | print |
---|
279 | |
---|
280 | |
---|
281 | |
---|
282 | # Copy to the ANU |
---|
283 | #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision) |
---|
284 | s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir) |
---|
285 | print s |
---|
286 | system(s) |
---|
287 | |
---|
288 | |
---|
289 | #---------------------------- |
---|
290 | # Throw away code to drop all files into the RAMP download area |
---|
291 | # This is hardwired for Ole but shows how such a thing can be done |
---|
292 | # automatically. |
---|
293 | |
---|
294 | |
---|
295 | if get_user_name() == 'ole' and get_host_name() == 'nautilus': |
---|
296 | |
---|
297 | |
---|
298 | answer = raw_input('Do you want to move this to the GA NAS? Y/N [Y]') |
---|
299 | if answer.lower() == 'n': |
---|
300 | import sys; sys.exit() |
---|
301 | |
---|
302 | |
---|
303 | |
---|
304 | print 'Attempt to rsync data to perlite and datamining' |
---|
305 | # Copy to Georisk |
---|
306 | s = 'rsync -avz %s/* onielsen@cyclone:georisk/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' % revision) |
---|
307 | print s |
---|
308 | system(s) |
---|
309 | |
---|
310 | #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)# |
---|
311 | |
---|
312 | |
---|
313 | |
---|
314 | |
---|
315 | print 'Remember to update' |
---|
316 | print ' anuga_whats_new.tex' |
---|
317 | print ' sourceforge' |
---|
318 | |
---|