"""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 import os 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 anuga_release_name = 'anuga-%s' % revision distro_filename = '%s.tgz' % anuga_release_name #----------------------------------- # 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 + '/%s' % anuga_release_name 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) # 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 #---------------------------------------------- # 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') # Copy to distro_dir to become part of one tarball release_name = 'anuga_user_manual-%s.pdf' % revision s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\ %(distro_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' %(distro_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' %(distro_dir, release_name) print s system(s) #------------------ # 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) #---------------------------------------------- # Generate Windows installer #---------------------------------------------- root = os.getcwd() from installation_files.windows.installer import create_config os.chdir('installation_files/windows') # Create ANUGA dir for NSI installer try: os.mkdir('files/%s' % anuga_release_name) os.mkdir('files/anuga_viewer') os.mkdir('files/prereqs') os.mkdir('files/prereqs/netcdf') except: pass # and unpack ANUGA into it s = 'cd files/%s; tar xvfz %s/%s' % (anuga_release_name, release_dir, distro_filename) print s system(s) # Must be replaced by local folder to where SourceForge version is downloaded anuga_viewer_folder = 'anuga_viewer' python = 'python-2.5.4.msi' numpy = 'numpy-1.3.0-win32-superpack-python2.5.exe' scientific_python = 'ScientificPython-2.9.0.win32-py2.5.exe' matplotlib = 'matplotlib-0.99.0.win32-py2.5.exe' netcdf_folder = 'netcdf' mingw = 'MinGW-5.1.6.exe' # Generate NSI file create_config(revision, anuga_release_name, anuga_viewer_folder, python, numpy, scientific_python, matplotlib, netcdf_folder, mingw) # Package up files necessary to compile the installer on Windows and # move to release area try: # Cleanup in case there was something left from a previous attempt s = 'cd %s; /bin/rm -rf windows_installer' % release_dir print s system(s) except: pass # Create subdirectories for windows installer s = 'cd %s; mkdir windows_installer; mkdir windows_installer/files'\ % release_dir print s system(s) # Copy installion scrips and imagery across s = 'cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir print s system(s) # Copy actual files used by Windows installer across s = 'cd files; cp -r * %s/windows_installer/files' % release_dir print s system(s) # Come back to starting directory os.chdir(root) # Grab license file from anuga_core and copy to installer s = 'cp anuga_core/source/anuga/LICENSE.txt %s/windows_installer/files'\ % release_dir print s os.system(s) print 'NSI installer created' #---------------------------- # 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 #------------------------------------- # FIXME (Ole): I don't think this is the way any more # due to changes at SourceForge. 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'