source: branches/anuga_1_2_0/create_distribution.py @ 8729

Last change on this file since 8729 was 7889, checked in by wilsonr, 14 years ago

Initial try at getting it working.

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