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, stdout |
---|
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 | from anuga.anuga_config import major_revision |
---|
30 | |
---|
31 | |
---|
32 | if platform == 'win32': |
---|
33 | msg = 'This script is not written for Windows.'+\ |
---|
34 | 'Please run it on a Unix platform' |
---|
35 | raise Exception, msg |
---|
36 | |
---|
37 | |
---|
38 | # Define main version manually |
---|
39 | # major_revision = '1.0beta' |
---|
40 | |
---|
41 | # line separator |
---|
42 | lsep = '----------------------------------------------------------------------' |
---|
43 | |
---|
44 | |
---|
45 | # Get svn revision number and create |
---|
46 | # file with version info for release. |
---|
47 | # This will mean that the version currently checked out is |
---|
48 | # the one which will be released. |
---|
49 | |
---|
50 | svn_revision = get_revision_number() |
---|
51 | revision = '%s_%s' %(major_revision, svn_revision) |
---|
52 | print 'Creating ANUGA revision %s' %revision |
---|
53 | |
---|
54 | distro_filename = 'anuga-%s.tgz' %revision |
---|
55 | |
---|
56 | # Create area directory |
---|
57 | release_dir = '~/anuga_release_%s' %revision |
---|
58 | s = 'mkdir %s' %release_dir |
---|
59 | try: |
---|
60 | print s |
---|
61 | system(s) |
---|
62 | except: |
---|
63 | pass |
---|
64 | |
---|
65 | |
---|
66 | # Export a clean directory tree from the working copy to a temporary dir |
---|
67 | distro_dir = mktemp() |
---|
68 | s = 'mkdir %s' %distro_dir |
---|
69 | print s |
---|
70 | system(s) |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | s = 'svn export -r %d anuga_core/source/anuga %s/anuga' %(svn_revision, |
---|
75 | distro_dir) |
---|
76 | print s |
---|
77 | system(s) |
---|
78 | |
---|
79 | |
---|
80 | # Store file with revision info for use with get_revision_number |
---|
81 | store_version_info(destination_path=distro_dir+'/anuga', verbose=True) |
---|
82 | |
---|
83 | # Zip it up |
---|
84 | s = 'cd %s;tar cvfz %s *' %(distro_dir, distro_filename) |
---|
85 | print s |
---|
86 | system(s) |
---|
87 | |
---|
88 | # Move distro to release area |
---|
89 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
90 | print s |
---|
91 | system(s) |
---|
92 | |
---|
93 | # Clean up |
---|
94 | s = '/bin/rm -rf %s/anuga' %(distro_dir) |
---|
95 | print s |
---|
96 | system(s) |
---|
97 | |
---|
98 | |
---|
99 | #----------------------------- |
---|
100 | # Get validation_files as well |
---|
101 | |
---|
102 | s = 'mkdir %s/anuga_validation' %distro_dir |
---|
103 | system(s) |
---|
104 | |
---|
105 | s = 'svn export anuga_validation/okushiri_2005 %s/anuga_validation/okushiri'\ |
---|
106 | %(distro_dir) |
---|
107 | print s |
---|
108 | system(s) |
---|
109 | |
---|
110 | s = 'svn export anuga_validation/solitary_waves %s/anuga_validation/solitary_waves'\ |
---|
111 | %(distro_dir) |
---|
112 | print s |
---|
113 | system(s) |
---|
114 | |
---|
115 | # Other validations in here!!! |
---|
116 | |
---|
117 | # Zip it up |
---|
118 | s = 'cd %s;tar cvfz anuga_validation-%s.tgz *'\ |
---|
119 | %(distro_dir, revision) |
---|
120 | print s |
---|
121 | system(s) |
---|
122 | |
---|
123 | # Move distro to release area |
---|
124 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
125 | print s |
---|
126 | system(s) |
---|
127 | |
---|
128 | # Clean up |
---|
129 | s = '/bin/rm -rf %s/anuga_validation' %(distro_dir) |
---|
130 | print s |
---|
131 | system(s) |
---|
132 | |
---|
133 | |
---|
134 | #----------------------------- |
---|
135 | # Get demos from user manual |
---|
136 | |
---|
137 | #s = 'mkdir %s/anuga_demos' %distro_dir |
---|
138 | #system(s) |
---|
139 | |
---|
140 | s = 'svn export anuga_core/documentation/user_manual/demos %s/anuga_demos'\ |
---|
141 | %(distro_dir) |
---|
142 | print s |
---|
143 | system(s) |
---|
144 | |
---|
145 | # Zip it up |
---|
146 | s = 'cd %s;tar cvfz anuga_demos-%s.tgz *'\ |
---|
147 | %(distro_dir, revision) |
---|
148 | print s |
---|
149 | system(s) |
---|
150 | |
---|
151 | # Move distro to release area |
---|
152 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
153 | print s |
---|
154 | system(s) |
---|
155 | |
---|
156 | # Clean up |
---|
157 | s = '/bin/rm -rf %s/anuga_demos' %(distro_dir) |
---|
158 | print s |
---|
159 | system(s) |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | #----------------------------- |
---|
164 | # Copy and rename anuga_viewer |
---|
165 | s = '/bin/cp ./anuga_core/source/anuga_viewer/distros/anuga_viewer_1.0.tgz %s/anuga_viewer-%s.tgz' %(distro_dir, revision) |
---|
166 | print s |
---|
167 | system(s) |
---|
168 | |
---|
169 | |
---|
170 | # Move viewer to release area |
---|
171 | s = '/bin/mv %s/*.tgz %s' %(distro_dir, release_dir) |
---|
172 | print s |
---|
173 | system(s) |
---|
174 | |
---|
175 | |
---|
176 | |
---|
177 | #----------------------------- |
---|
178 | # Hey, why not compile and bundle up the LaTeX documentation as well |
---|
179 | |
---|
180 | print |
---|
181 | print lsep |
---|
182 | print 'Preparing User Manual (see update_anuga_user_manual.log)' |
---|
183 | print lsep |
---|
184 | s = 'cd anuga_core/documentation/user_manual;' |
---|
185 | s += 'python update_anuga_user_manual.py --no_html' |
---|
186 | print s |
---|
187 | system(s + ' 1>update_anuga_user_manual.log 2>/dev/null') |
---|
188 | |
---|
189 | release_name = 'anuga_user_manual-%s.pdf' %revision |
---|
190 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_user_manual.pdf %s/%s'\ |
---|
191 | %(release_dir, release_name) |
---|
192 | print s |
---|
193 | system(s) |
---|
194 | |
---|
195 | release_name = 'anuga_installation_guide-%s.pdf' %revision |
---|
196 | s = '/bin/mv anuga_core/documentation/user_manual/anuga_installation_guide.pdf %s/%s' %(release_dir, release_name) |
---|
197 | |
---|
198 | print s |
---|
199 | system(s) |
---|
200 | |
---|
201 | |
---|
202 | #----------------------------- |
---|
203 | |
---|
204 | print 'Done' |
---|
205 | print |
---|
206 | print |
---|
207 | print lsep |
---|
208 | print 'The release files are in %s:' %release_dir |
---|
209 | system('ls -la %s' %release_dir) |
---|
210 | print lsep |
---|
211 | print |
---|
212 | print |
---|
213 | |
---|
214 | answer = raw_input('Do you want to upload this to sourceforge? Y/N [Y]') |
---|
215 | if answer.lower() != 'n': |
---|
216 | |
---|
217 | #------------------------------ |
---|
218 | print 'Uploading to sourceforge' |
---|
219 | |
---|
220 | |
---|
221 | import os, os.path |
---|
222 | release_dir = os.path.expanduser(release_dir) |
---|
223 | os.chdir(release_dir) |
---|
224 | print 'Reading from', os.getcwd() |
---|
225 | |
---|
226 | |
---|
227 | from ftplib import FTP |
---|
228 | ftp = FTP('upload.sourceforge.net') |
---|
229 | print ftp.login() # Anonymous |
---|
230 | print ftp.cwd('incoming') |
---|
231 | |
---|
232 | |
---|
233 | for filename in os.listdir('.'): |
---|
234 | print 'Uploading %s... ' %filename, |
---|
235 | stdout.flush() |
---|
236 | |
---|
237 | fid=open(filename, 'rb') |
---|
238 | print ftp.storbinary('STOR %s' %filename, fid) |
---|
239 | fid.close() |
---|
240 | |
---|
241 | print 'FTP done' |
---|
242 | print ftp.quit() |
---|
243 | |
---|
244 | print |
---|
245 | print lsep |
---|
246 | print ' ********************* NOTE *************************' |
---|
247 | print lsep |
---|
248 | print 'To complete this release you must log into' |
---|
249 | print 'http://sourceforge.net/projects/anuga as ANUGA admin' |
---|
250 | print 'and complete the process by selecting File Releases ' |
---|
251 | print 'in the admin menu there.' |
---|
252 | print lsep |
---|
253 | print |
---|
254 | print |
---|
255 | |
---|
256 | |
---|
257 | |
---|
258 | import sys; sys.exit() |
---|
259 | |
---|
260 | #---------------------------- |
---|
261 | # Throw away code to drop all files into the RAMP download area |
---|
262 | # This is hardwired for Ole but shows how such a thing can be done |
---|
263 | # automatically. |
---|
264 | |
---|
265 | if get_user_name() == 'ole' and get_host_name() == 'nautilus': |
---|
266 | |
---|
267 | print 'Attempt to rsync data to perlite and datamining' |
---|
268 | # Copy to RAMP |
---|
269 | s = 'rsync -avz %s/* onielsen@cyclone:/d/cit/1/cit/natural_hazard_impacts/downloads/ANUGA_install/%s' %(release_dir, 'anuga_%s' %revision) |
---|
270 | print s |
---|
271 | system(s) |
---|
272 | |
---|
273 | #system('scp %s/*.pdf onielsen@cyclone:/d/cit/1/cit/risk_assessment_methods_project/downloads/ANUGA_install' %release_dir)# |
---|
274 | |
---|
275 | |
---|
276 | |
---|
277 | # Copy to the ANU |
---|
278 | #s = 'rsync -avz %s/* ole@datamining.anu.edu.au:public_html/software/anuga/%s' %(release_dir, 'anuga_%s' %revision) |
---|
279 | #print s |
---|
280 | #system(s) |
---|
281 | |
---|
282 | |
---|