source: create_distribution.py @ 4428

Last change on this file since 4428 was 4384, checked in by ole, 17 years ago

Changed destination from risk_assesment_methods to natural_hazard_impacts.

File size: 5.6 KB
RevLine 
[3892]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
[4170]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
[3892]20   This script works only on Linux
21"""
22
23from os import sep, system, remove
24from tempfile import mktemp
25from sys import platform
[3937]26from anuga.utilities.system_tools import get_user_name, get_host_name
[4170]27from anuga.abstract_2d_finite_volumes.util import get_revision_number
28from anuga.abstract_2d_finite_volumes.util import store_version_info
[3892]29
30
31if platform == 'win32':
32    msg = 'This script is not written for Windows.'+\
33          'Please run it on a Unix platform'
34    raise Exception, msg
35
36
37# Define main version manually
[4122]38major_revision = '1.0beta'
[3892]39
40
[4170]41# Refresh sandpit and retrieve svn revision number
[3922]42# from last line in svn update output
[4170]43#filename = mktemp() + '.txt'
44#s = 'svn update > %s' %filename
45#print s
46#system(s)
47#
48#fid = open(filename)
49#last_line = fid.readlines()[-1]
50#remove(filename)
51#if not (last_line.startswith('At revision') or\
52#        last_line.startswith('Updated to revision')):
53#    msg = 'Unexpected output from svn up: %s' %last_line
54#    raise Exception, msg   
55#
56#fields = last_line.split()
57#svn_revision = fields[-1][:-1]
[4168]58
[4170]59# Get revision number and create
[4168]60# file with version info for release.
[4170]61# This will mean that the version currently checked out is
[4168]62# the one which will be released.
63
[4170]64svn_revision = get_revision_number()
[3922]65revision = '%s_%s' %(major_revision, svn_revision)
[3934]66print 'Creating ANUGA revision %s' %revision
67
[3892]68distro_filename = 'anuga-%s.tgz' %revision
69
[3902]70# Create area directory
71release_dir = '~/anuga_release_%s' %revision
72s = 'mkdir %s' %release_dir
73try:
[4170]74    print s   
[3902]75    system(s)
76except:
77    pass
78
79
[4170]80# Export a clean directory tree from the working copy to a temporary dir
[3892]81distro_dir = mktemp()
82s = 'mkdir %s' %distro_dir
[4170]83print s   
[3892]84system(s)
85
[4170]86
87
88s = 'svn export -r %d anuga_core/source/anuga %s/anuga' %(svn_revision,
89                                                          distro_dir) 
[3892]90print s
91system(s)
92
[4170]93
94# Store file with revision info for use with get_revision_number
95store_version_info(destination_path=distro_dir+'/anuga', verbose=True)
96
[3892]97# Zip it up
98s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename)
99print s
100system(s)
101
[3902]102# Move distro to release area
103s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
104print s
105system(s)
106
[3892]107# Clean up
108s = '/bin/rm -rf %s/anuga' %(distro_dir) 
109print s
110system(s)
111
[3902]112
113#-----------------------------
[3892]114# Get validation_files as well
[3902]115
116s = 'mkdir %s/anuga_validation' %distro_dir
117system(s)
118
119s = 'svn export anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\
120    %(distro_dir) 
[3892]121print s
122system(s)
123
[4012]124s = 'svn export anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\
125    %(distro_dir) 
126print s
127system(s)
128
[3892]129# Other validations in here!!!
130
131# Zip it up
132s = 'cd %s;tar cvfz anuga_validation-%s.tgz *'\
133    %(distro_dir, revision)
134print s
135system(s)
136
[3902]137# Move distro to release area
138s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
139print s
140system(s)
141
[3892]142# Clean up
[3902]143s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) 
[3892]144print s
145system(s)
146
[3987]147
[3902]148#-----------------------------
[3987]149# Get demos from user manual
150
151#s = 'mkdir %s/anuga_demos' %distro_dir
152#system(s)
153
154s = 'svn export anuga_core/documentation/user_manual/demos %s/anuga_demos'\
155    %(distro_dir) 
156print s
157system(s)
158
159# Zip it up
160s = 'cd %s;tar cvfz anuga_demos-%s.tgz *'\
161    %(distro_dir, revision)
162print s
163system(s)
164
165# Move distro to release area
166s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
167print s
168system(s)
169
170# Clean up
171s = '/bin/rm -rf %s/anuga_demos' %(distro_dir) 
172print s
173system(s)
174
175
176
177#-----------------------------
[3892]178# Copy anuga_viewer
179s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s'\
180    %(distro_dir)
181print s
182system(s)
183
[3902]184# Move distro to release area
[3892]185s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
186print s
187system(s)
[3902]188
[3922]189#-----------------------------
190# Hey, why not compile and bundle up the LaTeX documentation as well
[3902]191
[3922]192s = 'cd anuga_core/documentation/user_manual;'
193s += 'python update_anuga_user_manual.py --no_html'
194print s
195system(s)
196
[4122]197release_name = 'anuga_user_manual-%s.pdf' %revision
198s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\
199    %(release_dir, release_name)
[3922]200print s
201system(s)
202
[4122]203
204release_name = 'anuga_installation_guide-%s.pdf' %revision
205s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name)   
206   
[3922]207print s
208system(s)
209
210
211
[3902]212#-----------------------------
[3892]213print 'Done'
214print
215print
216print 'The release files are in %s:' %release_dir
217system('ls -la %s' %release_dir)
[3934]218
219
220
221#----------------------------
222# Throw away code to drop all files into the RAMP download area
223# This is hardwired for Ole
224
[3937]225if get_user_name() == 'ole' and get_host_name() == 'nautilus':
[3934]226
[3990]227    # Copy to RAMP
[4384]228    s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/natural_hazard_impacts/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision)
[3937]229    print s
230    system(s)
231   
[3990]232    #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)#
233
234
235   
236    # Copy to the ANU
237
[3991]238    s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision)
[3990]239    print s
240    system(s)
241   
242   
Note: See TracBrowser for help on using the repository browser.