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 | |
---|
24 | # Refresh sandit and retrieve minor revision number |
---|
25 | filename = mktemp() + '.txt' |
---|
26 | |
---|
27 | s = 'svn update > %s' %filename |
---|
28 | print s |
---|
29 | system(s) |
---|
30 | |
---|
31 | fid = open(filename) |
---|
32 | line = fid.read() |
---|
33 | remove(filename) |
---|
34 | |
---|
35 | if not line.startswith('At revision'): |
---|
36 | msg = 'Unexpected output from svn up: %s' %line |
---|
37 | raise Exception, msg |
---|
38 | |
---|
39 | minor_revision = line[12:-2] |
---|
40 | |
---|
41 | revision = '%s_%s' %(major_revision, minor_revision) |
---|
42 | |
---|
43 | distro_filename = 'anuga-%s.tgz' %revision |
---|
44 | |
---|
45 | # Export a clean directory tree from the working copy |
---|
46 | distro_dir = mktemp() |
---|
47 | s = 'mkdir %s' %distro_dir |
---|
48 | print s |
---|
49 | system(s) |
---|
50 | |
---|
51 | s = 'svn export anuga_core/source/anuga %s/anuga' %(distro_dir) |
---|
52 | print s |
---|
53 | system(s) |
---|
54 | |
---|
55 | # Zip it up |
---|
56 | s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename) |
---|
57 | print s |
---|
58 | system(s) |
---|
59 | |
---|
60 | # Clean up |
---|
61 | s = '/bin/rm -rf %s/anuga' %(distro_dir) |
---|
62 | print s |
---|
63 | system(s) |
---|
64 | |
---|
65 | # Get validation_files as well |
---|
66 | s = 'svn export anuga_validation/okushiri_2005 %s/okushiri' %(distro_dir) |
---|
67 | print s |
---|
68 | system(s) |
---|
69 | |
---|
70 | # Other validations in here!!! |
---|
71 | |
---|
72 | # Zip it up |
---|
73 | s = 'cd %s;tar cvfz anuga_validation-%s.tgz *'\ |
---|
74 | %(distro_dir, revision) |
---|
75 | print s |
---|
76 | system(s) |
---|
77 | |
---|
78 | # Clean up |
---|
79 | s = '/bin/rm -rf %s/okushiri' %(distro_dir) |
---|
80 | print s |
---|
81 | system(s) |
---|
82 | |
---|
83 | # Copy anuga_viewer |
---|
84 | s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s'\ |
---|
85 | %(distro_dir) |
---|
86 | print s |
---|
87 | system(s) |
---|
88 | |
---|
89 | # Move tar files to release area |
---|
90 | |
---|
91 | release_dir = '~/anuga_release_%s' %revision |
---|
92 | s = 'mkdir %s' %release_dir |
---|
93 | try: |
---|
94 | system(s) |
---|
95 | except: |
---|
96 | pass |
---|
97 | |
---|
98 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
99 | print s |
---|
100 | system(s) |
---|
101 | print 'Done' |
---|
102 | print |
---|
103 | print |
---|
104 | print 'The release files are in %s:' %release_dir |
---|
105 | system('ls -la %s' %release_dir) |
---|