Changeset 7901


Ignore:
Timestamp:
Jul 12, 2010, 6:18:01 PM (9 years ago)
Author:
wilsonr
Message:

Changes to match the windows installer creator.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/create_distribution.py

    r7753 r7901  
    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
    41 
    42 
    43 # 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.
     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 do_cmd(cmd, blind=True):
     41    """Execute command.  Ignore errors if blind=True."""
     42
     43    try:
     44        xlog(cmd)
     45        os.system(cmd)
     46    except:
     47        if not blind:
     48            raise
     49
     50
     51def get_release_number():
     52    """Get release information and create release name.
     53
     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######
    51100
    52101svn_revision = get_revision_number()
    53 revision = '%s_%s' %(major_revision, svn_revision)
    54 print 'Creating ANUGA revision %s' %revision
    55 
    56 anuga_release_name = 'anuga-%s' % revision
     102
     103anuga_release_number = get_release_number()
     104anuga_release_name = 'anuga-%s' % anuga_release_number
     105
    57106distro_filename = '%s.tgz' % anuga_release_name
    58107
    59 #-----------------------------------
     108xlog(lsep)
     109xlog('Creating %s' % anuga_release_name)
     110xlog(lsep)
     111
     112######
    60113# Create directory for this release.
    61114# It will be named like
    62 #        anuga_release_1.0beta_4824
    63 #-----------------------------------
    64 release_area = '~/anuga_releases'
    65 s = 'mkdir %s' % release_area
     115#        anuga_release_1.2.3
     116######
     117
     118release_area = os.path.join('~', 'anuga_releases')
     119release_area = os.path.expanduser(release_area)
     120do_cmd('mkdir -p %s' % release_area)
     121
     122release_dir = os.path.join(release_area, anuga_release_name )
     123do_cmd('mkdir -p %s' % release_dir)
     124
     125######
     126# Create temporary area for svn to export source files
     127######
     128
     129distro_dir = tempfile.mktemp()
     130do_cmd('mkdir -p %s' % distro_dir)
     131
     132######
     133# Get the ANUGA directories flagged for distribution
     134######
     135
     136for source in dirmap:
     137    destination = os.path.join(distro_dir, dirmap[source])
     138
     139    do_cmd('svn export -r %d --quiet %s %s'
     140           % (svn_revision, source, destination))
     141
     142# Store file with revision info for use with get_revision_number
     143store_version_info(destination_path=distro_dir+'/anuga', verbose=True)
     144
     145######
     146# IP Data Audit
     147######
     148
     149xlog('Verifying data IP')
     150if not IP_verified(distro_dir, verbose=True):
     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)
     154
     155######
     156# Compile and bundle up the LaTeX documentation
     157######
     158
     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)
     165
     166# Copy to distro_dir to become part of one tarball
     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))
     170
     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))
     174
     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######
     180# Zip everything up
     181######
     182
     183do_cmd('cd %s; tar cfz %s *' % (distro_dir, distro_filename))
     184
     185######
     186# Move distro to release area
     187######
     188
     189do_cmd('/bin/mv %s/*.tgz %s' % (distro_dir, release_dir) )
     190
     191######
     192# Clean up
     193######
     194
     195# do_cmd('/bin/rm -rf %s/*' % distro_dir)
     196
     197######
     198# Generate Windows installer config.sh
     199######
     200
     201xlog('')
     202xlog(lsep)
     203xlog('Creating Windows installer files')
     204xlog(lsep)
     205
     206root = os.getcwd()
     207from installation_files.windows.installer import create_config
     208
     209os.chdir('installation_files/windows')
     210
     211# Create ANUGA dir for NSI installer
    66212try:
    67     print s   
    68     system(s)
     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'))
    69217except:
    70218    pass
    71219
    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 
    200220# 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)
     221do_cmd('cd files/%s; tar xfz %s/%s'
     222       % (anuga_release_name, release_dir, distro_filename))
    206223
    207224# Must be replaced by local folder to where SourceForge version is downloaded
     
    215232
    216233# 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,
     234create_config(anuga_release_number, anuga_release_name, anuga_viewer_folder,
     235              python, numpy, scientific_python, matplotlib, netcdf_folder,
    225236              mingw)
    226237
    227 # Package up files necessary to compile the installer on Windows and 
     238# Package up files necessary to compile the installer on Windows and
    228239# 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   
    237    
     240# Cleanup in case there was something left from a previous attempt
     241do_cmd('cd %s; /bin/rm -rf windows_installer' % release_dir)
     242
    238243# 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 
     244do_cmd('cd %s; mkdir -p windows_installer/files' % release_dir)
    244245
    245246# Copy installion scrips and imagery across
    246 s = 'cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir
    247 print s
    248 system(s)
     247do_cmd('cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir)
    249248
    250249# 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)                                                       
     250do_cmd('cd files; cp -r * %s/windows_installer/files' % release_dir)
    254251
    255252# Come back to starting directory
    256253os.chdir(root)
    257                                                      
     254
    258255# 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 #----------------------------
     256do_cmd('cp anuga_core/source/anuga/LICENSE.txt %s/windows_installer/files'
     257       % release_dir)
     258
     259xlog('NSI installer created')
     260
     261######
    269262# 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 #-------------------------------------
     263######
     264
     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('')
     273
     274######
    283275# Copy release to various destinations
    284 #-------------------------------------
    285 # FIXME (Ole): I don't think this is the way any more
    286 # due to changes at SourceForge.
    287 
    288 answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]')
    289 if answer.lower() != 'n':
    290    
    291     print 'Uploading to sourceforge'
    292 
    293     import os, os.path
    294     release_dir = os.path.expanduser(release_dir)
    295     os.chdir(release_dir)
    296     print 'Reading from', os.getcwd()
    297 
    298 
    299     s = 'rsync -avP -e ssh *.* uniomni@frs.sourceforge.net:uploads/'
    300     print s
    301     os.system(s)
    302 
    303    
    304 
    305     #from ftplib import FTP
    306     #ftp = FTP('upload.sourceforge.net')
    307     #print ftp.login() # Anonymous
    308     #print ftp.cwd('incoming')
    309     #
    310     #for filename in os.listdir('.'):
    311     #    print 'Uploading %s... ' %filename,
    312     #    stdout.flush()
    313     #
    314     #    fid=open(filename, 'rb')
    315     #    print ftp.storbinary('STOR %s' %filename, fid)
    316     #    fid.close()
    317     #
    318     #print 'FTP done'
    319     #print ftp.quit()
    320 
    321     print
    322     print lsep
    323     print '    ********************* NOTE *************************'
    324     print lsep
    325     print 'To complete this release you must log into'
    326     print 'http://sourceforge.net/projects/anuga as ANUGA admin'
    327     print 'and complete the process by selecting File Releases '
    328     print 'in the admin menu there.'
    329     print lsep
    330     print
    331     print
    332    
    333 
    334 
    335 # Copy to the ANU
    336 #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision)
    337 s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir)       
    338 print s
    339 system(s)
    340    
    341    
    342 #----------------------------
     276######
     277
     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)
     283
     284######
    343285# Throw away code to drop all files into the RAMP download area
    344286# This is hardwired for Ole but shows how such a thing can be done
    345287# automatically.
    346 
     288######
    347289
    348290if get_user_name() == 'ole' and get_host_name() == 'nautilus':
    349 
    350 
    351291    answer = raw_input('Do you want to move this to the GA NAS? Y/N [Y]')
    352292    if answer.lower() == 'n':
    353293        import sys; sys.exit()
    354294
    355        
    356 
    357295    print 'Attempt to rsync data to perlite and datamining'
    358296    # Copy to Georisk
    359     s = 'rsync -avz %s/* onielsen@cyclone:georisk/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' % revision)
     297    s = ('rsync -avz %s/* onielsen@cyclone:georisk/downloads/ANUGA_install/%s'
     298         % (release_dir, 'anuga_%s' % anuga_release_number))
    360299    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)#
    364    
    365 print 'Remember to update'
    366 print '    anuga_whats_new.tex'
    367 print '    sourceforge'
    368    
     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')
  • trunk/installation_files/windows/installer.py

    r7525 r7901  
    1 def create_config(product_version,
    2                   anuga_folder,
    3                   anuga_viewer_folder,
    4                   python,
    5                   numpy,
    6                   scientific_python,
    7                   matplotlib,
    8                   netcdf,
    9                   mingw):
    10         """
    11         Short description:
    12         """
    13        
    14         file = open('config.nsh', 'w')
     1def create_config(product_version, anuga_folder, anuga_viewer_folder, python,
     2              numpy, scientific_python, matplotlib, netcdf, mingw):
     3    """
     4    Short description:
     5    """
     6   
     7    file = open('config.nsh', 'w')
    158
    16         file.write('''!ifndef __CONFIG_NSH
    17 !define __CONFIG_NSH
    18 ; custom config
    19 ; definitions should be quite self-explaining
     9    file.write('!ifndef __CONFIG_NSH\n'
     10               '!define __CONFIG_NSH\n'
     11               '; custom config\n'
     12               '; definitions should be quite self-explaining\n'
     13               '\n'
     14               '; global definitions\n'
     15               '!define ProductName "ANUGA"\n')
     16    file.write('!define ProductVersion "%s"\n' % product_version)
     17    file.write('!define Company "Geoscience Australia"\n'
     18               '!define Website "https://datamining.anu.edu.au/anuga"\n')
     19    file.write('!define ExecutableName "AnugaSetup-%s.exe"\n' % product_version)
     20    file.write('\n'
     21               '; distribution file sources (for compiling the installer)\n'
     22               '!define WelcomeFinishBitmap "wf.bmp"\n'
     23               '!define HeaderBitmap "header.bmp"\n'
     24               '!define InstallerIcon "installer.ico"\n'
     25               '!define FileSource "files"\n'
     26               '\n')
     27    file.write('!define AnugaFolder "%s"\n' % anuga_folder)
     28    file.write('!define AnugaViewerFolder "%s"\n' % anuga_viewer_folder)
     29    file.write('!define PythonInst "%s"\n' % python)
     30    file.write('!define NumpyInst "%s"\n' % numpy)
     31    file.write('!define ScientificInst "%s"\n' % scientific_python)
     32    file.write('!define MatplotlibInst "%s"\n' % matplotlib)
     33    file.write('!define NetCDFFolder "%s"\n' % netcdf)
     34    file.write('!define MinGWInst "%s"\n' % mingw)
     35    file.write('!define MVCRPInst "vcredist_x86.exe"\n'
     36               '\n'
     37               '; registry/advanced information for the installation routine\n'
     38               '!define AnugaViewerDefaultFolder "$PROGRAMFILES\Anuga Viewer"\n'
     39               '!define NetCDFDefaultFolder "$COMMONFILES\NetCDF"\n'
     40               '\n'
     41               '!define ViewerExtension ".sww"\n'
     42               '!define ViewerExtensionAlias "Anuga.Animation"\n'
     43               '\n'
     44               '!define UninstallerRegistryKey '
     45                   r'"Software\Microsoft\Windows\CurrentVersion\Uninstall'
     46                   r'\${ProductName}"'
     47                   '\n'
     48               '!define UninstallerExecutableName "Uninst_Anuga.exe"\n'
     49               '\n'
     50               '!endif\n')
    2051
    21 ; global definitions
    22 !define ProductName "ANUGA"
    23 ''')       
    24         file.write('!define ProductVersion "' + product_version + '"\n')
    25         file.write('!define Company "Geoscience Australia"\n')
    26         file.write('!define Website "https://datamining.anu.edu.au/anuga"\n')
    27         file.write('!define ExecutableName "AnugaSetup-' + product_version + '.exe"\n\n')
    28         file.write('''; distribution file sources (for compiling the installer)
    29 !define WelcomeFinishBitmap "wf.bmp"
    30 !define HeaderBitmap "header.bmp"
    31 !define InstallerIcon "installer.ico"
    32 !define FileSource "files"
    33 
    34 ''')   
    35         file.write('!define AnugaFolder "' + anuga_folder + '"\n')
    36         file.write('!define AnugaViewerFolder "' + anuga_viewer_folder + '"\n')
    37         file.write('!define PythonInst "' + python + '"\n')
    38         file.write('!define NumpyInst "' + numpy + '"\n')
    39         file.write('!define ScientificInst "' + scientific_python + '"\n')
    40         file.write('!define MatplotlibInst "' + matplotlib + '"\n')
    41         file.write('!define NetCDFFolder "' + netcdf + '"\n')
    42         file.write('!define MinGWInst "' + mingw + '"\n')
    43         file.write('!define MVCRPInst "vcredist_x86.exe"\n\n')
    44         file.write('''; registry and advanced information for the installation routine
    45 !define AnugaViewerDefaultFolder "$PROGRAMFILES\Anuga Viewer"
    46 !define NetCDFDefaultFolder "$COMMONFILES\NetCDF"
    47 
    48 !define ViewerExtension ".sww"
    49 !define ViewerExtensionAlias "Anuga.Animation"
    50 
    51 !define UninstallerRegistryKey "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProductName}"
    52 !define UninstallerExecutableName "Uninst_Anuga.exe"
    53 
    54 !endif''')
    55 
    56         file.close()
     52    file.close()
    5753
    5854
Note: See TracChangeset for help on using the changeset viewer.