source: create_distribution.py @ 4786

Last change on this file since 4786 was 4786, checked in by ole, 16 years ago

Moved major revision info to anuga_config, updated scripts and made userguide include build number in its header.

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