[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 | |
---|
[4931] | 23 | from os import sep, system |
---|
[5068] | 24 | from os.path import join |
---|
[7489] | 25 | import os |
---|
[3892] | 26 | from tempfile import mktemp |
---|
[4531] | 27 | from sys import platform, stdout |
---|
[3937] | 28 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
[4170] | 29 | from anuga.abstract_2d_finite_volumes.util import get_revision_number |
---|
| 30 | from anuga.abstract_2d_finite_volumes.util import store_version_info |
---|
[5016] | 31 | from anuga.config import major_revision |
---|
[3892] | 32 | |
---|
[5068] | 33 | from dirs_to_distribute import dirmap |
---|
[5018] | 34 | from anuga.utilities.data_audit_wrapper import IP_verified |
---|
[3892] | 35 | |
---|
[7506] | 36 | |
---|
[3892] | 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 | |
---|
[4531] | 43 | # line separator |
---|
| 44 | lsep = '----------------------------------------------------------------------' |
---|
[3892] | 45 | |
---|
[4168] | 46 | |
---|
[4531] | 47 | # Get svn revision number and create |
---|
[4168] | 48 | # file with version info for release. |
---|
[4170] | 49 | # This will mean that the version currently checked out is |
---|
[4168] | 50 | # the one which will be released. |
---|
| 51 | |
---|
[4170] | 52 | svn_revision = get_revision_number() |
---|
[3922] | 53 | revision = '%s_%s' %(major_revision, svn_revision) |
---|
[3934] | 54 | print 'Creating ANUGA revision %s' %revision |
---|
| 55 | |
---|
[7489] | 56 | anuga_release_name = 'anuga-%s' % revision |
---|
| 57 | distro_filename = '%s.tgz' % anuga_release_name |
---|
[3892] | 58 | |
---|
[4837] | 59 | #----------------------------------- |
---|
| 60 | # Create directory for this release. |
---|
| 61 | # It will be named like |
---|
| 62 | # anuga_release_1.0beta_4824 |
---|
| 63 | #----------------------------------- |
---|
[5540] | 64 | release_area = '~/anuga_releases' |
---|
[7489] | 65 | s = 'mkdir %s' % release_area |
---|
[5540] | 66 | try: |
---|
| 67 | print s |
---|
| 68 | system(s) |
---|
| 69 | except: |
---|
| 70 | pass |
---|
| 71 | |
---|
| 72 | |
---|
[7489] | 73 | |
---|
| 74 | release_dir = release_area + '/%s' % anuga_release_name |
---|
| 75 | s = 'mkdir %s' % release_dir |
---|
[3902] | 76 | try: |
---|
[4170] | 77 | print s |
---|
[3902] | 78 | system(s) |
---|
| 79 | except: |
---|
| 80 | pass |
---|
| 81 | |
---|
[4837] | 82 | #----------------------------------------------------- |
---|
| 83 | # Create temporary area for svn to export source files |
---|
| 84 | #----------------------------------------------------- |
---|
[3892] | 85 | distro_dir = mktemp() |
---|
[7489] | 86 | s = 'mkdir %s' % distro_dir |
---|
[4170] | 87 | print s |
---|
[3892] | 88 | system(s) |
---|
| 89 | |
---|
| 90 | |
---|
[5068] | 91 | #--------------------------------------------------- |
---|
| 92 | # Get the ANUGA directories flagged for distribution |
---|
| 93 | #--------------------------------------------------- |
---|
| 94 | |
---|
| 95 | for source in dirmap: |
---|
| 96 | |
---|
| 97 | destination = join(distro_dir, dirmap[source]) |
---|
[7489] | 98 | |
---|
| 99 | s = 'svn export -r %d --quiet %s %s' % (svn_revision, |
---|
| 100 | source, |
---|
| 101 | destination) |
---|
[5068] | 102 | |
---|
| 103 | print s |
---|
| 104 | system(s) |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | |
---|
[3902] | 108 | |
---|
[5016] | 109 | # Store file with revision info for use with get_revision_number |
---|
| 110 | store_version_info(destination_path=distro_dir+'/anuga', verbose=True) |
---|
[4865] | 111 | |
---|
| 112 | |
---|
[5016] | 113 | #--------------------------- |
---|
| 114 | # IP Data Audit |
---|
| 115 | #--------------------------- |
---|
| 116 | print 'Verifying data IP' |
---|
[5028] | 117 | if not IP_verified(distro_dir, verbose=True): |
---|
[5016] | 118 | msg = 'Files have not been verified for IP.\n' |
---|
| 119 | msg += 'Each data file must have a license file with it.' |
---|
[6124] | 120 | raise Exception, msg |
---|
[5016] | 121 | |
---|
| 122 | |
---|
[7607] | 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 | |
---|
[4802] | 160 | #------------------ |
---|
| 161 | # Zip everything up |
---|
[4837] | 162 | #------------------ |
---|
[7489] | 163 | s = 'cd %s;tar cvfz %s *' % (distro_dir, distro_filename) |
---|
[3987] | 164 | print s |
---|
| 165 | system(s) |
---|
| 166 | |
---|
[4837] | 167 | #---------------------------- |
---|
[3987] | 168 | # Move distro to release area |
---|
[4837] | 169 | #---------------------------- |
---|
[7489] | 170 | s = '/bin/mv %s/*.tgz %s' % (distro_dir, release_dir) |
---|
[3987] | 171 | print s |
---|
| 172 | system(s) |
---|
| 173 | |
---|
[4837] | 174 | #--------- |
---|
[3987] | 175 | # Clean up |
---|
[4837] | 176 | #--------- |
---|
[7489] | 177 | s = '/bin/rm -rf %s/*' % (distro_dir) |
---|
[3987] | 178 | print s |
---|
| 179 | system(s) |
---|
| 180 | |
---|
| 181 | |
---|
[7489] | 182 | #---------------------------------------------- |
---|
| 183 | # Generate Windows installer |
---|
| 184 | #---------------------------------------------- |
---|
[3892] | 185 | |
---|
[7489] | 186 | root = os.getcwd() |
---|
| 187 | from installation_files.windows.installer import create_config |
---|
[3902] | 188 | |
---|
[7489] | 189 | os.chdir('installation_files/windows') |
---|
[4531] | 190 | |
---|
[7489] | 191 | # Create ANUGA dir for NSI installer |
---|
| 192 | try: |
---|
[7506] | 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') |
---|
[7489] | 197 | except: |
---|
| 198 | pass |
---|
[4531] | 199 | |
---|
[7489] | 200 | # 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) |
---|
| 206 | |
---|
| 207 | # Must be replaced by local folder to where SourceForge version is downloaded |
---|
[7506] | 208 | anuga_viewer_folder = 'anuga_viewer' |
---|
[7489] | 209 | python = 'python-2.5.4.msi' |
---|
[7506] | 210 | numpy = 'numpy-1.3.0-win32-superpack-python2.5.exe' |
---|
| 211 | scientific_python = 'ScientificPython-2.9.0.win32-py2.5.exe' |
---|
[7513] | 212 | matplotlib = 'matplotlib-0.99.0.win32-py2.5.exe' |
---|
[7506] | 213 | netcdf_folder = 'netcdf' |
---|
[7610] | 214 | mingw = 'MinGW-5.1.6.exe' |
---|
[7489] | 215 | |
---|
| 216 | # Generate NSI file |
---|
| 217 | create_config(revision, |
---|
| 218 | anuga_release_name, |
---|
| 219 | anuga_viewer_folder, |
---|
| 220 | python, |
---|
| 221 | numpy, |
---|
| 222 | scientific_python, |
---|
[7513] | 223 | matplotlib, |
---|
[7489] | 224 | netcdf_folder, |
---|
| 225 | mingw) |
---|
| 226 | |
---|
| 227 | # Package up files necessary to compile the installer on Windows and |
---|
| 228 | # 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 | |
---|
| 238 | # 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 | |
---|
| 245 | # Copy installion scrips and imagery across |
---|
| 246 | s = 'cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir |
---|
| 247 | print s |
---|
| 248 | system(s) |
---|
| 249 | |
---|
| 250 | # Copy actual files used by Windows installer across |
---|
[7506] | 251 | s = 'cd files; cp -r * %s/windows_installer/files' % release_dir |
---|
[7489] | 252 | print s |
---|
| 253 | system(s) |
---|
| 254 | |
---|
| 255 | # Come back to starting directory |
---|
| 256 | os.chdir(root) |
---|
| 257 | |
---|
| 258 | # 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 | |
---|
[3922] | 267 | |
---|
[4837] | 268 | #---------------------------- |
---|
| 269 | # Print list of release files |
---|
| 270 | #---------------------------- |
---|
[3892] | 271 | print 'Done' |
---|
| 272 | print |
---|
| 273 | print |
---|
[4531] | 274 | print lsep |
---|
[3892] | 275 | print 'The release files are in %s:' %release_dir |
---|
| 276 | system('ls -la %s' %release_dir) |
---|
[4531] | 277 | print lsep |
---|
| 278 | print |
---|
| 279 | print |
---|
[3934] | 280 | |
---|
[4837] | 281 | |
---|
| 282 | #------------------------------------- |
---|
| 283 | # Copy release to various destinations |
---|
| 284 | #------------------------------------- |
---|
[7489] | 285 | # FIXME (Ole): I don't think this is the way any more |
---|
| 286 | # due to changes at SourceForge. |
---|
| 287 | |
---|
[4531] | 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' |
---|
[3934] | 292 | |
---|
[4531] | 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 | |
---|
[5748] | 299 | s = 'rsync -avP -e ssh *.* uniomni@frs.sourceforge.net:uploads/' |
---|
[5746] | 300 | print s |
---|
| 301 | os.system(s) |
---|
[4531] | 302 | |
---|
[5746] | 303 | |
---|
[4531] | 304 | |
---|
[5746] | 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() |
---|
[4531] | 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 | |
---|
[6426] | 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 | |
---|
[3934] | 342 | #---------------------------- |
---|
| 343 | # Throw away code to drop all files into the RAMP download area |
---|
[4532] | 344 | # This is hardwired for Ole but shows how such a thing can be done |
---|
| 345 | # automatically. |
---|
[3934] | 346 | |
---|
[6426] | 347 | |
---|
[3937] | 348 | if get_user_name() == 'ole' and get_host_name() == 'nautilus': |
---|
[3934] | 349 | |
---|
[4802] | 350 | |
---|
[6426] | 351 | answer = raw_input('Do you want to move this to the GA NAS? Y/N [Y]') |
---|
[4802] | 352 | if answer.lower() == 'n': |
---|
| 353 | import sys; sys.exit() |
---|
| 354 | |
---|
| 355 | |
---|
| 356 | |
---|
[4531] | 357 | print 'Attempt to rsync data to perlite and datamining' |
---|
[5746] | 358 | # Copy to Georisk |
---|
[7406] | 359 | s = 'rsync -avz %s/* onielsen@cyclone:georisk/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' % revision) |
---|
[3937] | 360 | print s |
---|
| 361 | system(s) |
---|
| 362 | |
---|
[3990] | 363 | #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)# |
---|
| 364 | |
---|
[6426] | 365 | print 'Remember to update' |
---|
| 366 | print ' anuga_whats_new.tex' |
---|
| 367 | print ' sourceforge' |
---|
[5540] | 368 | |
---|