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