source: create_distribution.py @ 4605

Last change on this file since 4605 was 4532, checked in by ole, 17 years ago

Disabled rsync of installation files but left code in as an example.

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