"""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 from os.path import join from tempfile import mktemp from sys import platform, stdout 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 from anuga.config import major_revision from dirs_to_distribute import dirmap from anuga.utilities.data_audit_wrapper import IP_verified if platform == 'win32': msg = 'This script is not written for Windows.'+\ 'Please run it on a Unix platform' raise Exception, msg # line separator lsep = '----------------------------------------------------------------------' # Get svn 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 directory for this release. # It will be named like # anuga_release_1.0beta_4824 #----------------------------------- release_area = '~/anuga_releases' s = 'mkdir %s' %release_area try: print s system(s) except: pass release_dir = release_area + '/anuga_release_%s' %revision s = 'mkdir %s' %release_dir try: print s system(s) except: pass #----------------------------------------------------- # Create temporary area for svn to export source files #----------------------------------------------------- distro_dir = mktemp() s = 'mkdir %s' %distro_dir print s system(s) #--------------------------------------------------- # Get the ANUGA directories flagged for distribution #--------------------------------------------------- for source in dirmap: destination = join(distro_dir, dirmap[source]) s = 'svn export -r %d --quiet %s %s' %(svn_revision, source, destination) print s system(s) #----------------------------- # Get validation_files as well #----------------------------- #s = 'mkdir %s/anuga_validation' %distro_dir #system(s) # #s = 'svn export -r %d --quiet anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\ # %(svn_revision, distro_dir) #print s #system(s) #s = 'svn export -r %d --quiet anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\ # %(svn_revision, distro_dir) #print s #syst #s = 'svn export -r %d --quiet anuga_validation/automated_validation_tests %s/anuga_validation/automated_validation_tests'\ # %(svn_revision, distro_dir) #print s #system(s) # FIXME: Other validations in here as they appear! #--------------------------- # Get demos from user manual #--------------------------- #s = 'svn export -r %d --quiet anuga_core/documentation/user_manual/demos %s/anuga_demos'\ # %(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) #--------------------------- # IP Data Audit #--------------------------- print 'Verifying data IP' if not IP_verified(distro_dir, verbose=True): msg = 'Files have not been verified for IP.\n' msg += 'Each data file must have a license file with it.' raise Exception, msg #------------------ # Zip everything 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/*' %(distro_dir) print s system(s) #----------------------------- # Copy and rename anuga_viewer #----------------------------- #s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s/anuga_viewer-%s.tgz' %(distro_dir, revision) #print s #system(s) #---------------------------- # Move viewer to release area #---------------------------- #s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) #print s #system(s) #---------------------------------------------- # Compile and bundle up the LaTeX documentation #---------------------------------------------- print print lsep print 'Preparing User Manual (see update_anuga_user_manual.log)' print lsep s = 'cd anuga_core/documentation/user_manual;' s += 'python update_anuga_user_manual.py --no_html' print s system(s + ' 1>update_anuga_user_manual.log 2>/dev/null') 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) release_name = 'anuga_whats_new-%s.pdf' %revision s = '/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s' %(release_dir, release_name) print s system(s) #---------------------------- # Print list of release files #---------------------------- print 'Done' print print print lsep print 'The release files are in %s:' %release_dir system('ls -la %s' %release_dir) print lsep print print #------------------------------------- # Copy release to various destinations #------------------------------------- answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]') if answer.lower() != 'n': print 'Uploading to sourceforge' import os, os.path release_dir = os.path.expanduser(release_dir) os.chdir(release_dir) print 'Reading from', os.getcwd() s = 'rsync -avP -e ssh *.* uniomni@frs.sourceforge.net:uploads/' print s os.system(s) #from ftplib import FTP #ftp = FTP('upload.sourceforge.net') #print ftp.login() # Anonymous #print ftp.cwd('incoming') # #for filename in os.listdir('.'): # print 'Uploading %s... ' %filename, # stdout.flush() # # fid=open(filename, 'rb') # print ftp.storbinary('STOR %s' %filename, fid) # fid.close() # #print 'FTP done' #print ftp.quit() print print lsep print ' ********************* NOTE *************************' print lsep print 'To complete this release you must log into' print 'http://sourceforge.net/projects/anuga as ANUGA admin' print 'and complete the process by selecting File Releases ' print 'in the admin menu there.' print lsep print print # Copy to the ANU #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision) s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir) print s system(s) #---------------------------- # Throw away code to drop all files into the RAMP download area # This is hardwired for Ole but shows how such a thing can be done # automatically. if get_user_name() == 'ole' and get_host_name() == 'nautilus': answer = raw_input('Do you want to move this to the GA NAS? Y/N [Y]') if answer.lower() == 'n': import sys; sys.exit() print 'Attempt to rsync data to perlite and datamining' # Copy to Georisk s = 'rsync -avz %s/* onielsen@cyclone:georisk/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)# print 'Remember to update' print ' anuga_whats_new.tex' print ' sourceforge'