"""Create a distribution of ANUGA from latest revision This script is assumed to be run in the root directory of anuga from a working sandpit connected to svn It will create a distribution of ANUGA from the version which is currently checked out. To use the latest version run svn up before running this script. To use a specific revision (2187, say) run svn up -r 2187 first assuming that create_distribution.py (this script) and anything it depends on still work for that revision. This script works only on Linux """ from os import sep, system, remove from tempfile import mktemp from sys import platform from anuga.utilities.system_tools import get_user_name, get_host_name from anuga.abstract_2d_finite_volumes.util import get_revision_number from anuga.abstract_2d_finite_volumes.util import store_version_info if platform == 'win32': msg = 'This script is not written for Windows.'+\ 'Please run it on a Unix platform' raise Exception, msg # Define main version manually major_revision = '1.0beta' # Refresh sandpit and retrieve svn revision number # from last line in svn update output #filename = mktemp() + '.txt' #s = 'svn update > %s' %filename #print s #system(s) # #fid = open(filename) #last_line = fid.readlines()[-1] #remove(filename) #if not (last_line.startswith('At revision') or\ # last_line.startswith('Updated to revision')): # msg = 'Unexpected output from svn up: %s' %last_line # raise Exception, msg # #fields = last_line.split() #svn_revision = fields[-1][:-1] # Get revision number and create # file with version info for release. # This will mean that the version currently checked out is # the one which will be released. svn_revision = get_revision_number() revision = '%s_%s' %(major_revision, svn_revision) print 'Creating ANUGA revision %s' %revision distro_filename = 'anuga-%s.tgz' %revision # Create area directory release_dir = '~/anuga_release_%s' %revision s = 'mkdir %s' %release_dir try: print s system(s) except: pass # Export a clean directory tree from the working copy to a temporary dir distro_dir = mktemp() s = 'mkdir %s' %distro_dir print s system(s) s = 'svn export -r %d anuga_core/source/anuga %s/anuga' %(svn_revision, distro_dir) print s system(s) # Store file with revision info for use with get_revision_number store_version_info(destination_path=distro_dir+'/anuga', verbose=True) import sys; sys.exit() # Zip it up s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename) print s system(s) # Move distro to release area s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) print s system(s) # Clean up s = '/bin/rm -rf %s/anuga' %(distro_dir) print s system(s) #----------------------------- # Get validation_files as well s = 'mkdir %s/anuga_validation' %distro_dir system(s) s = 'svn export anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\ %(distro_dir) print s system(s) s = 'svn export anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\ %(distro_dir) print s system(s) # Other validations in here!!! # Zip it up s = 'cd %s;tar cvfz anuga_validation-%s.tgz *'\ %(distro_dir, revision) print s system(s) # Move distro to release area s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) print s system(s) # Clean up s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) print s system(s) #----------------------------- # Get demos from user manual #s = 'mkdir %s/anuga_demos' %distro_dir #system(s) s = 'svn export anuga_core/documentation/user_manual/demos %s/anuga_demos'\ %(distro_dir) print s system(s) # Zip it up s = 'cd %s;tar cvfz anuga_demos-%s.tgz *'\ %(distro_dir, revision) print s system(s) # Move distro to release area s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) print s system(s) # Clean up s = '/bin/rm -rf %s/anuga_demos' %(distro_dir) print s system(s) #----------------------------- # Copy anuga_viewer s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s'\ %(distro_dir) print s system(s) # Move distro to release area s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) print s system(s) #----------------------------- # Hey, why not compile and bundle up the LaTeX documentation as well s = 'cd anuga_core/documentation/user_manual;' s += 'python update_anuga_user_manual.py --no_html' print s system(s) release_name = 'anuga_user_manual-%s.pdf' %revision s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\ %(release_dir, release_name) print s system(s) release_name = 'anuga_installation_guide-%s.pdf' %revision s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name) print s system(s) #----------------------------- print 'Done' print print print 'The release files are in %s:' %release_dir system('ls -la %s' %release_dir) #---------------------------- # Throw away code to drop all files into the RAMP download area # This is hardwired for Ole if get_user_name() == 'ole' and get_host_name() == 'nautilus': # Copy to RAMP s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision) print s system(s) #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)# # Copy to the ANU s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision) print s system(s)