source: create_distribution.py @ 6718

Last change on this file since 6718 was 6426, checked in by ole, 16 years ago

Made create distribution.py always attempt to upload to the ANU

File size: 8.3 KB
Line 
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
23from os import sep, system
24from os.path import join
25from tempfile import mktemp
26from sys import platform, stdout
27from anuga.utilities.system_tools import get_user_name, get_host_name
28from anuga.abstract_2d_finite_volumes.util import get_revision_number
29from anuga.abstract_2d_finite_volumes.util import store_version_info
30from anuga.config import major_revision
31
32from dirs_to_distribute import dirmap
33from anuga.utilities.data_audit_wrapper import IP_verified
34
35if 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
42lsep = '----------------------------------------------------------------------'
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
50svn_revision = get_revision_number()
51revision = '%s_%s' %(major_revision, svn_revision)
52print 'Creating ANUGA revision %s' %revision
53
54distro_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#-----------------------------------
61release_area = '~/anuga_releases'
62s = 'mkdir %s' %release_area
63try:
64    print s   
65    system(s)
66except:
67    pass
68
69
70release_dir = release_area + '/anuga_release_%s' %revision
71s = 'mkdir %s' %release_dir
72try:
73    print s   
74    system(s)
75except:
76    pass
77
78#-----------------------------------------------------
79# Create temporary area for svn to export source files
80#-----------------------------------------------------
81distro_dir = mktemp()
82s = 'mkdir %s' %distro_dir
83print s   
84system(s)
85
86
87#---------------------------------------------------
88# Get the ANUGA directories flagged for distribution
89#---------------------------------------------------
90
91for 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
138store_version_info(destination_path=distro_dir+'/anuga', verbose=True)
139
140
141#---------------------------
142# IP Data Audit
143#---------------------------
144print 'Verifying data IP'
145if 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#------------------
154s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename)
155print s
156system(s)
157
158#----------------------------
159# Move distro to release area
160#----------------------------
161s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
162print s
163system(s)
164
165#---------
166# Clean up
167#---------
168s = '/bin/rm -rf %s/*' %(distro_dir) 
169print s
170system(s)
171
172
173#-----------------------------
174# Copy and rename anuga_viewer
175#-----------------------------
176s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s/anuga_viewer-%s.tgz' %(distro_dir, revision)
177print s
178system(s)
179
180#----------------------------
181# Move viewer to release area
182#----------------------------
183s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
184print s
185system(s)
186
187
188
189#----------------------------------------------
190# Compile and bundle up the LaTeX documentation
191#----------------------------------------------
192print
193print lsep
194print 'Preparing User Manual (see update_anuga_user_manual.log)'
195print lsep
196s = 'cd anuga_core/documentation/user_manual;'
197s += 'python update_anuga_user_manual.py --no_html'
198print s
199system(s + ' 1>update_anuga_user_manual.log 2>/dev/null')
200
201release_name = 'anuga_user_manual-%s.pdf' %revision
202s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\
203    %(release_dir, release_name)
204print s
205system(s)
206
207release_name = 'anuga_installation_guide-%s.pdf' %revision
208s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name)   
209print s
210system(s)
211
212release_name = 'anuga_whats_new-%s.pdf' %revision
213s = '/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s' %(release_dir, release_name)   
214print s
215system(s)
216
217
218#----------------------------
219# Print list of release files
220#----------------------------
221print 'Done'
222print
223print
224print lsep
225print 'The release files are in %s:' %release_dir
226system('ls -la %s' %release_dir)
227print lsep
228print
229print
230
231
232#-------------------------------------
233# Copy release to various destinations
234#-------------------------------------
235answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]')
236if 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)
284s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir)       
285print s
286system(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
295if 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:/d/cit/1/cit/natural_hazard_impacts/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   
315print 'Remember to update' 
316print '    anuga_whats_new.tex'
317print '    sourceforge'
318   
Note: See TracBrowser for help on using the repository browser.