13
13
################################
14
14
# Parse command line args
15
15
parser = argparse .ArgumentParser (description = 'Package nw binaries.' )
16
- parser .add_argument ('-p' ,'--path' ,help = 'Where to find the binaries, like out/Release' , required = False )
17
- parser .add_argument ('-s' ,'--step' ,help = 'Execute specified step. (could be "nw", "chromedriver" or "symbol")' , required = False )
16
+ parser .add_argument ('-p' ,'--path' , help = 'Where to find the binaries, like out/Release' , required = False )
17
+ parser .add_argument ('-s' ,'--step' , help = 'Execute specified step. (could be "nw", "chromedriver" or "symbol")' , required = False )
18
+ # AWS uploader args
19
+ # Example: package_binaries.py -u -b linux_32bit -r 123 -n 99 -t my_bucket -i <id> -k <key>
20
+ parser .add_argument ('-u' ,'--upload' , help = 'Run aws uploader' , action = 'store_true' , required = False )
21
+ parser .add_argument ('-b' ,'--buildername' , help = 'Builder name' , required = False )
22
+ parser .add_argument ('-r' ,'--revision' , help = 'Build revision' ,required = False )
23
+ parser .add_argument ('-n' ,'--number' , help = 'Build number' , required = False )
24
+ parser .add_argument ('-t' ,'--bucket' , help = 'AWS bucket name' , required = False )
25
+ parser .add_argument ('-i' ,'--awsid' , help = 'AWS_ACCESS_KEY_ID' , required = False )
26
+ parser .add_argument ('-k' ,'--awskey' , help = 'AWS_SECRET_ACCESS_KEY' , required = False )
27
+
18
28
args = parser .parse_args ()
19
29
20
30
################################
24
34
arch = None # ia32/x64
25
35
step = None # nw/chromedriver/symbol
26
36
nw_ver = None # x.xx
37
+ dist_dir = None # .../out/Release/dist
27
38
28
39
step = args .step
29
40
binaries_location = args .path
38
49
if not os .path .isdir (binaries_location ):
39
50
print 'Invalid path: ' + binaries_location
40
51
exit (- 1 )
52
+ binaries_location = os .path .normpath (binaries_location )
53
+ dist_dir = os .path .join (binaries_location , 'dist' )
41
54
42
55
print 'Working on ' + binaries_location
43
56
@@ -208,12 +221,10 @@ def compress(from_dir, to_dir, fname, compress):
208
221
209
222
210
223
def make_packages (targets ):
211
- dist_dir = os .path .join (binaries_location , 'dist' )
212
224
213
225
# check file existance
214
226
for t in targets :
215
227
for f in t ['input' ]:
216
- print f
217
228
src = os .path .join (binaries_location , f )
218
229
if not os .path .exists (src ):
219
230
print 'File does not exist: ' , src
@@ -230,6 +241,7 @@ def make_packages(targets):
230
241
# now let's do it
231
242
os .mkdir (dist_dir )
232
243
for t in targets :
244
+ print 'Making "' + t ['output' ] + '.' + t ['compress' ] + '"'
233
245
if (t .has_key ('folder' ) and t ['folder' ] == True ) or len (t ['input' ]) > 1 :
234
246
# copy files into a folder then pack
235
247
folder = os .path .join (dist_dir , t ['output' ])
@@ -263,7 +275,44 @@ def make_packages(targets):
263
275
targets .append (generate_target_chromedriver (platform_name , arch , nw_ver ))
264
276
targets .append (generate_target_symbols (platform_name , arch , nw_ver ))
265
277
266
- make_packages (targets )
278
+ if args .upload != True :
279
+ print 'Creating packages...'
280
+ make_packages (targets )
281
+ exit (0 )
282
+ ################################################################
283
+ # aws uploader
284
+
285
+ from datetime import date
286
+
287
+ print 'Starting aws uploader...'
288
+
289
+ # Init variables
290
+ builder_name = args .buildername
291
+ got_revision = args .revision
292
+ build_number = args .number
293
+ bucket_name = args .bucket
294
+ awsid = args .awsid
295
+ awskey = args .awskey
296
+ date = date .today ().strftime ('%m-%d-%y' )
297
+
298
+ upload_path = '' .join (['/' + date ,
299
+ '/' + builder_name + '-build-' + build_number + '-' + got_revision ])
300
+
301
+ print 'Upload path: ' + upload_path
302
+ file_list = os .listdir (dist_dir )
303
+ if len (file_list ) == 0 :
304
+ print 'Cannot find packages!'
305
+ exit (- 1 )
306
+
307
+ import boto
308
+ conn = boto .connect_s3 (awsid , awskey )
309
+ bucket = conn .get_bucket (bucket_name )
310
+ for f in file_list :
311
+ print 'Uploading "' + f + '" ...'
312
+ key = bucket .new_key (os .path .join (upload_path , f ))
313
+ key .set_contents_from_filename (os .path .join (dist_dir , f ))
314
+
315
+ print 'Done.'
267
316
268
317
269
318
# vim: et:ts=4:sw=4
0 commit comments