source: create_distribution.py @ 5064

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

removed solitary waves from this.

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