[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 | |
---|
[3892] | 20 | This script works only on Linux |
---|
| 21 | """ |
---|
| 22 | |
---|
| 23 | from os import sep, system, remove |
---|
| 24 | from tempfile import mktemp |
---|
[4531] | 25 | from sys import platform, stdout |
---|
[3937] | 26 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
[4170] | 27 | from anuga.abstract_2d_finite_volumes.util import get_revision_number |
---|
| 28 | from anuga.abstract_2d_finite_volumes.util import store_version_info |
---|
[4786] | 29 | from anuga.anuga_config import major_revision |
---|
[3892] | 30 | |
---|
| 31 | |
---|
| 32 | if platform == 'win32': |
---|
| 33 | msg = 'This script is not written for Windows.'+\ |
---|
| 34 | 'Please run it on a Unix platform' |
---|
| 35 | raise Exception, msg |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | # Define main version manually |
---|
[4786] | 39 | # major_revision = '1.0beta' |
---|
[3892] | 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 | |
---|
[3902] | 56 | # Create area directory |
---|
| 57 | release_dir = '~/anuga_release_%s' %revision |
---|
| 58 | s = 'mkdir %s' %release_dir |
---|
| 59 | try: |
---|
[4170] | 60 | print s |
---|
[3902] | 61 | system(s) |
---|
| 62 | except: |
---|
| 63 | pass |
---|
| 64 | |
---|
| 65 | |
---|
[4170] | 66 | # Export a clean directory tree from the working copy to a temporary dir |
---|
[3892] | 67 | distro_dir = mktemp() |
---|
| 68 | s = 'mkdir %s' %distro_dir |
---|
[4170] | 69 | print s |
---|
[3892] | 70 | system(s) |
---|
| 71 | |
---|
[4170] | 72 | |
---|
| 73 | |
---|
| 74 | s = 'svn export -r %d anuga_core/source/anuga %s/anuga' %(svn_revision, |
---|
| 75 | distro_dir) |
---|
[3892] | 76 | print s |
---|
| 77 | system(s) |
---|
| 78 | |
---|
[4170] | 79 | |
---|
| 80 | # Store file with revision info for use with get_revision_number |
---|
| 81 | store_version_info(destination_path=distro_dir+'/anuga', verbose=True) |
---|
| 82 | |
---|
[3892] | 83 | # Zip it up |
---|
| 84 | s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename) |
---|
| 85 | print s |
---|
| 86 | system(s) |
---|
| 87 | |
---|
[3902] | 88 | # Move distro to release area |
---|
| 89 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 90 | print s |
---|
| 91 | system(s) |
---|
| 92 | |
---|
[3892] | 93 | # Clean up |
---|
| 94 | s = '/bin/rm -rf %s/anuga' %(distro_dir) |
---|
| 95 | print s |
---|
| 96 | system(s) |
---|
| 97 | |
---|
[3902] | 98 | |
---|
| 99 | #----------------------------- |
---|
[3892] | 100 | # Get validation_files as well |
---|
[3902] | 101 | |
---|
| 102 | s = 'mkdir %s/anuga_validation' %distro_dir |
---|
| 103 | system(s) |
---|
| 104 | |
---|
| 105 | s = 'svn export anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\ |
---|
| 106 | %(distro_dir) |
---|
[3892] | 107 | print s |
---|
| 108 | system(s) |
---|
| 109 | |
---|
[4012] | 110 | s = 'svn export anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\ |
---|
| 111 | %(distro_dir) |
---|
| 112 | print s |
---|
| 113 | system(s) |
---|
| 114 | |
---|
[3892] | 115 | # Other validations in here!!! |
---|
| 116 | |
---|
| 117 | # Zip it up |
---|
| 118 | s = 'cd %s;tar cvfz anuga_validation-%s.tgz *'\ |
---|
| 119 | %(distro_dir, revision) |
---|
| 120 | print s |
---|
| 121 | system(s) |
---|
| 122 | |
---|
[3902] | 123 | # Move distro to release area |
---|
| 124 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 125 | print s |
---|
| 126 | system(s) |
---|
| 127 | |
---|
[3892] | 128 | # Clean up |
---|
[3902] | 129 | s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) |
---|
[3892] | 130 | print s |
---|
| 131 | system(s) |
---|
| 132 | |
---|
[3987] | 133 | |
---|
[3902] | 134 | #----------------------------- |
---|
[3987] | 135 | # Get demos from user manual |
---|
| 136 | |
---|
| 137 | #s = 'mkdir %s/anuga_demos' %distro_dir |
---|
| 138 | #system(s) |
---|
| 139 | |
---|
| 140 | s = 'svn export anuga_core/documentation/user_manual/demos %s/anuga_demos'\ |
---|
| 141 | %(distro_dir) |
---|
| 142 | print s |
---|
| 143 | system(s) |
---|
| 144 | |
---|
| 145 | # Zip it up |
---|
| 146 | s = 'cd %s;tar cvfz anuga_demos-%s.tgz *'\ |
---|
| 147 | %(distro_dir, revision) |
---|
| 148 | print s |
---|
| 149 | system(s) |
---|
| 150 | |
---|
| 151 | # Move distro to release area |
---|
| 152 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 153 | print s |
---|
| 154 | system(s) |
---|
| 155 | |
---|
| 156 | # Clean up |
---|
| 157 | s = '/bin/rm -rf %s/anuga_demos' %(distro_dir) |
---|
| 158 | print s |
---|
| 159 | system(s) |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | #----------------------------- |
---|
[4531] | 164 | # Copy and rename anuga_viewer |
---|
| 165 | s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s/anuga_viewer-%s.tgz' %(distro_dir, revision) |
---|
[3892] | 166 | print s |
---|
| 167 | system(s) |
---|
| 168 | |
---|
[4531] | 169 | |
---|
| 170 | # Move viewer to release area |
---|
[3892] | 171 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 172 | print s |
---|
| 173 | system(s) |
---|
[3902] | 174 | |
---|
[4531] | 175 | |
---|
| 176 | |
---|
[3922] | 177 | #----------------------------- |
---|
| 178 | # Hey, why not compile and bundle up the LaTeX documentation as well |
---|
[3902] | 179 | |
---|
[4531] | 180 | print |
---|
| 181 | print lsep |
---|
| 182 | print 'Preparing User Manual (see update_anuga_user_manual.log)' |
---|
| 183 | print lsep |
---|
[3922] | 184 | s = 'cd anuga_core/documentation/user_manual;' |
---|
| 185 | s += 'python update_anuga_user_manual.py --no_html' |
---|
| 186 | print s |
---|
[4531] | 187 | system(s + ' 1>update_anuga_user_manual.log 2>/dev/null') |
---|
[3922] | 188 | |
---|
[4122] | 189 | release_name = 'anuga_user_manual-%s.pdf' %revision |
---|
| 190 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\ |
---|
| 191 | %(release_dir, release_name) |
---|
[3922] | 192 | print s |
---|
| 193 | system(s) |
---|
| 194 | |
---|
[4122] | 195 | release_name = 'anuga_installation_guide-%s.pdf' %revision |
---|
| 196 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name) |
---|
| 197 | |
---|
[3922] | 198 | print s |
---|
| 199 | system(s) |
---|
| 200 | |
---|
| 201 | |
---|
[4531] | 202 | #----------------------------- |
---|
[3922] | 203 | |
---|
[3892] | 204 | print 'Done' |
---|
| 205 | print |
---|
| 206 | print |
---|
[4531] | 207 | print lsep |
---|
[3892] | 208 | print 'The release files are in %s:' %release_dir |
---|
| 209 | system('ls -la %s' %release_dir) |
---|
[4531] | 210 | print lsep |
---|
| 211 | print |
---|
| 212 | print |
---|
[3934] | 213 | |
---|
[4531] | 214 | answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]') |
---|
| 215 | if answer.lower() != 'n': |
---|
| 216 | |
---|
| 217 | #------------------------------ |
---|
| 218 | print 'Uploading to sourceforge' |
---|
[3934] | 219 | |
---|
| 220 | |
---|
[4531] | 221 | import os, os.path |
---|
| 222 | release_dir = os.path.expanduser(release_dir) |
---|
| 223 | os.chdir(release_dir) |
---|
| 224 | print 'Reading from', os.getcwd() |
---|
| 225 | |
---|
| 226 | |
---|
| 227 | from ftplib import FTP |
---|
| 228 | ftp = FTP('upload.sourceforge.net') |
---|
| 229 | print ftp.login() # Anonymous |
---|
| 230 | print ftp.cwd('incoming') |
---|
| 231 | |
---|
| 232 | |
---|
| 233 | for filename in os.listdir('.'): |
---|
| 234 | print 'Uploading %s... ' %filename, |
---|
| 235 | stdout.flush() |
---|
| 236 | |
---|
| 237 | fid=open(filename, 'rb') |
---|
| 238 | print ftp.storbinary('STOR %s' %filename, fid) |
---|
| 239 | fid.close() |
---|
| 240 | |
---|
| 241 | print 'FTP done' |
---|
| 242 | print ftp.quit() |
---|
| 243 | |
---|
| 244 | print |
---|
| 245 | print lsep |
---|
| 246 | print ' ********************* NOTE *************************' |
---|
| 247 | print lsep |
---|
| 248 | print 'To complete this release you must log into' |
---|
| 249 | print 'http://sourceforge.net/projects/anuga as ANUGA admin' |
---|
| 250 | print 'and complete the process by selecting File Releases ' |
---|
| 251 | print 'in the admin menu there.' |
---|
| 252 | print lsep |
---|
| 253 | print |
---|
| 254 | print |
---|
| 255 | |
---|
| 256 | |
---|
| 257 | |
---|
[4532] | 258 | import sys; sys.exit() |
---|
[4531] | 259 | |
---|
[3934] | 260 | #---------------------------- |
---|
| 261 | # Throw away code to drop all files into the RAMP download area |
---|
[4532] | 262 | # This is hardwired for Ole but shows how such a thing can be done |
---|
| 263 | # automatically. |
---|
[3934] | 264 | |
---|
[3937] | 265 | if get_user_name() == 'ole' and get_host_name() == 'nautilus': |
---|
[3934] | 266 | |
---|
[4531] | 267 | print 'Attempt to rsync data to perlite and datamining' |
---|
[3990] | 268 | # Copy to RAMP |
---|
[4384] | 269 | s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/natural_hazard_impacts/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision) |
---|
[3937] | 270 | print s |
---|
| 271 | system(s) |
---|
| 272 | |
---|
[3990] | 273 | #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)# |
---|
| 274 | |
---|
| 275 | |
---|
| 276 | |
---|
| 277 | # Copy to the ANU |
---|
[4531] | 278 | #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision) |
---|
| 279 | #print s |
---|
| 280 | #system(s) |
---|
[3990] | 281 | |
---|
| 282 | |
---|