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 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
13 | |
---|
14 | |
---|
15 | if platform == 'win32': |
---|
16 | msg = 'This script is not written for Windows.'+\ |
---|
17 | 'Please run it on a Unix platform' |
---|
18 | raise Exception, msg |
---|
19 | |
---|
20 | |
---|
21 | # Define main version manually |
---|
22 | major_revision = '1.0beta' |
---|
23 | |
---|
24 | |
---|
25 | # Refresh sandit and retrieve svn revision number |
---|
26 | # from last line in svn update output |
---|
27 | filename = mktemp() + '.txt' |
---|
28 | |
---|
29 | s = 'svn update > %s' %filename |
---|
30 | print s |
---|
31 | system(s) |
---|
32 | |
---|
33 | fid = open(filename) |
---|
34 | last_line = fid.readlines()[-1] |
---|
35 | remove(filename) |
---|
36 | if not (last_line.startswith('At revision') or\ |
---|
37 | last_line.startswith('Updated to revision')): |
---|
38 | msg = 'Unexpected output from svn up: %s' %last_line |
---|
39 | raise Exception, msg |
---|
40 | |
---|
41 | fields = last_line.split() |
---|
42 | svn_revision = fields[-1][:-1] |
---|
43 | |
---|
44 | revision = '%s_%s' %(major_revision, svn_revision) |
---|
45 | |
---|
46 | print 'Creating ANUGA revision %s' %revision |
---|
47 | |
---|
48 | distro_filename = 'anuga-%s.tgz' %revision |
---|
49 | |
---|
50 | # Create area directory |
---|
51 | release_dir = '~/anuga_release_%s' %revision |
---|
52 | s = 'mkdir %s' %release_dir |
---|
53 | try: |
---|
54 | system(s) |
---|
55 | except: |
---|
56 | pass |
---|
57 | |
---|
58 | |
---|
59 | # Export a clean directory tree from the working copy |
---|
60 | distro_dir = mktemp() |
---|
61 | s = 'mkdir %s' %distro_dir |
---|
62 | print s |
---|
63 | system(s) |
---|
64 | |
---|
65 | s = 'svn export anuga_core/source/anuga %s/anuga' %(distro_dir) |
---|
66 | print s |
---|
67 | system(s) |
---|
68 | |
---|
69 | # Zip it up |
---|
70 | s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename) |
---|
71 | print s |
---|
72 | system(s) |
---|
73 | |
---|
74 | # Move distro to release area |
---|
75 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
76 | print s |
---|
77 | system(s) |
---|
78 | |
---|
79 | # Clean up |
---|
80 | s = '/bin/rm -rf %s/anuga' %(distro_dir) |
---|
81 | print s |
---|
82 | system(s) |
---|
83 | |
---|
84 | |
---|
85 | #----------------------------- |
---|
86 | # Get validation_files as well |
---|
87 | |
---|
88 | s = 'mkdir %s/anuga_validation' %distro_dir |
---|
89 | system(s) |
---|
90 | |
---|
91 | s = 'svn export anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\ |
---|
92 | %(distro_dir) |
---|
93 | print s |
---|
94 | system(s) |
---|
95 | |
---|
96 | s = 'svn export anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\ |
---|
97 | %(distro_dir) |
---|
98 | print s |
---|
99 | system(s) |
---|
100 | |
---|
101 | # Other validations in here!!! |
---|
102 | |
---|
103 | # Zip it up |
---|
104 | s = 'cd %s;tar cvfz anuga_validation-%s.tgz *'\ |
---|
105 | %(distro_dir, revision) |
---|
106 | print s |
---|
107 | system(s) |
---|
108 | |
---|
109 | # Move distro to release area |
---|
110 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
111 | print s |
---|
112 | system(s) |
---|
113 | |
---|
114 | # Clean up |
---|
115 | s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) |
---|
116 | print s |
---|
117 | system(s) |
---|
118 | |
---|
119 | |
---|
120 | #----------------------------- |
---|
121 | # Get demos from user manual |
---|
122 | |
---|
123 | #s = 'mkdir %s/anuga_demos' %distro_dir |
---|
124 | #system(s) |
---|
125 | |
---|
126 | s = 'svn export anuga_core/documentation/user_manual/demos %s/anuga_demos'\ |
---|
127 | %(distro_dir) |
---|
128 | print s |
---|
129 | system(s) |
---|
130 | |
---|
131 | # Zip it up |
---|
132 | s = 'cd %s;tar cvfz anuga_demos-%s.tgz *'\ |
---|
133 | %(distro_dir, revision) |
---|
134 | print s |
---|
135 | system(s) |
---|
136 | |
---|
137 | # Move distro to release area |
---|
138 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
139 | print s |
---|
140 | system(s) |
---|
141 | |
---|
142 | # Clean up |
---|
143 | s = '/bin/rm -rf %s/anuga_demos' %(distro_dir) |
---|
144 | print s |
---|
145 | system(s) |
---|
146 | |
---|
147 | |
---|
148 | |
---|
149 | #----------------------------- |
---|
150 | # Copy anuga_viewer |
---|
151 | s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s'\ |
---|
152 | %(distro_dir) |
---|
153 | print s |
---|
154 | system(s) |
---|
155 | |
---|
156 | # Move distro to release area |
---|
157 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
158 | print s |
---|
159 | system(s) |
---|
160 | |
---|
161 | #----------------------------- |
---|
162 | # Hey, why not compile and bundle up the LaTeX documentation as well |
---|
163 | |
---|
164 | s = 'cd anuga_core/documentation/user_manual;' |
---|
165 | s += 'python update_anuga_user_manual.py --no_html' |
---|
166 | print s |
---|
167 | system(s) |
---|
168 | |
---|
169 | release_name = 'anuga_user_manual-%s.pdf' %revision |
---|
170 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\ |
---|
171 | %(release_dir, release_name) |
---|
172 | print s |
---|
173 | system(s) |
---|
174 | |
---|
175 | |
---|
176 | release_name = 'anuga_installation_guide-%s.pdf' %revision |
---|
177 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name) |
---|
178 | |
---|
179 | print s |
---|
180 | system(s) |
---|
181 | |
---|
182 | |
---|
183 | |
---|
184 | #----------------------------- |
---|
185 | print 'Done' |
---|
186 | print |
---|
187 | print |
---|
188 | print 'The release files are in %s:' %release_dir |
---|
189 | system('ls -la %s' %release_dir) |
---|
190 | |
---|
191 | |
---|
192 | |
---|
193 | #---------------------------- |
---|
194 | # Throw away code to drop all files into the RAMP download area |
---|
195 | # This is hardwired for Ole |
---|
196 | |
---|
197 | if get_user_name() == 'ole' and get_host_name() == 'nautilus': |
---|
198 | |
---|
199 | # Copy to RAMP |
---|
200 | s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision) |
---|
201 | print s |
---|
202 | system(s) |
---|
203 | |
---|
204 | #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)# |
---|
205 | |
---|
206 | |
---|
207 | |
---|
208 | # Copy to the ANU |
---|
209 | |
---|
210 | s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision) |
---|
211 | print s |
---|
212 | system(s) |
---|
213 | |
---|
214 | |
---|