[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 |
---|
| 25 | from sys import platform |
---|
[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 | |
---|
| 40 | |
---|
[4170] | 41 | # Refresh sandpit and retrieve svn revision number |
---|
[3922] | 42 | # from last line in svn update output |
---|
[4170] | 43 | #filename = mktemp() + '.txt' |
---|
| 44 | #s = 'svn update > %s' %filename |
---|
| 45 | #print s |
---|
| 46 | #system(s) |
---|
| 47 | # |
---|
| 48 | #fid = open(filename) |
---|
| 49 | #last_line = fid.readlines()[-1] |
---|
| 50 | #remove(filename) |
---|
| 51 | #if not (last_line.startswith('At revision') or\ |
---|
| 52 | # last_line.startswith('Updated to revision')): |
---|
| 53 | # msg = 'Unexpected output from svn up: %s' %last_line |
---|
| 54 | # raise Exception, msg |
---|
| 55 | # |
---|
| 56 | #fields = last_line.split() |
---|
| 57 | #svn_revision = fields[-1][:-1] |
---|
[4168] | 58 | |
---|
[4170] | 59 | # Get revision number and create |
---|
[4168] | 60 | # file with version info for release. |
---|
[4170] | 61 | # This will mean that the version currently checked out is |
---|
[4168] | 62 | # the one which will be released. |
---|
| 63 | |
---|
[4170] | 64 | svn_revision = get_revision_number() |
---|
[3922] | 65 | revision = '%s_%s' %(major_revision, svn_revision) |
---|
[3934] | 66 | print 'Creating ANUGA revision %s' %revision |
---|
| 67 | |
---|
[3892] | 68 | distro_filename = 'anuga-%s.tgz' %revision |
---|
| 69 | |
---|
[3902] | 70 | # Create area directory |
---|
| 71 | release_dir = '~/anuga_release_%s' %revision |
---|
| 72 | s = 'mkdir %s' %release_dir |
---|
| 73 | try: |
---|
[4170] | 74 | print s |
---|
[3902] | 75 | system(s) |
---|
| 76 | except: |
---|
| 77 | pass |
---|
| 78 | |
---|
| 79 | |
---|
[4170] | 80 | # Export a clean directory tree from the working copy to a temporary dir |
---|
[3892] | 81 | distro_dir = mktemp() |
---|
| 82 | s = 'mkdir %s' %distro_dir |
---|
[4170] | 83 | print s |
---|
[3892] | 84 | system(s) |
---|
| 85 | |
---|
[4170] | 86 | |
---|
| 87 | |
---|
| 88 | s = 'svn export -r %d anuga_core/source/anuga %s/anuga' %(svn_revision, |
---|
| 89 | distro_dir) |
---|
[3892] | 90 | print s |
---|
| 91 | system(s) |
---|
| 92 | |
---|
[4170] | 93 | |
---|
| 94 | # Store file with revision info for use with get_revision_number |
---|
| 95 | store_version_info(destination_path=distro_dir+'/anuga', verbose=True) |
---|
| 96 | |
---|
| 97 | import sys; sys.exit() |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | |
---|
[3892] | 101 | # Zip it up |
---|
| 102 | s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename) |
---|
| 103 | print s |
---|
| 104 | system(s) |
---|
| 105 | |
---|
[3902] | 106 | # Move distro to release area |
---|
| 107 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 108 | print s |
---|
| 109 | system(s) |
---|
| 110 | |
---|
[3892] | 111 | # Clean up |
---|
| 112 | s = '/bin/rm -rf %s/anuga' %(distro_dir) |
---|
| 113 | print s |
---|
| 114 | system(s) |
---|
| 115 | |
---|
[3902] | 116 | |
---|
| 117 | #----------------------------- |
---|
[3892] | 118 | # Get validation_files as well |
---|
[3902] | 119 | |
---|
| 120 | s = 'mkdir %s/anuga_validation' %distro_dir |
---|
| 121 | system(s) |
---|
| 122 | |
---|
| 123 | s = 'svn export anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\ |
---|
| 124 | %(distro_dir) |
---|
[3892] | 125 | print s |
---|
| 126 | system(s) |
---|
| 127 | |
---|
[4012] | 128 | s = 'svn export anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\ |
---|
| 129 | %(distro_dir) |
---|
| 130 | print s |
---|
| 131 | system(s) |
---|
| 132 | |
---|
[3892] | 133 | # Other validations in here!!! |
---|
| 134 | |
---|
| 135 | # Zip it up |
---|
| 136 | s = 'cd %s;tar cvfz anuga_validation-%s.tgz *'\ |
---|
| 137 | %(distro_dir, revision) |
---|
| 138 | print s |
---|
| 139 | system(s) |
---|
| 140 | |
---|
[3902] | 141 | # Move distro to release area |
---|
| 142 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 143 | print s |
---|
| 144 | system(s) |
---|
| 145 | |
---|
[3892] | 146 | # Clean up |
---|
[3902] | 147 | s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) |
---|
[3892] | 148 | print s |
---|
| 149 | system(s) |
---|
| 150 | |
---|
[3987] | 151 | |
---|
[3902] | 152 | #----------------------------- |
---|
[3987] | 153 | # Get demos from user manual |
---|
| 154 | |
---|
| 155 | #s = 'mkdir %s/anuga_demos' %distro_dir |
---|
| 156 | #system(s) |
---|
| 157 | |
---|
| 158 | s = 'svn export anuga_core/documentation/user_manual/demos %s/anuga_demos'\ |
---|
| 159 | %(distro_dir) |
---|
| 160 | print s |
---|
| 161 | system(s) |
---|
| 162 | |
---|
| 163 | # Zip it up |
---|
| 164 | s = 'cd %s;tar cvfz anuga_demos-%s.tgz *'\ |
---|
| 165 | %(distro_dir, revision) |
---|
| 166 | print s |
---|
| 167 | system(s) |
---|
| 168 | |
---|
| 169 | # Move distro to release area |
---|
| 170 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 171 | print s |
---|
| 172 | system(s) |
---|
| 173 | |
---|
| 174 | # Clean up |
---|
| 175 | s = '/bin/rm -rf %s/anuga_demos' %(distro_dir) |
---|
| 176 | print s |
---|
| 177 | system(s) |
---|
| 178 | |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | #----------------------------- |
---|
[3892] | 182 | # Copy anuga_viewer |
---|
| 183 | s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s'\ |
---|
| 184 | %(distro_dir) |
---|
| 185 | print s |
---|
| 186 | system(s) |
---|
| 187 | |
---|
[3902] | 188 | # Move distro to release area |
---|
[3892] | 189 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 190 | print s |
---|
| 191 | system(s) |
---|
[3902] | 192 | |
---|
[3922] | 193 | #----------------------------- |
---|
| 194 | # Hey, why not compile and bundle up the LaTeX documentation as well |
---|
[3902] | 195 | |
---|
[3922] | 196 | s = 'cd anuga_core/documentation/user_manual;' |
---|
| 197 | s += 'python update_anuga_user_manual.py --no_html' |
---|
| 198 | print s |
---|
| 199 | system(s) |
---|
| 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 | |
---|
| 208 | release_name = 'anuga_installation_guide-%s.pdf' %revision |
---|
| 209 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name) |
---|
| 210 | |
---|
[3922] | 211 | print s |
---|
| 212 | system(s) |
---|
| 213 | |
---|
| 214 | |
---|
| 215 | |
---|
[3902] | 216 | #----------------------------- |
---|
[3892] | 217 | print 'Done' |
---|
| 218 | print |
---|
| 219 | print |
---|
| 220 | print 'The release files are in %s:' %release_dir |
---|
| 221 | system('ls -la %s' %release_dir) |
---|
[3934] | 222 | |
---|
| 223 | |
---|
| 224 | |
---|
| 225 | #---------------------------- |
---|
| 226 | # Throw away code to drop all files into the RAMP download area |
---|
| 227 | # This is hardwired for Ole |
---|
| 228 | |
---|
[3937] | 229 | if get_user_name() == 'ole' and get_host_name() == 'nautilus': |
---|
[3934] | 230 | |
---|
[3990] | 231 | # Copy to RAMP |
---|
| 232 | s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision) |
---|
[3937] | 233 | print s |
---|
| 234 | system(s) |
---|
| 235 | |
---|
[3990] | 236 | #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)# |
---|
| 237 | |
---|
| 238 | |
---|
| 239 | |
---|
| 240 | # Copy to the ANU |
---|
| 241 | |
---|
[3991] | 242 | s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision) |
---|
[3990] | 243 | print s |
---|
| 244 | system(s) |
---|
| 245 | |
---|
| 246 | |
---|