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
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
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
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
38major_revision = '1.0beta'
39
40
41# Refresh sandpit and retrieve svn revision number
42# from last line in svn update output
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]
58
59# Get revision number and create
60# file with version info for release.
61# This will mean that the version currently checked out is
62# the one which will be released.
63
64svn_revision = get_revision_number()
65revision = '%s_%s' %(major_revision, svn_revision)
66print 'Creating ANUGA revision %s' %revision
67
68distro_filename = 'anuga-%s.tgz' %revision
69
70# Create area directory
71release_dir = '~/anuga_release_%s' %revision
72s = 'mkdir %s' %release_dir
73try:
74    print s   
75    system(s)
76except:
77    pass
78
79
80# Export a clean directory tree from the working copy to a temporary dir
81distro_dir = mktemp()
82s = 'mkdir %s' %distro_dir
83print s   
84system(s)
85
86
87
88s = 'svn export -r %d anuga_core/source/anuga %s/anuga' %(svn_revision,
89                                                          distro_dir) 
90print s
91system(s)
92
93
94# Store file with revision info for use with get_revision_number
95store_version_info(destination_path=distro_dir+'/anuga', verbose=True)
96
97# Zip it up
98s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename)
99print s
100system(s)
101
102# Move distro to release area
103s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
104print s
105system(s)
106
107# Clean up
108s = '/bin/rm -rf %s/anuga' %(distro_dir) 
109print s
110system(s)
111
112
113#-----------------------------
114# Get validation_files as well
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) 
121print s
122system(s)
123
124s = 'svn export anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\
125    %(distro_dir) 
126print s
127system(s)
128
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
137# Move distro to release area
138s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
139print s
140system(s)
141
142# Clean up
143s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) 
144print s
145system(s)
146
147
148#-----------------------------
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#-----------------------------
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
184# Move distro to release area
185s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
186print s
187system(s)
188
189#-----------------------------
190# Hey, why not compile and bundle up the LaTeX documentation as well
191
192s = 'cd anuga_core/documentation/user_manual;'
193s += 'python update_anuga_user_manual.py --no_html'
194print s
195system(s)
196
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)
200print s
201system(s)
202
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   
207print s
208system(s)
209
210
211
212#-----------------------------
213print 'Done'
214print
215print
216print 'The release files are in %s:' %release_dir
217system('ls -la %s' %release_dir)
218
219
220
221#----------------------------
222# Throw away code to drop all files into the RAMP download area
223# This is hardwired for Ole
224
225if get_user_name() == 'ole' and get_host_name() == 'nautilus':
226
227    # Copy to RAMP
228    s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/natural_hazard_impacts/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision)
229    print s
230    system(s)
231   
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
238    s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision)
239    print s
240    system(s)
241   
242   
Note: See TracBrowser for help on using the repository browser.