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