source: create_distribution.py @ 5570

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

Small modification to create_distribution.py

File size: 8.3 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
[5018]20   This script works only on Linux!
[3892]21"""
22
[4931]23from os import sep, system
[5068]24from os.path import join
[3892]25from tempfile import mktemp
[4531]26from sys import platform, stdout
[3937]27from anuga.utilities.system_tools import get_user_name, get_host_name
[4170]28from anuga.abstract_2d_finite_volumes.util import get_revision_number
29from anuga.abstract_2d_finite_volumes.util import store_version_info
[5016]30from anuga.config import major_revision
[3892]31
[5068]32from dirs_to_distribute import dirmap
[5018]33from anuga.utilities.data_audit_wrapper import IP_verified
[3892]34
35if platform == 'win32':
36    msg = 'This script is not written for Windows.'+\
37          'Please run it on a Unix platform'
38    raise Exception, msg
39
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
[4837]56#-----------------------------------
57# Create directory for this release.
58# It will be named like
59#        anuga_release_1.0beta_4824
60#-----------------------------------
[5540]61release_area = '~/anuga_releases'
62s = 'mkdir %s' %release_area
63try:
64    print s   
65    system(s)
66except:
67    pass
68
69
70release_dir = release_area + '/anuga_release_%s' %revision
[3902]71s = 'mkdir %s' %release_dir
72try:
[4170]73    print s   
[3902]74    system(s)
75except:
76    pass
77
[4837]78#-----------------------------------------------------
79# Create temporary area for svn to export source files
80#-----------------------------------------------------
[3892]81distro_dir = mktemp()
82s = 'mkdir %s' %distro_dir
[4170]83print s   
[3892]84system(s)
85
86
[5068]87#---------------------------------------------------
88# Get the ANUGA directories flagged for distribution
89#---------------------------------------------------
90
91for source in dirmap:
92   
93    destination = join(distro_dir, dirmap[source])
94    s = 'svn export -r %d --quiet %s %s' %(svn_revision,
95                                           source,
96                                           destination)
97
98    print s
99    system(s)
100
101
102
[3902]103#-----------------------------
[3892]104# Get validation_files as well
[4837]105#-----------------------------
[5068]106#s = 'mkdir %s/anuga_validation' %distro_dir
107#system(s)
108#
109#s = 'svn export -r %d --quiet anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\
110#    %(svn_revision, distro_dir)
111#print s
112#system(s)
[3902]113
[5064]114#s = 'svn export -r %d --quiet anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\
115#    %(svn_revision, distro_dir)
116#print s
[5068]117#syst
118
119#s = 'svn export -r %d --quiet anuga_validation/automated_validation_tests %s/anuga_validation/automated_validation_tests'\
120#    %(svn_revision, distro_dir)
121#print s
[5064]122#system(s)
[4012]123
[4837]124# FIXME: Other validations in here as they appear!
[3902]125
[3892]126
[4837]127#---------------------------
[3987]128# Get demos from user manual
[4837]129#---------------------------
[5068]130#s = 'svn export -r %d --quiet anuga_core/documentation/user_manual/demos %s/anuga_demos'\
131#    %(svn_revision, distro_dir)
132#print s
133#system(s)
[3987]134
[4865]135
[5068]136
[5016]137# Store file with revision info for use with get_revision_number
138store_version_info(destination_path=distro_dir+'/anuga', verbose=True)
[4865]139
140
[5016]141#---------------------------
142# IP Data Audit
143#---------------------------
144print 'Verifying data IP'
[5028]145if not IP_verified(distro_dir, verbose=True):
[5016]146    msg = 'Files have not been verified for IP.\n'
147    msg += 'Each data file must have a license file with it.'
[5514]148    print
149    #raise Exception, msg
[5016]150
151
[4802]152#------------------
153# Zip everything up
[4837]154#------------------
[4802]155s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename)
[3987]156print s
157system(s)
158
[4837]159#----------------------------
[3987]160# Move distro to release area
[4837]161#----------------------------
[3987]162s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
163print s
164system(s)
165
[4837]166#---------
[3987]167# Clean up
[4837]168#---------
[4802]169s = '/bin/rm -rf %s/*' %(distro_dir) 
[3987]170print s
171system(s)
172
173
174#-----------------------------
[4531]175# Copy and rename anuga_viewer
[4837]176#-----------------------------
[4531]177s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s/anuga_viewer-%s.tgz' %(distro_dir, revision)
[3892]178print s
179system(s)
180
[4837]181#----------------------------
[4531]182# Move viewer to release area
[4837]183#----------------------------
[3892]184s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) 
185print s
186system(s)
[3902]187
[4531]188
189
[4837]190#----------------------------------------------
191# Compile and bundle up the LaTeX documentation
192#----------------------------------------------
[4531]193print
194print lsep
195print 'Preparing User Manual (see update_anuga_user_manual.log)'
196print lsep
[3922]197s = 'cd anuga_core/documentation/user_manual;'
198s += 'python update_anuga_user_manual.py --no_html'
199print s
[4531]200system(s + ' 1>update_anuga_user_manual.log 2>/dev/null')
[3922]201
[4122]202release_name = 'anuga_user_manual-%s.pdf' %revision
203s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\
204    %(release_dir, release_name)
[3922]205print s
206system(s)
207
[4122]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)   
[3922]210print s
211system(s)
212
[5513]213release_name = 'anuga_whats_new-%s.pdf' %revision
214s = '/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s' %(release_dir, release_name)   
215print s
216system(s)
[3922]217
[5513]218
[4837]219#----------------------------
220# Print list of release files
221#----------------------------
[3892]222print 'Done'
223print
224print
[4531]225print lsep
[3892]226print 'The release files are in %s:' %release_dir
227system('ls -la %s' %release_dir)
[4531]228print lsep
229print
230print
[3934]231
[4837]232
233#-------------------------------------
234# Copy release to various destinations
235#-------------------------------------
[4531]236answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]')
237if answer.lower() != 'n':
238   
239    print 'Uploading to sourceforge'
[3934]240
[4531]241    import os, os.path
242    release_dir = os.path.expanduser(release_dir)
243    os.chdir(release_dir)
244    print 'Reading from', os.getcwd()
245
246
247    from ftplib import FTP
248    ftp = FTP('upload.sourceforge.net')
249    print ftp.login() # Anonymous
250    print ftp.cwd('incoming')
251
252
253    for filename in os.listdir('.'):
254        print 'Uploading %s... ' %filename,
255        stdout.flush()
256
257        fid=open(filename, 'rb')
258        print ftp.storbinary('STOR %s' %filename, fid)
259        fid.close()
260
261    print 'FTP done'
262    print ftp.quit()
263
264    print
265    print lsep
266    print '    ********************* NOTE *************************'
267    print lsep
268    print 'To complete this release you must log into'
269    print 'http://sourceforge.net/projects/anuga as ANUGA admin'
270    print 'and complete the process by selecting File Releases '
271    print 'in the admin menu there.'
272    print lsep
273    print
274    print
275   
276
277
[3934]278#----------------------------
279# Throw away code to drop all files into the RAMP download area
[4532]280# This is hardwired for Ole but shows how such a thing can be done
281# automatically.
[3934]282
[3937]283if get_user_name() == 'ole' and get_host_name() == 'nautilus':
[3934]284
[4802]285
286    answer = raw_input('Do you want to move this to perlite and ANU? Y/N [Y]')
287    if answer.lower() == 'n':
288        import sys; sys.exit()
289
290       
291    #------------------------------
292    print 'Uploading to sourceforge'
293
294
295   
296
[4531]297    print 'Attempt to rsync data to perlite and datamining'
[4802]298    # Copy to NHIP
[4384]299    s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/natural_hazard_impacts/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision)
[3937]300    print s
301    system(s)
302   
[3990]303    #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)#
304
305
306    # Copy to the ANU
[5438]307    #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision)
308    s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir)       
[5423]309    print s
310    system(s)
[3990]311   
312   
[5540]313    print 'Remember to update' 
314    print '    anuga_whats_new.tex'
315    print '    sourceforge'
316   
Note: See TracBrowser for help on using the repository browser.