source: create_distribution.py @ 4180

Last change on this file since 4180 was 4170, checked in by ole, 18 years ago

Implemented stored revision information for distributions and allowed get_revision_number to get that information from either stored file or svn as per ticket:125

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
97import sys; sys.exit() 
98
99
100
101# Zip it up
102s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename)
103print s
104system(s)
105
106# Move distro to release area
107s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
108print s
109system(s)
110
111# Clean up
112s = '/bin/rm -rf %s/anuga' %(distro_dir) 
113print s
114system(s)
115
116
117#-----------------------------
118# Get validation_files as well
119
120s = 'mkdir %s/anuga_validation' %distro_dir
121system(s)
122
123s = 'svn export anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\
124    %(distro_dir) 
125print s
126system(s)
127
128s = 'svn export anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\
129    %(distro_dir) 
130print s
131system(s)
132
133# Other validations in here!!!
134
135# Zip it up
136s = 'cd %s;tar cvfz anuga_validation-%s.tgz *'\
137    %(distro_dir, revision)
138print s
139system(s)
140
141# Move distro to release area
142s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
143print s
144system(s)
145
146# Clean up
147s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) 
148print s
149system(s)
150
151
152#-----------------------------
153# Get demos from user manual
154
155#s = 'mkdir %s/anuga_demos' %distro_dir
156#system(s)
157
158s = 'svn export anuga_core/documentation/user_manual/demos %s/anuga_demos'\
159    %(distro_dir) 
160print s
161system(s)
162
163# Zip it up
164s = 'cd %s;tar cvfz anuga_demos-%s.tgz *'\
165    %(distro_dir, revision)
166print s
167system(s)
168
169# Move distro to release area
170s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
171print s
172system(s)
173
174# Clean up
175s = '/bin/rm -rf %s/anuga_demos' %(distro_dir) 
176print s
177system(s)
178
179
180
181#-----------------------------
182# Copy anuga_viewer
183s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s'\
184    %(distro_dir)
185print s
186system(s)
187
188# Move distro to release area
189s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
190print s
191system(s)
192
193#-----------------------------
194# Hey, why not compile and bundle up the LaTeX documentation as well
195
196s = 'cd anuga_core/documentation/user_manual;'
197s += 'python update_anuga_user_manual.py --no_html'
198print s
199system(s)
200
201release_name = 'anuga_user_manual-%s.pdf' %revision
202s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\
203    %(release_dir, release_name)
204print s
205system(s)
206
207
208release_name = 'anuga_installation_guide-%s.pdf' %revision
209s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name)   
210   
211print s
212system(s)
213
214
215
216#-----------------------------
217print 'Done'
218print
219print
220print 'The release files are in %s:' %release_dir
221system('ls -la %s' %release_dir)
222
223
224
225#----------------------------
226# Throw away code to drop all files into the RAMP download area
227# This is hardwired for Ole
228
229if get_user_name() == 'ole' and get_host_name() == 'nautilus':
230
231    # Copy to RAMP
232    s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision)
233    print s
234    system(s)
235   
236    #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)#
237
238
239   
240    # Copy to the ANU
241
242    s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision)
243    print s
244    system(s)
245   
246   
Note: See TracBrowser for help on using the repository browser.