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
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
97import sys; sys.exit() 
98
99
100
[3892]101# Zip it up
102s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename)
103print s
104system(s)
105
[3902]106# Move distro to release area
107s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
108print s
109system(s)
110
[3892]111# Clean up
112s = '/bin/rm -rf %s/anuga' %(distro_dir) 
113print s
114system(s)
115
[3902]116
117#-----------------------------
[3892]118# Get validation_files as well
[3902]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) 
[3892]125print s
126system(s)
127
[4012]128s = 'svn export anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\
129    %(distro_dir) 
130print s
131system(s)
132
[3892]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
[3902]141# Move distro to release area
142s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
143print s
144system(s)
145
[3892]146# Clean up
[3902]147s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) 
[3892]148print s
149system(s)
150
[3987]151
[3902]152#-----------------------------
[3987]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#-----------------------------
[3892]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
[3902]188# Move distro to release area
[3892]189s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
190print s
191system(s)
[3902]192
[3922]193#-----------------------------
194# Hey, why not compile and bundle up the LaTeX documentation as well
[3902]195
[3922]196s = 'cd anuga_core/documentation/user_manual;'
197s += 'python update_anuga_user_manual.py --no_html'
198print s
199system(s)
200
[4122]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)
[3922]204print s
205system(s)
206
[4122]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   
[3922]211print s
212system(s)
213
214
215
[3902]216#-----------------------------
[3892]217print 'Done'
218print
219print
220print 'The release files are in %s:' %release_dir
221system('ls -la %s' %release_dir)
[3934]222
223
224
225#----------------------------
226# Throw away code to drop all files into the RAMP download area
227# This is hardwired for Ole
228
[3937]229if get_user_name() == 'ole' and get_host_name() == 'nautilus':
[3934]230
[3990]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)
[3937]233    print s
234    system(s)
235   
[3990]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
[3991]242    s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision)
[3990]243    print s
244    system(s)
245   
246   
Note: See TracBrowser for help on using the repository browser.