Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(987)

Side by Side Diff: chrome/tools/build/make_zip.py

Issue 2585633002: Fix duplicate name warnings from make_zip, and pass allowZip64. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import glob 6 import glob
7 import os 7 import os
8 import sys 8 import sys
9 import zipfile 9 import zipfile
10 10
11 11
12 def main(args): 12 def main(args):
13 if len(args) != 3: 13 if len(args) != 3:
14 print 'usage: make_zip.py build_dir FILES.cfg output.zip' 14 print 'usage: make_zip.py build_dir FILES.cfg output.zip'
15 return 1 15 return 1
16 (build_dir, cfg_file, output_file) = args 16 (build_dir, cfg_file, output_file) = args
17 17
18 exec_globals = {'__builtins__': None} 18 exec_globals = {'__builtins__': None}
19 execfile(cfg_file, exec_globals) 19 execfile(cfg_file, exec_globals)
20 20
21 cwd = os.getcwd() 21 cwd = os.getcwd()
22 os.chdir(build_dir) 22 os.chdir(build_dir)
23 23
24 files = [] 24 files = set()
25 for file_spec in exec_globals['FILES']: 25 for file_spec in exec_globals['FILES']:
26 pattern = file_spec['filename'] 26 pattern = file_spec['filename']
27 for glob_match in glob.glob(pattern): 27 for glob_match in glob.glob(pattern):
28 if os.path.isfile(glob_match): 28 if os.path.isfile(glob_match):
29 files.append(glob_match) 29 files.add(glob_match)
30 elif os.path.isdir(glob_match): 30 elif os.path.isdir(glob_match):
31 for root, dirs, filenames in os.walk(glob_match): 31 for root, dirs, filenames in os.walk(glob_match):
32 for f in filenames: 32 for f in filenames:
33 files.append(os.path.join(root, f)); 33 files.add(os.path.join(root, f));
34 34
35 os.chdir(cwd) 35 os.chdir(cwd)
36 if not len(files): 36 if not len(files):
37 print 'error: no files found in %s' % build_dir 37 print 'error: no files found in %s' % build_dir
38 return 1 38 return 1
39 39
40 with zipfile.ZipFile(output_file, mode = 'w', 40 with zipfile.ZipFile(output_file, mode = 'w',
41 compression = zipfile.ZIP_DEFLATED) as output: 41 compression = zipfile.ZIP_DEFLATED, allowZip64 = True) as output:
42 for f in files: 42 for f in sorted(files):
43 sys.stdout.write("%s\r" % f[:40].ljust(40, ' ')) 43 sys.stdout.write("%s\r" % f[:40].ljust(40, ' '))
44 sys.stdout.flush() 44 sys.stdout.flush()
45 output.write(os.path.join(build_dir, f), f) 45 output.write(os.path.join(build_dir, f), f)
46 46
47 print 'wrote %s' % output_file 47 print 'wrote %s' % output_file
48 48
49 49
50 if __name__ == '__main__': 50 if __name__ == '__main__':
51 sys.exit(main(sys.argv[1:])) 51 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698