[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 | |
---|
[7901] | 23 | import sys |
---|
[7489] | 24 | import os |
---|
[7901] | 25 | import tempfile |
---|
| 26 | |
---|
[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 |
---|
[5068] | 31 | from dirs_to_distribute import dirmap |
---|
[5018] | 32 | from anuga.utilities.data_audit_wrapper import IP_verified |
---|
[3892] | 33 | |
---|
[7506] | 34 | |
---|
[7901] | 35 | if sys.platform == 'win32': |
---|
| 36 | msg = ('This script is not written for Windows. ' |
---|
| 37 | 'Please run it on a Unix platform') |
---|
| 38 | raise Exception(msg) |
---|
[3892] | 39 | |
---|
[7901] | 40 | def do_cmd(cmd, blind=True): |
---|
| 41 | """Execute command. Ignore errors if blind=True.""" |
---|
[3892] | 42 | |
---|
[7901] | 43 | try: |
---|
| 44 | xlog(cmd) |
---|
| 45 | os.system(cmd) |
---|
| 46 | except: |
---|
| 47 | if not blind: |
---|
| 48 | raise |
---|
[3892] | 49 | |
---|
[4168] | 50 | |
---|
[7901] | 51 | def get_release_number(): |
---|
| 52 | """Get release information and create release name. |
---|
[4168] | 53 | |
---|
[7901] | 54 | Get release numbers from the current directory. |
---|
| 55 | |
---|
| 56 | Returns a string which is of the form 'anuga-X-Y-Z' where X is the |
---|
| 57 | major release number, Y is the minor and Z is the bug number. |
---|
| 58 | """ |
---|
| 59 | |
---|
| 60 | curr_dir = os.getcwd() |
---|
| 61 | curr_dir = os.path.basename(curr_dir) |
---|
| 62 | split_dir = curr_dir.split('_') |
---|
| 63 | if len(split_dir) < 2: |
---|
| 64 | abort('You must run this script in an ANUGA branch directory: ' |
---|
| 65 | 'anuga_X_Y[_Z].') |
---|
| 66 | if split_dir[0] != 'anuga': |
---|
| 67 | abort('You must run this script in an ANUGA branch directory: ' |
---|
| 68 | 'anuga_X_Y[_Z].') |
---|
| 69 | |
---|
| 70 | major = split_dir[1] |
---|
| 71 | if len(split_dir) < 3: |
---|
| 72 | minor = '0' |
---|
| 73 | else: |
---|
| 74 | minor = split_dir[2] |
---|
| 75 | |
---|
| 76 | if len(split_dir) < 4: |
---|
| 77 | bug = '0' |
---|
| 78 | else: |
---|
| 79 | bug = split_dir[3] |
---|
| 80 | |
---|
| 81 | return '%s.%s.%s' % (major, minor, bug) |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | def xlog(msg): |
---|
| 85 | """Log a message and print to console.""" |
---|
| 86 | |
---|
| 87 | print(msg) |
---|
| 88 | #log(msg) |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | # line separator |
---|
| 92 | lsep = '-' * 72 |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | ###### |
---|
| 96 | # Get svn revision number and create file with version info for release. |
---|
| 97 | # This will mean that the version currently checked out is the one which |
---|
| 98 | # will be released. |
---|
| 99 | ###### |
---|
| 100 | |
---|
[4170] | 101 | svn_revision = get_revision_number() |
---|
[3934] | 102 | |
---|
[7901] | 103 | anuga_release_number = get_release_number() |
---|
| 104 | anuga_release_name = 'anuga-%s' % anuga_release_number |
---|
| 105 | |
---|
[7489] | 106 | distro_filename = '%s.tgz' % anuga_release_name |
---|
[3892] | 107 | |
---|
[7901] | 108 | xlog(lsep) |
---|
| 109 | xlog('Creating %s' % anuga_release_name) |
---|
| 110 | xlog(lsep) |
---|
| 111 | |
---|
| 112 | ###### |
---|
[4837] | 113 | # Create directory for this release. |
---|
| 114 | # It will be named like |
---|
[7901] | 115 | # anuga_release_1.2.3 |
---|
| 116 | ###### |
---|
[5540] | 117 | |
---|
[7901] | 118 | release_area = os.path.join('~', 'anuga_releases') |
---|
| 119 | release_area = os.path.expanduser(release_area) |
---|
| 120 | do_cmd('mkdir -p %s' % release_area) |
---|
[5540] | 121 | |
---|
[7901] | 122 | release_dir = os.path.join(release_area, anuga_release_name ) |
---|
| 123 | do_cmd('mkdir -p %s' % release_dir) |
---|
[3902] | 124 | |
---|
[7901] | 125 | ###### |
---|
[4837] | 126 | # Create temporary area for svn to export source files |
---|
[7901] | 127 | ###### |
---|
[3892] | 128 | |
---|
[7901] | 129 | distro_dir = tempfile.mktemp() |
---|
| 130 | do_cmd('mkdir -p %s' % distro_dir) |
---|
[3892] | 131 | |
---|
[7901] | 132 | ###### |
---|
[5068] | 133 | # Get the ANUGA directories flagged for distribution |
---|
[7901] | 134 | ###### |
---|
[5068] | 135 | |
---|
| 136 | for source in dirmap: |
---|
[7901] | 137 | destination = os.path.join(distro_dir, dirmap[source]) |
---|
[5068] | 138 | |
---|
[7901] | 139 | do_cmd('svn export -r %d --quiet %s %s' |
---|
| 140 | % (svn_revision, source, destination)) |
---|
[5068] | 141 | |
---|
[5016] | 142 | # Store file with revision info for use with get_revision_number |
---|
| 143 | store_version_info(destination_path=distro_dir+'/anuga', verbose=True) |
---|
[4865] | 144 | |
---|
[7901] | 145 | ###### |
---|
| 146 | # IP Data Audit |
---|
| 147 | ###### |
---|
[4865] | 148 | |
---|
[7901] | 149 | xlog('Verifying data IP') |
---|
[5028] | 150 | if not IP_verified(distro_dir, verbose=True): |
---|
[7901] | 151 | msg = ('Files have not been verified for IP.\n' |
---|
| 152 | 'Each data file must have a license file with it.') |
---|
| 153 | raise Exception(msg) |
---|
[5016] | 154 | |
---|
[7901] | 155 | ###### |
---|
| 156 | # Compile and bundle up the LaTeX documentation |
---|
| 157 | ###### |
---|
[5016] | 158 | |
---|
[7901] | 159 | print(lsep) |
---|
| 160 | xlog('Preparing User Manual (see update_anuga_user_manual.log)') |
---|
| 161 | print(lsep) |
---|
| 162 | do_cmd('cd anuga_core/documentation/user_manual; ' |
---|
| 163 | 'python update_anuga_user_manual.py --no_html ' |
---|
| 164 | '1>update_anuga_user_manual.log 2>/dev/null', blind=False) |
---|
[7607] | 165 | |
---|
| 166 | # Copy to distro_dir to become part of one tarball |
---|
[7901] | 167 | release_name = 'anuga_user_manual-%s.pdf' % anuga_release_number |
---|
| 168 | do_cmd('/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf ' |
---|
| 169 | '%s/%s' % (distro_dir, release_name)) |
---|
[7607] | 170 | |
---|
[7901] | 171 | release_name = 'anuga_installation_guide-%s.pdf' % anuga_release_number |
---|
| 172 | do_cmd('/bin/mv anuga_core/documentation/user_manual/' |
---|
| 173 | 'anuga_installation_guide.pdf %s/%s' % (distro_dir, release_name)) |
---|
[7607] | 174 | |
---|
[7901] | 175 | release_name = 'anuga_whats_new-%s.pdf' % anuga_release_number |
---|
| 176 | do_cmd('/bin/mv anuga_core/documentation/user_manual/anuga_whats_new.pdf %s/%s' |
---|
| 177 | % (distro_dir, release_name)) |
---|
| 178 | |
---|
| 179 | ###### |
---|
[4802] | 180 | # Zip everything up |
---|
[7901] | 181 | ###### |
---|
[3987] | 182 | |
---|
[7901] | 183 | do_cmd('cd %s; tar cfz %s *' % (distro_dir, distro_filename)) |
---|
| 184 | |
---|
| 185 | ###### |
---|
[3987] | 186 | # Move distro to release area |
---|
[7901] | 187 | ###### |
---|
[3987] | 188 | |
---|
[7901] | 189 | do_cmd('/bin/mv %s/*.tgz %s' % (distro_dir, release_dir) ) |
---|
| 190 | |
---|
| 191 | ###### |
---|
[3987] | 192 | # Clean up |
---|
[7901] | 193 | ###### |
---|
[3987] | 194 | |
---|
[7901] | 195 | # do_cmd('/bin/rm -rf %s/*' % distro_dir) |
---|
[3987] | 196 | |
---|
[7901] | 197 | ###### |
---|
| 198 | # Generate Windows installer config.sh |
---|
| 199 | ###### |
---|
[3892] | 200 | |
---|
[7901] | 201 | xlog('') |
---|
| 202 | xlog(lsep) |
---|
| 203 | xlog('Creating Windows installer files') |
---|
| 204 | xlog(lsep) |
---|
| 205 | |
---|
[7489] | 206 | root = os.getcwd() |
---|
| 207 | from installation_files.windows.installer import create_config |
---|
[3902] | 208 | |
---|
[7489] | 209 | os.chdir('installation_files/windows') |
---|
[4531] | 210 | |
---|
[7489] | 211 | # Create ANUGA dir for NSI installer |
---|
| 212 | try: |
---|
[7901] | 213 | os.mkdir(os.path.join('files', anuga_release_name)) |
---|
| 214 | os.mkdir(os.path.join('files', 'anuga_viewer')) |
---|
| 215 | os.mkdir(os.path.join('files', 'prereqs')) |
---|
| 216 | os.mkdir(os.path.join('files', 'prereqs', 'netcdf')) |
---|
[7489] | 217 | except: |
---|
| 218 | pass |
---|
[4531] | 219 | |
---|
[7489] | 220 | # and unpack ANUGA into it |
---|
[7901] | 221 | do_cmd('cd files/%s; tar xfz %s/%s' |
---|
| 222 | % (anuga_release_name, release_dir, distro_filename)) |
---|
[7489] | 223 | |
---|
| 224 | # Must be replaced by local folder to where SourceForge version is downloaded |
---|
[7506] | 225 | anuga_viewer_folder = 'anuga_viewer' |
---|
[7489] | 226 | python = 'python-2.5.4.msi' |
---|
[7506] | 227 | numpy = 'numpy-1.3.0-win32-superpack-python2.5.exe' |
---|
| 228 | scientific_python = 'ScientificPython-2.9.0.win32-py2.5.exe' |
---|
[7513] | 229 | matplotlib = 'matplotlib-0.99.0.win32-py2.5.exe' |
---|
[7506] | 230 | netcdf_folder = 'netcdf' |
---|
[7610] | 231 | mingw = 'MinGW-5.1.6.exe' |
---|
[7489] | 232 | |
---|
| 233 | # Generate NSI file |
---|
[7901] | 234 | create_config(anuga_release_number, anuga_release_name, anuga_viewer_folder, |
---|
| 235 | python, numpy, scientific_python, matplotlib, netcdf_folder, |
---|
[7489] | 236 | mingw) |
---|
| 237 | |
---|
[7901] | 238 | # Package up files necessary to compile the installer on Windows and |
---|
[7489] | 239 | # move to release area |
---|
[7901] | 240 | # Cleanup in case there was something left from a previous attempt |
---|
| 241 | do_cmd('cd %s; /bin/rm -rf windows_installer' % release_dir) |
---|
[7489] | 242 | |
---|
| 243 | # Create subdirectories for windows installer |
---|
[7901] | 244 | do_cmd('cd %s; mkdir -p windows_installer/files' % release_dir) |
---|
[7489] | 245 | |
---|
| 246 | # Copy installion scrips and imagery across |
---|
[7901] | 247 | do_cmd('cp *.bmp *.nsh *.nsi *.ico %s/windows_installer' % release_dir) |
---|
[7489] | 248 | |
---|
| 249 | # Copy actual files used by Windows installer across |
---|
[7901] | 250 | do_cmd('cd files; cp -r * %s/windows_installer/files' % release_dir) |
---|
[7489] | 251 | |
---|
| 252 | # Come back to starting directory |
---|
| 253 | os.chdir(root) |
---|
[7901] | 254 | |
---|
[7489] | 255 | # Grab license file from anuga_core and copy to installer |
---|
[7901] | 256 | do_cmd('cp anuga_core/source/anuga/LICENSE.txt %s/windows_installer/files' |
---|
| 257 | % release_dir) |
---|
[7489] | 258 | |
---|
[7901] | 259 | xlog('NSI installer created') |
---|
[7489] | 260 | |
---|
[7901] | 261 | ###### |
---|
[4837] | 262 | # Print list of release files |
---|
[7901] | 263 | ###### |
---|
[3934] | 264 | |
---|
[7901] | 265 | xlog('Done') |
---|
| 266 | print('') |
---|
| 267 | print('') |
---|
| 268 | print(lsep) |
---|
| 269 | xlog('The release files are in %s:' % release_dir) |
---|
| 270 | os.system('ls -la %s' % release_dir) |
---|
| 271 | print(lsep) |
---|
| 272 | print('') |
---|
[4837] | 273 | |
---|
[7901] | 274 | ###### |
---|
[4837] | 275 | # Copy release to various destinations |
---|
[7901] | 276 | ###### |
---|
[7489] | 277 | |
---|
[7901] | 278 | # # Copy to the ANU |
---|
| 279 | # #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision) |
---|
| 280 | # s = 'scp -r %s ole@datamining.anu.edu.au:public_html/software/anuga' %(release_dir) |
---|
| 281 | # print s |
---|
| 282 | # os.system(s) |
---|
[3934] | 283 | |
---|
[7901] | 284 | ###### |
---|
[3934] | 285 | # Throw away code to drop all files into the RAMP download area |
---|
[4532] | 286 | # This is hardwired for Ole but shows how such a thing can be done |
---|
| 287 | # automatically. |
---|
[7901] | 288 | ###### |
---|
[3934] | 289 | |
---|
[3937] | 290 | if get_user_name() == 'ole' and get_host_name() == 'nautilus': |
---|
[6426] | 291 | answer = raw_input('Do you want to move this to the GA NAS? Y/N [Y]') |
---|
[4802] | 292 | if answer.lower() == 'n': |
---|
| 293 | import sys; sys.exit() |
---|
| 294 | |
---|
[4531] | 295 | print 'Attempt to rsync data to perlite and datamining' |
---|
[5746] | 296 | # Copy to Georisk |
---|
[7901] | 297 | s = ('rsync -avz %s/* onielsen@cyclone:georisk/downloads/ANUGA_install/%s' |
---|
| 298 | % (release_dir, 'anuga_%s' % anuga_release_number)) |
---|
[3937] | 299 | print s |
---|
[7901] | 300 | os.system(s) |
---|
| 301 | |
---|
| 302 | #os.system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)# |
---|
| 303 | |
---|
| 304 | ###### |
---|
| 305 | # Little reminders |
---|
| 306 | ###### |
---|
| 307 | |
---|
| 308 | xlog('Remember to update') |
---|
| 309 | xlog(' anuga_whats_new.tex') |
---|
| 310 | xlog(' sourceforge') |
---|
| 311 | xlog(' code.google.com') |
---|