source: create_distribution.py @ 6099

Last change on this file since 6099 was 5748, checked in by ole, 16 years ago

Tiny bug in create_distribution

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    print
149    #raise Exception, msg
150
151
152#------------------
153# Zip everything up
154#------------------
155s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename)
156print s
157system(s)
158
159#----------------------------
160# Move distro to release area
161#----------------------------
162s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
163print s
164system(s)
165
166#---------
167# Clean up
168#---------
169s = '/bin/rm -rf %s/*' %(distro_dir) 
170print s
171system(s)
172
173
174#-----------------------------
175# Copy and rename anuga_viewer
176#-----------------------------
177s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s/anuga_viewer-%s.tgz' %(distro_dir, revision)
178print s
179system(s)
180
181#----------------------------
182# Move viewer to release area
183#----------------------------
184s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
185print s
186system(s)
187
188
189
190#----------------------------------------------
191# Compile and bundle up the LaTeX documentation
192#----------------------------------------------
193print
194print lsep
195print 'Preparing User Manual (see update_anuga_user_manual.log)'
196print lsep
197s = 'cd anuga_core/documentation/user_manual;'
198s += 'python update_anuga_user_manual.py --no_html'
199print s
200system(s + ' 1>update_anuga_user_manual.log 2>/dev/null')
201
202release_name = 'anuga_user_manual-%s.pdf' %revision
203s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\
204    %(release_dir, release_name)
205print s
206system(s)
207
208release_name = 'anuga_installation_guide-%s.pdf' %revision
209s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name)   
210print s
211system(s)
212
213release_name = 'anuga_whats_new-%s.pdf' %revision
214s = '/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s' %(release_dir, release_name)   
215print s
216system(s)
217
218
219#----------------------------
220# Print list of release files
221#----------------------------
222print 'Done'
223print
224print
225print lsep
226print 'The release files are in %s:' %release_dir
227system('ls -la %s' %release_dir)
228print lsep
229print
230print
231
232
233#-------------------------------------
234# Copy release to various destinations
235#-------------------------------------
236answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]')
237if answer.lower() != 'n':
238   
239    print 'Uploading to sourceforge'
240
241    import os, os.path
242    release_dir = os.path.expanduser(release_dir)
243    os.chdir(release_dir)
244    print 'Reading from', os.getcwd()
245
246
247    s = 'rsync -avP -e ssh *.* uniomni@frs.sourceforge.net:uploads/'
248    print s
249    os.system(s)
250
251   
252
253    #from ftplib import FTP
254    #ftp = FTP('upload.sourceforge.net')
255    #print ftp.login() # Anonymous
256    #print ftp.cwd('incoming')
257    #
258    #for filename in os.listdir('.'):
259    #    print 'Uploading %s... ' %filename,
260    #    stdout.flush()
261    #
262    #    fid=open(filename, 'rb')
263    #    print ftp.storbinary('STOR %s' %filename, fid)
264    #    fid.close()
265    #
266    #print 'FTP done'
267    #print ftp.quit()
268
269    print
270    print lsep
271    print '    ********************* NOTE *************************'
272    print lsep
273    print 'To complete this release you must log into'
274    print 'http://sourceforge.net/projects/anuga as ANUGA admin'
275    print 'and complete the process by selecting File Releases '
276    print 'in the admin menu there.'
277    print lsep
278    print
279    print
280   
281
282
283#----------------------------
284# Throw away code to drop all files into the RAMP download area
285# This is hardwired for Ole but shows how such a thing can be done
286# automatically.
287
288if get_user_name() == 'ole' and get_host_name() == 'nautilus':
289
290
291    answer = raw_input('Do you want to move this to perlite and ANU? Y/N [Y]')
292    if answer.lower() == 'n':
293        import sys; sys.exit()
294
295       
296
297    print 'Attempt to rsync data to perlite and datamining'
298    # Copy to Georisk
299    s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/natural_hazard_impacts/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision)
300    print s
301    system(s)
302   
303    #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)#
304
305
306    # Copy to the ANU
307    #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision)
308    s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir)       
309    print s
310    system(s)
311   
312   
313    print 'Remember to update' 
314    print '    anuga_whats_new.tex'
315    print '    sourceforge'
316   
Note: See TracBrowser for help on using the repository browser.