source: create_distribution.py @ 4786

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

Moved major revision info to anuga_config, updated scripts and made userguide include build number in its header.

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