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