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 | # 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 | |
---|
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 | |
---|
69 | # Move distro to release area |
---|
70 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
71 | print s |
---|
72 | system(s) |
---|
73 | |
---|
74 | # Clean up |
---|
75 | s = '/bin/rm -rf %s/anuga' %(distro_dir) |
---|
76 | print s |
---|
77 | system(s) |
---|
78 | |
---|
79 | |
---|
80 | #----------------------------- |
---|
81 | # Get validation_files as well |
---|
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) |
---|
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 | |
---|
99 | # Move distro to release area |
---|
100 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
101 | print s |
---|
102 | system(s) |
---|
103 | |
---|
104 | # Clean up |
---|
105 | s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) |
---|
106 | print s |
---|
107 | system(s) |
---|
108 | |
---|
109 | #----------------------------- |
---|
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 | |
---|
116 | # Move distro to release area |
---|
117 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
118 | print s |
---|
119 | system(s) |
---|
120 | |
---|
121 | |
---|
122 | #----------------------------- |
---|
123 | print 'Done' |
---|
124 | print |
---|
125 | print |
---|
126 | print 'The release files are in %s:' %release_dir |
---|
127 | system('ls -la %s' %release_dir) |
---|