Changeset 7889


Ignore:
Timestamp:
Jul 5, 2010, 5:54:08 PM (9 years ago)
Author:
wilsonr
Message:

Initial try at getting it working.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/anuga_1_2_0/create_distribution.py

    r7753 r7889  
    2121"""
    2222
    23 from os import sep, system
    24 from os.path import join
     23import sys
    2524import os
    26 from tempfile import mktemp
    27 from sys import platform, stdout
     25import tempfile
     26
    2827from anuga.utilities.system_tools import get_user_name, get_host_name
    2928from anuga.abstract_2d_finite_volumes.util import get_revision_number
    3029from anuga.abstract_2d_finite_volumes.util import store_version_info
    3130from anuga.config import major_revision
    32 
    3331from dirs_to_distribute import dirmap
    3432from anuga.utilities.data_audit_wrapper import IP_verified
    3533
    3634
    37 if platform == 'win32':
    38     msg = 'This script is not written for Windows.'+\
    39           'Please run it on a Unix platform'
    40     raise Exception, msg
     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
    4154
    4255
    4356# line separator
    44 lsep = '----------------------------------------------------------------------'
    45 
    46 
    47 # Get svn revision number and create
    48 # file with version info for release.
    49 # This will mean that the version currently checked out is
    50 # the one which will be released.
     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######
    5165
    5266svn_revision = get_revision_number()
    53 revision = '%s_%s' %(major_revision, svn_revision)
    54 print 'Creating ANUGA revision %s' %revision
     67revision = '%s_%s' % (major_revision, svn_revision)
     68xlog('Creating ANUGA revision %s' % revision)
    5569
    5670anuga_release_name = 'anuga-%s' % revision
    5771distro_filename = '%s.tgz' % anuga_release_name
    5872
    59 #-----------------------------------
     73######
    6074# Create directory for this release.
    6175# It will be named like
    6276#        anuga_release_1.0beta_4824
    63 #-----------------------------------
    64 release_area = '~/anuga_releases'
    65 s = 'mkdir %s' % release_area
     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
    66169try:
    67     print s   
    68     system(s)
     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'))
    69174except:
    70175    pass
    71176
    72 
    73    
    74 release_dir = release_area + '/%s' % anuga_release_name
    75 s = 'mkdir %s' % release_dir
    76 try:
    77     print s   
    78     system(s)
    79 except:
    80     pass
    81 
    82 #-----------------------------------------------------
    83 # Create temporary area for svn to export source files
    84 #-----------------------------------------------------
    85 distro_dir = mktemp()
    86 s = 'mkdir %s' % distro_dir
    87 print s   
    88 system(s)
    89 
    90 
    91 #---------------------------------------------------
    92 # Get the ANUGA directories flagged for distribution
    93 #---------------------------------------------------
    94 
    95 for source in dirmap:
    96    
    97     destination = join(distro_dir, dirmap[source])
    98    
    99     s = 'svn export -r %d --quiet %s %s' % (svn_revision,
    100                                             source,
    101                                             destination)
    102 
    103     print s
    104     system(s)
    105 
    106 
    107 
    108 
    109 # Store file with revision info for use with get_revision_number
    110 store_version_info(destination_path=distro_dir+'/anuga', verbose=True)
    111 
    112 
    113 #---------------------------
    114 # IP Data Audit
    115 #---------------------------
    116 print 'Verifying data IP'
    117 if not IP_verified(distro_dir, verbose=True):
    118     msg = 'Files have not been verified for IP.\n'
    119     msg += 'Each data file must have a license file with it.'
    120     raise Exception, msg
    121 
    122 
    123    
    124 
    125 #----------------------------------------------
    126 # Compile and bundle up the LaTeX documentation
    127 #----------------------------------------------
    128 print
    129 print lsep
    130 print 'Preparing User Manual (see update_anuga_user_manual.log)'
    131 print lsep
    132 s = 'cd anuga_core/documentation/user_manual;'
    133 s += 'python update_anuga_user_manual.py --no_html'
    134 print s
    135 system(s + ' 1>update_anuga_user_manual.log 2>/dev/null')
    136 
    137 # Copy to distro_dir to become part of one tarball
    138 release_name = 'anuga_user_manual-%s.pdf' % revision
    139 s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\
    140     %(distro_dir, release_name)
    141 print s
    142 system(s)
    143 
    144 release_name = 'anuga_installation_guide-%s.pdf' % revision
    145 s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(distro_dir, release_name)   
    146 print s
    147 system(s)
    148 
    149 release_name = 'anuga_whats_new-%s.pdf' % revision
    150 s = '/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s' %(distro_dir, release_name)   
    151 print s
    152 system(s)
    153    
    154    
    155    
    156    
    157    
    158    
    159    
    160 #------------------
    161 # Zip everything up
    162 #------------------
    163 s = 'cd %s;tar cvfz %s *' % (distro_dir, distro_filename)
    164 print s
    165 system(s)
    166 
    167 #----------------------------
    168 # Move distro to release area
    169 #----------------------------
    170 s = '/bin/mv %s/*.tgz %s' % (distro_dir, release_dir)
    171 print s
    172 system(s)
    173 
    174 #---------
    175 # Clean up
    176 #---------
    177 s = '/bin/rm -rf %s/*' % (distro_dir)
    178 print s
    179 system(s)
    180 
    181 
    182 #----------------------------------------------
    183 # Generate Windows installer
    184 #----------------------------------------------
    185 
    186 root = os.getcwd()
    187 from installation_files.windows.installer import create_config
    188 
    189 os.chdir('installation_files/windows')
    190 
    191 # Create ANUGA dir for NSI installer
    192 try:
    193     os.mkdir('files/%s' % anuga_release_name)
    194     os.mkdir('files/anuga_viewer')
    195     os.mkdir('files/prereqs')
    196     os.mkdir('files/prereqs/netcdf')
    197 except:
    198     pass
    199 
    200177# and unpack ANUGA into it
    201 s = 'cd files/%s; tar xvfz %s/%s' % (anuga_release_name,
    202                                      release_dir,
    203                                      distro_filename)
    204 print s
    205 system(s)
     178do_cmd('cd files/%s; tar xvfz %s/%s'
     179       % (anuga_release_name, release_dir, distro_filename))
    206180
    207181# Must be replaced by local folder to where SourceForge version is downloaded
     
    215189
    216190# Generate NSI file
    217 create_config(revision,
    218               anuga_release_name,
    219               anuga_viewer_folder,
    220               python,
    221               numpy,
    222               scientific_python,
    223               matplotlib,
    224               netcdf_folder,
    225               mingw)
     191create_config(revision, anuga_release_name, anuga_viewer_folder, python,
     192              numpy, scientific_python, matplotlib, netcdf_folder, mingw)
    226193
    227194# Package up files necessary to compile the installer on Windows and
    228195# move to release area
    229 
    230 try:
    231     # Cleanup in case there was something left from a previous attempt
    232     s = 'cd %s; /bin/rm -rf windows_installer' % release_dir
    233     print s
    234     system(s)
    235 except:
    236     pass   
     196# Cleanup in case there was something left from a previous attempt
     197do_cmd('cd %s; /bin/rm -rf windows_installer' % release_dir)
    237198   
    238199# Create subdirectories for windows installer
    239 s = 'cd %s; mkdir windows_installer; mkdir windows_installer/files'\
    240     % release_dir
    241 print s
    242 system(s)
    243 
     200do_cmd('cd %s; mkdir windows_installer; mkdir windows_installer/files'
     201       % release_dir)
    244202
    245203# Copy installion scrips and imagery across
    246 s = 'cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir
    247 print s
    248 system(s)
     204do_cmd('cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir)
    249205
    250206# Copy actual files used by Windows installer across
    251 s = 'cd files; cp -r * %s/windows_installer/files' % release_dir
    252 print s
    253 system(s)                                                       
     207do_cmd('cd files; cp -r * %s/windows_installer/files' % release_dir)
    254208
    255209# Come back to starting directory
     
    257211                                                     
    258212# Grab license file from anuga_core and copy to installer
    259 s = 'cp anuga_core/source/anuga/LICENSE.txt %s/windows_installer/files'\
    260     % release_dir                                                       
    261 print s
    262 os.system(s)
    263 
    264 print 'NSI installer created'
    265 
    266 
    267 
    268 #----------------------------
     213do_cmd('cp anuga_core/source/anuga/LICENSE.txt %s/windows_installer/files'
     214       % release_dir                                                       )
     215
     216xlog('NSI installer created')
     217
     218######
    269219# Print list of release files
    270 #----------------------------
    271 print 'Done'
    272 print
    273 print
    274 print lsep
    275 print 'The release files are in %s:' %release_dir
    276 system('ls -la %s' %release_dir)
    277 print lsep
    278 print
    279 print
    280 
    281 
    282 #-------------------------------------
     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######
    283234# Copy release to various destinations
    284 #-------------------------------------
     235######
    285236# FIXME (Ole): I don't think this is the way any more
    286237# due to changes at SourceForge.
     
    310261    #for filename in os.listdir('.'):
    311262    #    print 'Uploading %s... ' %filename,
    312     #    stdout.flush()
     263    #    sys.stdout.flush()
    313264    #
    314265    #    fid=open(filename, 'rb')
     
    337288s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir)       
    338289print s
    339 system(s)
    340    
    341    
    342 #----------------------------
     290os.system(s)
     291   
     292   
     293######
    343294# Throw away code to drop all files into the RAMP download area
    344295# This is hardwired for Ole but shows how such a thing can be done
    345296# automatically.
    346 
     297######
    347298
    348299if get_user_name() == 'ole' and get_host_name() == 'nautilus':
    349 
    350 
    351300    answer = raw_input('Do you want to move this to the GA NAS? Y/N [Y]')
    352301    if answer.lower() == 'n':
    353302        import sys; sys.exit()
    354 
    355        
    356303
    357304    print 'Attempt to rsync data to perlite and datamining'
     
    359306    s = 'rsync -avz %s/* onielsen@cyclone:georisk/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' % revision)
    360307    print s
    361     system(s)
    362    
    363     #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)#
     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)#
    364311   
    365312print 'Remember to update'
Note: See TracChangeset for help on using the changeset viewer.