source: create_distribution.py @ 5514

Last change on this file since 5514 was 5514, checked in by ole, 11 years ago

Updated user manual and create distribution

File size: 8.0 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_dir = '~/anuga_release_%s' %revision
62s = 'mkdir %s' %release_dir
63try:
64    print s   
65    system(s)
66except:
67    pass
68
69#-----------------------------------------------------
70# Create temporary area for svn to export source files
71#-----------------------------------------------------
72distro_dir = mktemp()
73s = 'mkdir %s' %distro_dir
74print s   
75system(s)
76
77
78#---------------------------------------------------
79# Get the ANUGA directories flagged for distribution
80#---------------------------------------------------
81
82for source in dirmap:
83   
84    destination = join(distro_dir, dirmap[source])
85    s = 'svn export -r %d --quiet %s %s' %(svn_revision,
86                                           source,
87                                           destination)
88
89    print s
90    system(s)
91
92
93
94#-----------------------------
95# Get validation_files as well
96#-----------------------------
97#s = 'mkdir %s/anuga_validation' %distro_dir
98#system(s)
99#
100#s = 'svn export -r %d --quiet anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\
101#    %(svn_revision, distro_dir)
102#print s
103#system(s)
104
105#s = 'svn export -r %d --quiet anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\
106#    %(svn_revision, distro_dir)
107#print s
108#syst
109
110#s = 'svn export -r %d --quiet anuga_validation/automated_validation_tests %s/anuga_validation/automated_validation_tests'\
111#    %(svn_revision, distro_dir)
112#print s
113#system(s)
114
115# FIXME: Other validations in here as they appear!
116
117
118#---------------------------
119# Get demos from user manual
120#---------------------------
121#s = 'svn export -r %d --quiet anuga_core/documentation/user_manual/demos %s/anuga_demos'\
122#    %(svn_revision, distro_dir)
123#print s
124#system(s)
125
126
127
128# Store file with revision info for use with get_revision_number
129store_version_info(destination_path=distro_dir+'/anuga', verbose=True)
130
131
132#---------------------------
133# IP Data Audit
134#---------------------------
135print 'Verifying data IP'
136if not IP_verified(distro_dir, verbose=True):
137    msg = 'Files have not been verified for IP.\n'
138    msg += 'Each data file must have a license file with it.'
139    print
140    #raise Exception, msg
141
142
143#------------------
144# Zip everything up
145#------------------
146s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename)
147print s
148system(s)
149
150#----------------------------
151# Move distro to release area
152#----------------------------
153s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
154print s
155system(s)
156
157#---------
158# Clean up
159#---------
160s = '/bin/rm -rf %s/*' %(distro_dir) 
161print s
162system(s)
163
164
165#-----------------------------
166# Copy and rename anuga_viewer
167#-----------------------------
168s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s/anuga_viewer-%s.tgz' %(distro_dir, revision)
169print s
170system(s)
171
172#----------------------------
173# Move viewer to release area
174#----------------------------
175s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
176print s
177system(s)
178
179
180
181#----------------------------------------------
182# Compile and bundle up the LaTeX documentation
183#----------------------------------------------
184print
185print lsep
186print 'Preparing User Manual (see update_anuga_user_manual.log)'
187print lsep
188s = 'cd anuga_core/documentation/user_manual;'
189s += 'python update_anuga_user_manual.py --no_html'
190print s
191system(s + ' 1>update_anuga_user_manual.log 2>/dev/null')
192
193release_name = 'anuga_user_manual-%s.pdf' %revision
194s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\
195    %(release_dir, release_name)
196print s
197system(s)
198
199release_name = 'anuga_installation_guide-%s.pdf' %revision
200s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name)   
201print s
202system(s)
203
204release_name = 'anuga_whats_new-%s.pdf' %revision
205s = '/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s' %(release_dir, release_name)   
206print s
207system(s)
208
209
210#----------------------------
211# Print list of release files
212#----------------------------
213print 'Done'
214print
215print
216print lsep
217print 'The release files are in %s:' %release_dir
218system('ls -la %s' %release_dir)
219print lsep
220print
221print
222
223
224#-------------------------------------
225# Copy release to various destinations
226#-------------------------------------
227answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]')
228if answer.lower() != 'n':
229   
230    print 'Uploading to sourceforge'
231
232    import os, os.path
233    release_dir = os.path.expanduser(release_dir)
234    os.chdir(release_dir)
235    print 'Reading from', os.getcwd()
236
237
238    from ftplib import FTP
239    ftp = FTP('upload.sourceforge.net')
240    print ftp.login() # Anonymous
241    print ftp.cwd('incoming')
242
243
244    for filename in os.listdir('.'):
245        print 'Uploading %s... ' %filename,
246        stdout.flush()
247
248        fid=open(filename, 'rb')
249        print ftp.storbinary('STOR %s' %filename, fid)
250        fid.close()
251
252    print 'FTP done'
253    print ftp.quit()
254
255    print
256    print lsep
257    print '    ********************* NOTE *************************'
258    print lsep
259    print 'To complete this release you must log into'
260    print 'http://sourceforge.net/projects/anuga as ANUGA admin'
261    print 'and complete the process by selecting File Releases '
262    print 'in the admin menu there.'
263    print lsep
264    print
265    print
266   
267
268
269#----------------------------
270# Throw away code to drop all files into the RAMP download area
271# This is hardwired for Ole but shows how such a thing can be done
272# automatically.
273
274if get_user_name() == 'ole' and get_host_name() == 'nautilus':
275
276
277    answer = raw_input('Do you want to move this to perlite and ANU? Y/N [Y]')
278    if answer.lower() == 'n':
279        import sys; sys.exit()
280
281       
282    #------------------------------
283    print 'Uploading to sourceforge'
284
285
286   
287
288    print 'Attempt to rsync data to perlite and datamining'
289    # Copy to NHIP
290    s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/natural_hazard_impacts/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision)
291    print s
292    system(s)
293   
294    #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)#
295
296
297    # Copy to the ANU
298    #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision)
299    s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir)       
300    print s
301    system(s)
302   
303   
Note: See TracBrowser for help on using the repository browser.