source: trunk/create_distribution.py @ 9341

Last change on this file since 9341 was 7901, checked in by wilsonr, 15 years ago

Changes to match the windows installer creator.

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
[7901]23import sys
[7489]24import os
[7901]25import tempfile
26
[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
[5068]31from dirs_to_distribute import dirmap
[5018]32from anuga.utilities.data_audit_wrapper import IP_verified
[3892]33
[7506]34
[7901]35if sys.platform == 'win32':
36    msg = ('This script is not written for Windows.  '
37           'Please run it on a Unix platform')
38    raise Exception(msg)
[3892]39
[7901]40def do_cmd(cmd, blind=True):
41    """Execute command.  Ignore errors if blind=True."""
[3892]42
[7901]43    try:
44        xlog(cmd)
45        os.system(cmd)
46    except:
47        if not blind:
48            raise
[3892]49
[4168]50
[7901]51def get_release_number():
52    """Get release information and create release name.
[4168]53
[7901]54    Get release numbers from the current directory.
55
56    Returns a string which is of the form 'anuga-X-Y-Z' where X is the
57    major release number, Y is the minor and Z is the bug number.
58    """
59   
60    curr_dir = os.getcwd()
61    curr_dir = os.path.basename(curr_dir)
62    split_dir = curr_dir.split('_')
63    if len(split_dir) < 2:
64        abort('You must run this script in an ANUGA branch directory: '
65              'anuga_X_Y[_Z].')
66    if split_dir[0] != 'anuga':
67        abort('You must run this script in an ANUGA branch directory: '
68              'anuga_X_Y[_Z].')
69
70    major = split_dir[1]
71    if len(split_dir) < 3:
72        minor = '0'
73    else:
74        minor = split_dir[2]
75       
76    if len(split_dir) < 4:
77        bug = '0'
78    else:
79        bug = split_dir[3]
80
81    return '%s.%s.%s' % (major, minor, bug)
82
83
84def xlog(msg):
85    """Log a message and print to console."""
86
87    print(msg)
88    #log(msg)
89
90
91# line separator
92lsep = '-' * 72
93
94
95######
96# Get svn revision number and create file with version info for release.
97# This will mean that the version currently checked out is the one which
98# will be released.
99######
100
[4170]101svn_revision = get_revision_number()
[3934]102
[7901]103anuga_release_number = get_release_number()
104anuga_release_name = 'anuga-%s' % anuga_release_number
105
[7489]106distro_filename = '%s.tgz' % anuga_release_name
[3892]107
[7901]108xlog(lsep)
109xlog('Creating %s' % anuga_release_name)
110xlog(lsep)
111
112######
[4837]113# Create directory for this release.
114# It will be named like
[7901]115#        anuga_release_1.2.3
116######
[5540]117
[7901]118release_area = os.path.join('~', 'anuga_releases')
119release_area = os.path.expanduser(release_area)
120do_cmd('mkdir -p %s' % release_area)
[5540]121
[7901]122release_dir = os.path.join(release_area, anuga_release_name )
123do_cmd('mkdir -p %s' % release_dir)
[3902]124
[7901]125######
[4837]126# Create temporary area for svn to export source files
[7901]127######
[3892]128
[7901]129distro_dir = tempfile.mktemp()
130do_cmd('mkdir -p %s' % distro_dir)
[3892]131
[7901]132######
[5068]133# Get the ANUGA directories flagged for distribution
[7901]134######
[5068]135
136for source in dirmap:
[7901]137    destination = os.path.join(distro_dir, dirmap[source])
[5068]138
[7901]139    do_cmd('svn export -r %d --quiet %s %s'
140           % (svn_revision, source, destination))
[5068]141
[5016]142# Store file with revision info for use with get_revision_number
143store_version_info(destination_path=distro_dir+'/anuga', verbose=True)
[4865]144
[7901]145######
146# IP Data Audit
147######
[4865]148
[7901]149xlog('Verifying data IP')
[5028]150if not IP_verified(distro_dir, verbose=True):
[7901]151    msg = ('Files have not been verified for IP.\n'
152           'Each data file must have a license file with it.')
153    raise Exception(msg)
[5016]154
[7901]155######
156# Compile and bundle up the LaTeX documentation
157######
[5016]158
[7901]159print(lsep)
160xlog('Preparing User Manual (see update_anuga_user_manual.log)')
161print(lsep)
162do_cmd('cd anuga_core/documentation/user_manual; '
163       'python update_anuga_user_manual.py --no_html '
164           '1>update_anuga_user_manual.log 2>/dev/null', blind=False)
[7607]165
166# Copy to distro_dir to become part of one tarball
[7901]167release_name = 'anuga_user_manual-%s.pdf' % anuga_release_number
168do_cmd('/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf '
169           '%s/%s' % (distro_dir, release_name))
[7607]170
[7901]171release_name = 'anuga_installation_guide-%s.pdf' % anuga_release_number
172do_cmd('/bin/mv anuga_core/documentation/user_manual/'
173           'anuga_installation_guide.pdf %s/%s' % (distro_dir, release_name))
[7607]174
[7901]175release_name = 'anuga_whats_new-%s.pdf' % anuga_release_number
176do_cmd('/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s'
177       % (distro_dir, release_name))
178
179######
[4802]180# Zip everything up
[7901]181######
[3987]182
[7901]183do_cmd('cd %s; tar cfz %s *' % (distro_dir, distro_filename))
184
185######
[3987]186# Move distro to release area
[7901]187######
[3987]188
[7901]189do_cmd('/bin/mv %s/*.tgz %s' % (distro_dir, release_dir) )
190
191######
[3987]192# Clean up
[7901]193######
[3987]194
[7901]195# do_cmd('/bin/rm -rf %s/*' % distro_dir)
[3987]196
[7901]197######
198# Generate Windows installer config.sh
199######
[3892]200
[7901]201xlog('')
202xlog(lsep)
203xlog('Creating Windows installer files')
204xlog(lsep)
205
[7489]206root = os.getcwd()
207from installation_files.windows.installer import create_config
[3902]208
[7489]209os.chdir('installation_files/windows')
[4531]210
[7489]211# Create ANUGA dir for NSI installer
212try:
[7901]213    os.mkdir(os.path.join('files', anuga_release_name))
214    os.mkdir(os.path.join('files', 'anuga_viewer'))
215    os.mkdir(os.path.join('files', 'prereqs'))
216    os.mkdir(os.path.join('files', 'prereqs', 'netcdf'))
[7489]217except:
218    pass
[4531]219
[7489]220# and unpack ANUGA into it
[7901]221do_cmd('cd files/%s; tar xfz %s/%s'
222       % (anuga_release_name, release_dir, distro_filename))
[7489]223
224# Must be replaced by local folder to where SourceForge version is downloaded
[7506]225anuga_viewer_folder = 'anuga_viewer'
[7489]226python = 'python-2.5.4.msi'
[7506]227numpy = 'numpy-1.3.0-win32-superpack-python2.5.exe'
228scientific_python = 'ScientificPython-2.9.0.win32-py2.5.exe'
[7513]229matplotlib = 'matplotlib-0.99.0.win32-py2.5.exe'
[7506]230netcdf_folder = 'netcdf'
[7610]231mingw = 'MinGW-5.1.6.exe'
[7489]232
233# Generate NSI file
[7901]234create_config(anuga_release_number, anuga_release_name, anuga_viewer_folder,
235              python, numpy, scientific_python, matplotlib, netcdf_folder,
[7489]236              mingw)
237
[7901]238# Package up files necessary to compile the installer on Windows and
[7489]239# move to release area
[7901]240# Cleanup in case there was something left from a previous attempt
241do_cmd('cd %s; /bin/rm -rf windows_installer' % release_dir)
[7489]242
243# Create subdirectories for windows installer
[7901]244do_cmd('cd %s; mkdir -p windows_installer/files' % release_dir)
[7489]245
246# Copy installion scrips and imagery across
[7901]247do_cmd('cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir)
[7489]248
249# Copy actual files used by Windows installer across
[7901]250do_cmd('cd files; cp -r * %s/windows_installer/files' % release_dir)
[7489]251
252# Come back to starting directory
253os.chdir(root)
[7901]254
[7489]255# Grab license file from anuga_core and copy to installer
[7901]256do_cmd('cp anuga_core/source/anuga/LICENSE.txt %s/windows_installer/files'
257       % release_dir)
[7489]258
[7901]259xlog('NSI installer created')
[7489]260
[7901]261######
[4837]262# Print list of release files
[7901]263######
[3934]264
[7901]265xlog('Done')
266print('')
267print('')
268print(lsep)
269xlog('The release files are in %s:' % release_dir)
270os.system('ls -la %s' % release_dir)
271print(lsep)
272print('')
[4837]273
[7901]274######
[4837]275# Copy release to various destinations
[7901]276######
[7489]277
[7901]278# # Copy to the ANU
279# #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision)
280# s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir)
281# print s
282# os.system(s)
[3934]283
[7901]284######
[3934]285# Throw away code to drop all files into the RAMP download area
[4532]286# This is hardwired for Ole but shows how such a thing can be done
287# automatically.
[7901]288######
[3934]289
[3937]290if get_user_name() == 'ole' and get_host_name() == 'nautilus':
[6426]291    answer = raw_input('Do you want to move this to the GA NAS? Y/N [Y]')
[4802]292    if answer.lower() == 'n':
293        import sys; sys.exit()
294
[4531]295    print 'Attempt to rsync data to perlite and datamining'
[5746]296    # Copy to Georisk
[7901]297    s = ('rsync -avz %s/* onielsen@cyclone:georisk/downloads/ANUGA_install/%s'
298         % (release_dir, 'anuga_%s' % anuga_release_number))
[3937]299    print s
[7901]300    os.system(s)
301
302    #os.system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)#
303
304######
305# Little reminders
306######
307
308xlog('Remember to update')
309xlog('    anuga_whats_new.tex')
310xlog('    sourceforge')
311xlog('    code.google.com')
Note: See TracBrowser for help on using the repository browser.