[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 |
---|
[3892] | 25 | from tempfile import mktemp |
---|
[4531] | 26 | from sys import platform, stdout |
---|
[3937] | 27 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
[4170] | 28 | from anuga.abstract_2d_finite_volumes.util import get_revision_number |
---|
| 29 | from anuga.abstract_2d_finite_volumes.util import store_version_info |
---|
[5016] | 30 | from anuga.config import major_revision |
---|
[3892] | 31 | |
---|
[5068] | 32 | from dirs_to_distribute import dirmap |
---|
[5018] | 33 | from anuga.utilities.data_audit_wrapper import IP_verified |
---|
[3892] | 34 | |
---|
| 35 | if 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 | |
---|
[4531] | 41 | # line separator |
---|
| 42 | lsep = '----------------------------------------------------------------------' |
---|
[3892] | 43 | |
---|
[4168] | 44 | |
---|
[4531] | 45 | # Get svn revision number and create |
---|
[4168] | 46 | # file with version info for release. |
---|
[4170] | 47 | # This will mean that the version currently checked out is |
---|
[4168] | 48 | # the one which will be released. |
---|
| 49 | |
---|
[4170] | 50 | svn_revision = get_revision_number() |
---|
[3922] | 51 | revision = '%s_%s' %(major_revision, svn_revision) |
---|
[3934] | 52 | print 'Creating ANUGA revision %s' %revision |
---|
| 53 | |
---|
[3892] | 54 | distro_filename = 'anuga-%s.tgz' %revision |
---|
| 55 | |
---|
[4837] | 56 | #----------------------------------- |
---|
| 57 | # Create directory for this release. |
---|
| 58 | # It will be named like |
---|
| 59 | # anuga_release_1.0beta_4824 |
---|
| 60 | #----------------------------------- |
---|
[5540] | 61 | release_area = '~/anuga_releases' |
---|
| 62 | s = 'mkdir %s' %release_area |
---|
| 63 | try: |
---|
| 64 | print s |
---|
| 65 | system(s) |
---|
| 66 | except: |
---|
| 67 | pass |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | release_dir = release_area + '/anuga_release_%s' %revision |
---|
[3902] | 71 | s = 'mkdir %s' %release_dir |
---|
| 72 | try: |
---|
[4170] | 73 | print s |
---|
[3902] | 74 | system(s) |
---|
| 75 | except: |
---|
| 76 | pass |
---|
| 77 | |
---|
[4837] | 78 | #----------------------------------------------------- |
---|
| 79 | # Create temporary area for svn to export source files |
---|
| 80 | #----------------------------------------------------- |
---|
[3892] | 81 | distro_dir = mktemp() |
---|
| 82 | s = 'mkdir %s' %distro_dir |
---|
[4170] | 83 | print s |
---|
[3892] | 84 | system(s) |
---|
| 85 | |
---|
| 86 | |
---|
[5068] | 87 | #--------------------------------------------------- |
---|
| 88 | # Get the ANUGA directories flagged for distribution |
---|
| 89 | #--------------------------------------------------- |
---|
| 90 | |
---|
| 91 | for source in dirmap: |
---|
| 92 | |
---|
| 93 | destination = join(distro_dir, dirmap[source]) |
---|
| 94 | s = 'svn export -r %d --quiet %s %s' %(svn_revision, |
---|
| 95 | source, |
---|
| 96 | destination) |
---|
| 97 | |
---|
| 98 | print s |
---|
| 99 | system(s) |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | |
---|
[3902] | 103 | #----------------------------- |
---|
[3892] | 104 | # Get validation_files as well |
---|
[4837] | 105 | #----------------------------- |
---|
[5068] | 106 | #s = 'mkdir %s/anuga_validation' %distro_dir |
---|
| 107 | #system(s) |
---|
| 108 | # |
---|
| 109 | #s = 'svn export -r %d --quiet anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\ |
---|
| 110 | # %(svn_revision, distro_dir) |
---|
| 111 | #print s |
---|
| 112 | #system(s) |
---|
[3902] | 113 | |
---|
[5064] | 114 | #s = 'svn export -r %d --quiet anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\ |
---|
| 115 | # %(svn_revision, distro_dir) |
---|
| 116 | #print s |
---|
[5068] | 117 | #syst |
---|
| 118 | |
---|
| 119 | #s = 'svn export -r %d --quiet anuga_validation/automated_validation_tests %s/anuga_validation/automated_validation_tests'\ |
---|
| 120 | # %(svn_revision, distro_dir) |
---|
| 121 | #print s |
---|
[5064] | 122 | #system(s) |
---|
[4012] | 123 | |
---|
[4837] | 124 | # FIXME: Other validations in here as they appear! |
---|
[3902] | 125 | |
---|
[3892] | 126 | |
---|
[4837] | 127 | #--------------------------- |
---|
[3987] | 128 | # Get demos from user manual |
---|
[4837] | 129 | #--------------------------- |
---|
[5068] | 130 | #s = 'svn export -r %d --quiet anuga_core/documentation/user_manual/demos %s/anuga_demos'\ |
---|
| 131 | # %(svn_revision, distro_dir) |
---|
| 132 | #print s |
---|
| 133 | #system(s) |
---|
[3987] | 134 | |
---|
[4865] | 135 | |
---|
[5068] | 136 | |
---|
[5016] | 137 | # Store file with revision info for use with get_revision_number |
---|
| 138 | store_version_info(destination_path=distro_dir+'/anuga', verbose=True) |
---|
[4865] | 139 | |
---|
| 140 | |
---|
[5016] | 141 | #--------------------------- |
---|
| 142 | # IP Data Audit |
---|
| 143 | #--------------------------- |
---|
| 144 | print 'Verifying data IP' |
---|
[5028] | 145 | if not IP_verified(distro_dir, verbose=True): |
---|
[5016] | 146 | msg = 'Files have not been verified for IP.\n' |
---|
| 147 | msg += 'Each data file must have a license file with it.' |
---|
[6124] | 148 | raise Exception, msg |
---|
[5016] | 149 | |
---|
| 150 | |
---|
[4802] | 151 | #------------------ |
---|
| 152 | # Zip everything up |
---|
[4837] | 153 | #------------------ |
---|
[4802] | 154 | s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename) |
---|
[3987] | 155 | print s |
---|
| 156 | system(s) |
---|
| 157 | |
---|
[4837] | 158 | #---------------------------- |
---|
[3987] | 159 | # Move distro to release area |
---|
[4837] | 160 | #---------------------------- |
---|
[3987] | 161 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 162 | print s |
---|
| 163 | system(s) |
---|
| 164 | |
---|
[4837] | 165 | #--------- |
---|
[3987] | 166 | # Clean up |
---|
[4837] | 167 | #--------- |
---|
[4802] | 168 | s = '/bin/rm -rf %s/*' %(distro_dir) |
---|
[3987] | 169 | print s |
---|
| 170 | system(s) |
---|
| 171 | |
---|
| 172 | |
---|
| 173 | #----------------------------- |
---|
[4531] | 174 | # Copy and rename anuga_viewer |
---|
[4837] | 175 | #----------------------------- |
---|
[4531] | 176 | s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s/anuga_viewer-%s.tgz' %(distro_dir, revision) |
---|
[3892] | 177 | print s |
---|
| 178 | system(s) |
---|
| 179 | |
---|
[4837] | 180 | #---------------------------- |
---|
[4531] | 181 | # Move viewer to release area |
---|
[4837] | 182 | #---------------------------- |
---|
[3892] | 183 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 184 | print s |
---|
| 185 | system(s) |
---|
[3902] | 186 | |
---|
[4531] | 187 | |
---|
| 188 | |
---|
[4837] | 189 | #---------------------------------------------- |
---|
| 190 | # Compile and bundle up the LaTeX documentation |
---|
| 191 | #---------------------------------------------- |
---|
[4531] | 192 | print |
---|
| 193 | print lsep |
---|
| 194 | print 'Preparing User Manual (see update_anuga_user_manual.log)' |
---|
| 195 | print lsep |
---|
[3922] | 196 | s = 'cd anuga_core/documentation/user_manual;' |
---|
| 197 | s += 'python update_anuga_user_manual.py --no_html' |
---|
| 198 | print s |
---|
[4531] | 199 | system(s + ' 1>update_anuga_user_manual.log 2>/dev/null') |
---|
[3922] | 200 | |
---|
[4122] | 201 | release_name = 'anuga_user_manual-%s.pdf' %revision |
---|
| 202 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\ |
---|
| 203 | %(release_dir, release_name) |
---|
[3922] | 204 | print s |
---|
| 205 | system(s) |
---|
| 206 | |
---|
[4122] | 207 | release_name = 'anuga_installation_guide-%s.pdf' %revision |
---|
| 208 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name) |
---|
[3922] | 209 | print s |
---|
| 210 | system(s) |
---|
| 211 | |
---|
[5513] | 212 | release_name = 'anuga_whats_new-%s.pdf' %revision |
---|
| 213 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s' %(release_dir, release_name) |
---|
| 214 | print s |
---|
| 215 | system(s) |
---|
[3922] | 216 | |
---|
[5513] | 217 | |
---|
[4837] | 218 | #---------------------------- |
---|
| 219 | # Print list of release files |
---|
| 220 | #---------------------------- |
---|
[3892] | 221 | print 'Done' |
---|
| 222 | print |
---|
| 223 | print |
---|
[4531] | 224 | print lsep |
---|
[3892] | 225 | print 'The release files are in %s:' %release_dir |
---|
| 226 | system('ls -la %s' %release_dir) |
---|
[4531] | 227 | print lsep |
---|
| 228 | print |
---|
| 229 | print |
---|
[3934] | 230 | |
---|
[4837] | 231 | |
---|
| 232 | #------------------------------------- |
---|
| 233 | # Copy release to various destinations |
---|
| 234 | #------------------------------------- |
---|
[4531] | 235 | answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]') |
---|
| 236 | if answer.lower() != 'n': |
---|
| 237 | |
---|
| 238 | print 'Uploading to sourceforge' |
---|
[3934] | 239 | |
---|
[4531] | 240 | import os, os.path |
---|
| 241 | release_dir = os.path.expanduser(release_dir) |
---|
| 242 | os.chdir(release_dir) |
---|
| 243 | print 'Reading from', os.getcwd() |
---|
| 244 | |
---|
| 245 | |
---|
[5748] | 246 | s = 'rsync -avP -e ssh *.* uniomni@frs.sourceforge.net:uploads/' |
---|
[5746] | 247 | print s |
---|
| 248 | os.system(s) |
---|
[4531] | 249 | |
---|
[5746] | 250 | |
---|
[4531] | 251 | |
---|
[5746] | 252 | #from ftplib import FTP |
---|
| 253 | #ftp = FTP('upload.sourceforge.net') |
---|
| 254 | #print ftp.login() # Anonymous |
---|
| 255 | #print ftp.cwd('incoming') |
---|
| 256 | # |
---|
| 257 | #for filename in os.listdir('.'): |
---|
| 258 | # print 'Uploading %s... ' %filename, |
---|
| 259 | # stdout.flush() |
---|
| 260 | # |
---|
| 261 | # fid=open(filename, 'rb') |
---|
| 262 | # print ftp.storbinary('STOR %s' %filename, fid) |
---|
| 263 | # fid.close() |
---|
| 264 | # |
---|
| 265 | #print 'FTP done' |
---|
| 266 | #print ftp.quit() |
---|
[4531] | 267 | |
---|
| 268 | print |
---|
| 269 | print lsep |
---|
| 270 | print ' ********************* NOTE *************************' |
---|
| 271 | print lsep |
---|
| 272 | print 'To complete this release you must log into' |
---|
| 273 | print 'http://sourceforge.net/projects/anuga as ANUGA admin' |
---|
| 274 | print 'and complete the process by selecting File Releases ' |
---|
| 275 | print 'in the admin menu there.' |
---|
| 276 | print lsep |
---|
| 277 | print |
---|
| 278 | print |
---|
| 279 | |
---|
| 280 | |
---|
| 281 | |
---|
[6426] | 282 | # Copy to the ANU |
---|
| 283 | #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision) |
---|
| 284 | s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir) |
---|
| 285 | print s |
---|
| 286 | system(s) |
---|
| 287 | |
---|
| 288 | |
---|
[3934] | 289 | #---------------------------- |
---|
| 290 | # Throw away code to drop all files into the RAMP download area |
---|
[4532] | 291 | # This is hardwired for Ole but shows how such a thing can be done |
---|
| 292 | # automatically. |
---|
[3934] | 293 | |
---|
[6426] | 294 | |
---|
[3937] | 295 | if get_user_name() == 'ole' and get_host_name() == 'nautilus': |
---|
[3934] | 296 | |
---|
[4802] | 297 | |
---|
[6426] | 298 | answer = raw_input('Do you want to move this to the GA NAS? Y/N [Y]') |
---|
[4802] | 299 | if answer.lower() == 'n': |
---|
| 300 | import sys; sys.exit() |
---|
| 301 | |
---|
| 302 | |
---|
| 303 | |
---|
[4531] | 304 | print 'Attempt to rsync data to perlite and datamining' |
---|
[5746] | 305 | # Copy to Georisk |
---|
[4384] | 306 | s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/natural_hazard_impacts/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision) |
---|
[3937] | 307 | print s |
---|
| 308 | system(s) |
---|
| 309 | |
---|
[3990] | 310 | #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)# |
---|
| 311 | |
---|
| 312 | |
---|
| 313 | |
---|
| 314 | |
---|
[6426] | 315 | print 'Remember to update' |
---|
| 316 | print ' anuga_whats_new.tex' |
---|
| 317 | print ' sourceforge' |
---|
[5540] | 318 | |
---|