source: create_distribution.py @ 4668

Last change on this file since 4668 was 4532, checked in by ole, 18 years ago

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

File size: 6.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
[4531]25from sys import platform, stdout
[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
[4531]40# line separator
41lsep = '----------------------------------------------------------------------'
[3892]42
[4168]43
[4531]44# Get svn revision number and create
[4168]45# file with version info for release.
[4170]46# This will mean that the version currently checked out is
[4168]47# the one which will be released.
48
[4170]49svn_revision = get_revision_number()
[3922]50revision = '%s_%s' %(major_revision, svn_revision)
[3934]51print 'Creating ANUGA revision %s' %revision
52
[3892]53distro_filename = 'anuga-%s.tgz' %revision
54
[3902]55# Create area directory
56release_dir = '~/anuga_release_%s' %revision
57s = 'mkdir %s' %release_dir
58try:
[4170]59    print s   
[3902]60    system(s)
61except:
62    pass
63
64
[4170]65# Export a clean directory tree from the working copy to a temporary dir
[3892]66distro_dir = mktemp()
67s = 'mkdir %s' %distro_dir
[4170]68print s   
[3892]69system(s)
70
[4170]71
72
73s = 'svn export -r %d anuga_core/source/anuga %s/anuga' %(svn_revision,
74                                                          distro_dir) 
[3892]75print s
76system(s)
77
[4170]78
79# Store file with revision info for use with get_revision_number
80store_version_info(destination_path=distro_dir+'/anuga', verbose=True)
81
[3892]82# Zip it up
83s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename)
84print s
85system(s)
86
[3902]87# Move distro to release area
88s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
89print s
90system(s)
91
[3892]92# Clean up
93s = '/bin/rm -rf %s/anuga' %(distro_dir) 
94print s
95system(s)
96
[3902]97
98#-----------------------------
[3892]99# Get validation_files as well
[3902]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) 
[3892]106print s
107system(s)
108
[4012]109s = 'svn export anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\
110    %(distro_dir) 
111print s
112system(s)
113
[3892]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
[3902]122# Move distro to release area
123s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
124print s
125system(s)
126
[3892]127# Clean up
[3902]128s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) 
[3892]129print s
130system(s)
131
[3987]132
[3902]133#-----------------------------
[3987]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#-----------------------------
[4531]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)
[3892]165print s
166system(s)
167
[4531]168
169# Move viewer to release area
[3892]170s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
171print s
172system(s)
[3902]173
[4531]174
175
[3922]176#-----------------------------
177# Hey, why not compile and bundle up the LaTeX documentation as well
[3902]178
[4531]179print
180print lsep
181print 'Preparing User Manual (see update_anuga_user_manual.log)'
182print lsep
[3922]183s = 'cd anuga_core/documentation/user_manual;'
184s += 'python update_anuga_user_manual.py --no_html'
185print s
[4531]186system(s + ' 1>update_anuga_user_manual.log 2>/dev/null')
[3922]187
[4122]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)
[3922]191print s
192system(s)
193
[4122]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   
[3922]197print s
198system(s)
199
200
[4531]201#-----------------------------
[3922]202
[3892]203print 'Done'
204print
205print
[4531]206print lsep
[3892]207print 'The release files are in %s:' %release_dir
208system('ls -la %s' %release_dir)
[4531]209print lsep
210print
211print
[3934]212
[4531]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'
[3934]218
219
[4531]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
[4532]257import sys; sys.exit() 
[4531]258
[3934]259#----------------------------
260# Throw away code to drop all files into the RAMP download area
[4532]261# This is hardwired for Ole but shows how such a thing can be done
262# automatically.
[3934]263
[3937]264if get_user_name() == 'ole' and get_host_name() == 'nautilus':
[3934]265
[4531]266    print 'Attempt to rsync data to perlite and datamining'
[3990]267    # Copy to RAMP
[4384]268    s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/natural_hazard_impacts/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision)
[3937]269    print s
270    system(s)
271   
[3990]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
[4531]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)
[3990]280   
281   
Note: See TracBrowser for help on using the repository browser.