[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 | |
---|
| 6 | This script works only on Linux |
---|
| 7 | """ |
---|
| 8 | |
---|
| 9 | from os import sep, system, remove |
---|
| 10 | from tempfile import mktemp |
---|
| 11 | from sys import platform |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | if platform == 'win32': |
---|
| 15 | msg = 'This script is not written for Windows.'+\ |
---|
| 16 | 'Please run it on a Unix platform' |
---|
| 17 | raise Exception, msg |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | # Define main version manually |
---|
| 21 | major_revision = '1.0' |
---|
| 22 | |
---|
| 23 | |
---|
[3922] | 24 | # Refresh sandit and retrieve svn revision number |
---|
| 25 | # from last line in svn update output |
---|
[3892] | 26 | filename = mktemp() + '.txt' |
---|
| 27 | |
---|
| 28 | s = 'svn update > %s' %filename |
---|
| 29 | print s |
---|
| 30 | system(s) |
---|
| 31 | |
---|
| 32 | fid = open(filename) |
---|
[3922] | 33 | last_line = fid.readlines()[-1] |
---|
[3892] | 34 | remove(filename) |
---|
[3922] | 35 | if not last_line.startswith('At revision'): |
---|
| 36 | msg = 'Unexpected output from svn up: %s' %last_line |
---|
[3892] | 37 | raise Exception, msg |
---|
| 38 | |
---|
[3922] | 39 | svn_revision = last_line[12:-2] |
---|
[3892] | 40 | |
---|
[3922] | 41 | revision = '%s_%s' %(major_revision, svn_revision) |
---|
[3892] | 42 | |
---|
| 43 | distro_filename = 'anuga-%s.tgz' %revision |
---|
| 44 | |
---|
[3902] | 45 | # Create area directory |
---|
| 46 | release_dir = '~/anuga_release_%s' %revision |
---|
| 47 | s = 'mkdir %s' %release_dir |
---|
| 48 | try: |
---|
| 49 | system(s) |
---|
| 50 | except: |
---|
| 51 | pass |
---|
| 52 | |
---|
| 53 | |
---|
[3892] | 54 | # Export a clean directory tree from the working copy |
---|
| 55 | distro_dir = mktemp() |
---|
| 56 | s = 'mkdir %s' %distro_dir |
---|
| 57 | print s |
---|
| 58 | system(s) |
---|
| 59 | |
---|
| 60 | s = 'svn export anuga_core/source/anuga %s/anuga' %(distro_dir) |
---|
| 61 | print s |
---|
| 62 | system(s) |
---|
| 63 | |
---|
| 64 | # Zip it up |
---|
| 65 | s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename) |
---|
| 66 | print s |
---|
| 67 | system(s) |
---|
| 68 | |
---|
[3902] | 69 | # Move distro to release area |
---|
| 70 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 71 | print s |
---|
| 72 | system(s) |
---|
| 73 | |
---|
[3892] | 74 | # Clean up |
---|
| 75 | s = '/bin/rm -rf %s/anuga' %(distro_dir) |
---|
| 76 | print s |
---|
| 77 | system(s) |
---|
| 78 | |
---|
[3902] | 79 | |
---|
| 80 | #----------------------------- |
---|
[3892] | 81 | # Get validation_files as well |
---|
[3902] | 82 | |
---|
| 83 | s = 'mkdir %s/anuga_validation' %distro_dir |
---|
| 84 | system(s) |
---|
| 85 | |
---|
| 86 | s = 'svn export anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\ |
---|
| 87 | %(distro_dir) |
---|
[3892] | 88 | print s |
---|
| 89 | system(s) |
---|
| 90 | |
---|
| 91 | # Other validations in here!!! |
---|
| 92 | |
---|
| 93 | # Zip it up |
---|
| 94 | s = 'cd %s;tar cvfz anuga_validation-%s.tgz *'\ |
---|
| 95 | %(distro_dir, revision) |
---|
| 96 | print s |
---|
| 97 | system(s) |
---|
| 98 | |
---|
[3902] | 99 | # Move distro to release area |
---|
| 100 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 101 | print s |
---|
| 102 | system(s) |
---|
| 103 | |
---|
[3892] | 104 | # Clean up |
---|
[3902] | 105 | s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) |
---|
[3892] | 106 | print s |
---|
| 107 | system(s) |
---|
| 108 | |
---|
[3902] | 109 | #----------------------------- |
---|
[3892] | 110 | # Copy anuga_viewer |
---|
| 111 | s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s'\ |
---|
| 112 | %(distro_dir) |
---|
| 113 | print s |
---|
| 114 | system(s) |
---|
| 115 | |
---|
[3902] | 116 | # Move distro to release area |
---|
[3892] | 117 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
| 118 | print s |
---|
| 119 | system(s) |
---|
[3902] | 120 | |
---|
[3922] | 121 | #----------------------------- |
---|
| 122 | # Hey, why not compile and bundle up the LaTeX documentation as well |
---|
[3902] | 123 | |
---|
[3922] | 124 | s = 'cd anuga_core/documentation/user_manual;' |
---|
| 125 | s += 'python update_anuga_user_manual.py --no_html' |
---|
| 126 | print s |
---|
| 127 | system(s) |
---|
| 128 | |
---|
| 129 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s'\ |
---|
| 130 | %(release_dir) |
---|
| 131 | print s |
---|
| 132 | system(s) |
---|
| 133 | |
---|
| 134 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s'\ |
---|
| 135 | %(release_dir) |
---|
| 136 | print s |
---|
| 137 | system(s) |
---|
| 138 | |
---|
| 139 | |
---|
| 140 | |
---|
[3902] | 141 | #----------------------------- |
---|
[3892] | 142 | print 'Done' |
---|
| 143 | print |
---|
| 144 | print |
---|
| 145 | print 'The release files are in %s:' %release_dir |
---|
| 146 | system('ls -la %s' %release_dir) |
---|