Changeset 7901
- Timestamp:
- Jul 12, 2010, 6:18:01 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/create_distribution.py
r7753 r7901 21 21 """ 22 22 23 from os import sep, system 24 from os.path import join 23 import sys 25 24 import os 26 from tempfile import mktemp 27 from sys import platform, stdout 25 import tempfile 26 28 27 from anuga.utilities.system_tools import get_user_name, get_host_name 29 28 from anuga.abstract_2d_finite_volumes.util import get_revision_number 30 29 from anuga.abstract_2d_finite_volumes.util import store_version_info 31 30 from anuga.config import major_revision 32 33 31 from dirs_to_distribute import dirmap 34 32 from anuga.utilities.data_audit_wrapper import IP_verified 35 33 36 34 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. 35 if 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 40 def 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 51 def 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 84 def xlog(msg): 85 """Log a message and print to console.""" 86 87 print(msg) 88 #log(msg) 89 90 91 # line separator 92 lsep = '-' * 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 ###### 51 100 52 101 svn_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 103 anuga_release_number = get_release_number() 104 anuga_release_name = 'anuga-%s' % anuga_release_number 105 57 106 distro_filename = '%s.tgz' % anuga_release_name 58 107 59 #----------------------------------- 108 xlog(lsep) 109 xlog('Creating %s' % anuga_release_name) 110 xlog(lsep) 111 112 ###### 60 113 # Create directory for this release. 61 114 # 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 118 release_area = os.path.join('~', 'anuga_releases') 119 release_area = os.path.expanduser(release_area) 120 do_cmd('mkdir -p %s' % release_area) 121 122 release_dir = os.path.join(release_area, anuga_release_name ) 123 do_cmd('mkdir -p %s' % release_dir) 124 125 ###### 126 # Create temporary area for svn to export source files 127 ###### 128 129 distro_dir = tempfile.mktemp() 130 do_cmd('mkdir -p %s' % distro_dir) 131 132 ###### 133 # Get the ANUGA directories flagged for distribution 134 ###### 135 136 for 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 143 store_version_info(destination_path=distro_dir+'/anuga', verbose=True) 144 145 ###### 146 # IP Data Audit 147 ###### 148 149 xlog('Verifying data IP') 150 if 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 159 print(lsep) 160 xlog('Preparing User Manual (see update_anuga_user_manual.log)') 161 print(lsep) 162 do_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 167 release_name = 'anuga_user_manual-%s.pdf' % anuga_release_number 168 do_cmd('/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf ' 169 '%s/%s' % (distro_dir, release_name)) 170 171 release_name = 'anuga_installation_guide-%s.pdf' % anuga_release_number 172 do_cmd('/bin/mv anuga_core/documentation/user_manual/' 173 'anuga_installation_guide.pdf %s/%s' % (distro_dir, release_name)) 174 175 release_name = 'anuga_whats_new-%s.pdf' % anuga_release_number 176 do_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 183 do_cmd('cd %s; tar cfz %s *' % (distro_dir, distro_filename)) 184 185 ###### 186 # Move distro to release area 187 ###### 188 189 do_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 201 xlog('') 202 xlog(lsep) 203 xlog('Creating Windows installer files') 204 xlog(lsep) 205 206 root = os.getcwd() 207 from installation_files.windows.installer import create_config 208 209 os.chdir('installation_files/windows') 210 211 # Create ANUGA dir for NSI installer 66 212 try: 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')) 69 217 except: 70 218 pass 71 219 72 73 74 release_dir = release_area + '/%s' % anuga_release_name75 s = 'mkdir %s' % release_dir76 try:77 print s78 system(s)79 except:80 pass81 82 #-----------------------------------------------------83 # Create temporary area for svn to export source files84 #-----------------------------------------------------85 distro_dir = mktemp()86 s = 'mkdir %s' % distro_dir87 print s88 system(s)89 90 91 #---------------------------------------------------92 # Get the ANUGA directories flagged for distribution93 #---------------------------------------------------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 s104 system(s)105 106 107 108 109 # Store file with revision info for use with get_revision_number110 store_version_info(destination_path=distro_dir+'/anuga', verbose=True)111 112 113 #---------------------------114 # IP Data Audit115 #---------------------------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, msg121 122 123 124 125 #----------------------------------------------126 # Compile and bundle up the LaTeX documentation127 #----------------------------------------------128 print129 print lsep130 print 'Preparing User Manual (see update_anuga_user_manual.log)'131 print lsep132 s = 'cd anuga_core/documentation/user_manual;'133 s += 'python update_anuga_user_manual.py --no_html'134 print s135 system(s + ' 1>update_anuga_user_manual.log 2>/dev/null')136 137 # Copy to distro_dir to become part of one tarball138 release_name = 'anuga_user_manual-%s.pdf' % revision139 s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\140 %(distro_dir, release_name)141 print s142 system(s)143 144 release_name = 'anuga_installation_guide-%s.pdf' % revision145 s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(distro_dir, release_name)146 print s147 system(s)148 149 release_name = 'anuga_whats_new-%s.pdf' % revision150 s = '/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s' %(distro_dir, release_name)151 print s152 system(s)153 154 155 156 157 158 159 160 #------------------161 # Zip everything up162 #------------------163 s = 'cd %s;tar cvfz %s *' % (distro_dir, distro_filename)164 print s165 system(s)166 167 #----------------------------168 # Move distro to release area169 #----------------------------170 s = '/bin/mv %s/*.tgz %s' % (distro_dir, release_dir)171 print s172 system(s)173 174 #---------175 # Clean up176 #---------177 s = '/bin/rm -rf %s/*' % (distro_dir)178 print s179 system(s)180 181 182 #----------------------------------------------183 # Generate Windows installer184 #----------------------------------------------185 186 root = os.getcwd()187 from installation_files.windows.installer import create_config188 189 os.chdir('installation_files/windows')190 191 # Create ANUGA dir for NSI installer192 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 pass199 200 220 # 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) 221 do_cmd('cd files/%s; tar xfz %s/%s' 222 % (anuga_release_name, release_dir, distro_filename)) 206 223 207 224 # Must be replaced by local folder to where SourceForge version is downloaded … … 215 232 216 233 # 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, 234 create_config(anuga_release_number, anuga_release_name, anuga_viewer_folder, 235 python, numpy, scientific_python, matplotlib, netcdf_folder, 225 236 mingw) 226 237 227 # Package up files necessary to compile the installer on Windows and 238 # Package up files necessary to compile the installer on Windows and 228 239 # 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 241 do_cmd('cd %s; /bin/rm -rf windows_installer' % release_dir) 242 238 243 # 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 244 do_cmd('cd %s; mkdir -p windows_installer/files' % release_dir) 244 245 245 246 # Copy installion scrips and imagery across 246 s = 'cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir 247 print s 248 system(s) 247 do_cmd('cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir) 249 248 250 249 # 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) 250 do_cmd('cd files; cp -r * %s/windows_installer/files' % release_dir) 254 251 255 252 # Come back to starting directory 256 253 os.chdir(root) 257 254 258 255 # 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 #---------------------------- 256 do_cmd('cp anuga_core/source/anuga/LICENSE.txt %s/windows_installer/files' 257 % release_dir) 258 259 xlog('NSI installer created') 260 261 ###### 269 262 # 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 265 xlog('Done') 266 print('') 267 print('') 268 print(lsep) 269 xlog('The release files are in %s:' % release_dir) 270 os.system('ls -la %s' % release_dir) 271 print(lsep) 272 print('') 273 274 ###### 283 275 # 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 ###### 343 285 # Throw away code to drop all files into the RAMP download area 344 286 # This is hardwired for Ole but shows how such a thing can be done 345 287 # automatically. 346 288 ###### 347 289 348 290 if get_user_name() == 'ole' and get_host_name() == 'nautilus': 349 350 351 291 answer = raw_input('Do you want to move this to the GA NAS? Y/N [Y]') 352 292 if answer.lower() == 'n': 353 293 import sys; sys.exit() 354 294 355 356 357 295 print 'Attempt to rsync data to perlite and datamining' 358 296 # 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)) 360 299 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 308 xlog('Remember to update') 309 xlog(' anuga_whats_new.tex') 310 xlog(' sourceforge') 311 xlog(' 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') 1 def 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') 15 8 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') 20 51 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() 57 53 58 54
Note: See TracChangeset
for help on using the changeset viewer.