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

Side by Side Diff: build/android/gyp/util/build_utils.py

Issue 1384513002: Fix unix file permissions in resource zips and jar files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import ast 5 import ast
6 import contextlib 6 import contextlib
7 import fnmatch 7 import fnmatch
8 import json 8 import json
9 import os 9 import os
10 import pipes 10 import pipes
(...skipping 10 matching lines...) Expand all
21 21
22 CHROMIUM_SRC = os.path.normpath( 22 CHROMIUM_SRC = os.path.normpath(
23 os.path.join(os.path.dirname(__file__), 23 os.path.join(os.path.dirname(__file__),
24 os.pardir, os.pardir, os.pardir, os.pardir)) 24 os.pardir, os.pardir, os.pardir, os.pardir))
25 COLORAMA_ROOT = os.path.join(CHROMIUM_SRC, 25 COLORAMA_ROOT = os.path.join(CHROMIUM_SRC,
26 'third_party', 'colorama', 'src') 26 'third_party', 'colorama', 'src')
27 # aapt should ignore OWNERS files in addition the default ignore pattern. 27 # aapt should ignore OWNERS files in addition the default ignore pattern.
28 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' + 28 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' +
29 '!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp') 29 '!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp')
30 HERMETIC_TIMESTAMP = (2001, 1, 1, 0, 0, 0) 30 HERMETIC_TIMESTAMP = (2001, 1, 1, 0, 0, 0)
31 HERMETIC_FILE_ATTR = (0644 << 16L)
31 32
32 33
33 @contextlib.contextmanager 34 @contextlib.contextmanager
34 def TempDir(): 35 def TempDir():
35 dirname = tempfile.mkdtemp() 36 dirname = tempfile.mkdtemp()
36 try: 37 try:
37 yield dirname 38 yield dirname
38 finally: 39 finally:
39 shutil.rmtree(dirname) 40 shutil.rmtree(dirname)
40 41
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 if isinstance(tup, basestring): 237 if isinstance(tup, basestring):
237 tup = (os.path.relpath(tup, base_dir), tup) 238 tup = (os.path.relpath(tup, base_dir), tup)
238 input_tuples.append(tup) 239 input_tuples.append(tup)
239 240
240 # Sort by zip path to ensure stable zip ordering. 241 # Sort by zip path to ensure stable zip ordering.
241 input_tuples.sort(key=lambda tup: tup[0]) 242 input_tuples.sort(key=lambda tup: tup[0])
242 with zipfile.ZipFile(output, 'w') as outfile: 243 with zipfile.ZipFile(output, 'w') as outfile:
243 for zip_path, fs_path in input_tuples: 244 for zip_path, fs_path in input_tuples:
244 CheckZipPath(zip_path) 245 CheckZipPath(zip_path)
245 zipinfo = zipfile.ZipInfo(filename=zip_path, date_time=HERMETIC_TIMESTAMP) 246 zipinfo = zipfile.ZipInfo(filename=zip_path, date_time=HERMETIC_TIMESTAMP)
247 zipinfo.external_attr = HERMETIC_FILE_ATTR
246 with file(fs_path) as f: 248 with file(fs_path) as f:
247 contents = f.read() 249 contents = f.read()
248 outfile.writestr(zipinfo, contents) 250 outfile.writestr(zipinfo, contents)
249 251
250 252
251 def ZipDir(output, base_dir): 253 def ZipDir(output, base_dir):
252 """Creates a zip file from a directory.""" 254 """Creates a zip file from a directory."""
253 inputs = [] 255 inputs = []
254 for root, _, files in os.walk(base_dir): 256 for root, _, files in os.walk(base_dir):
255 for f in files: 257 for f in files:
(...skipping 12 matching lines...) Expand all
268 270
269 with zipfile.ZipFile(output, 'w') as out_zip: 271 with zipfile.ZipFile(output, 'w') as out_zip:
270 for in_file in inputs: 272 for in_file in inputs:
271 with zipfile.ZipFile(in_file, 'r') as in_zip: 273 with zipfile.ZipFile(in_file, 'r') as in_zip:
272 for name in in_zip.namelist(): 274 for name in in_zip.namelist():
273 dst_name = path_transform(name, in_file) 275 dst_name = path_transform(name, in_file)
274 already_added = dst_name in added_names 276 already_added = dst_name in added_names
275 if not already_added and not MatchesGlob(dst_name, exclude_patterns): 277 if not already_added and not MatchesGlob(dst_name, exclude_patterns):
276 zipinfo = zipfile.ZipInfo(filename=dst_name, 278 zipinfo = zipfile.ZipInfo(filename=dst_name,
277 date_time=HERMETIC_TIMESTAMP) 279 date_time=HERMETIC_TIMESTAMP)
280 zipinfo.external_attr = HERMETIC_FILE_ATTR
278 out_zip.writestr(zipinfo, in_zip.read(name)) 281 out_zip.writestr(zipinfo, in_zip.read(name))
279 added_names.add(dst_name) 282 added_names.add(dst_name)
280 283
281 284
282 def PrintWarning(message): 285 def PrintWarning(message):
283 print 'WARNING: ' + message 286 print 'WARNING: ' + message
284 287
285 288
286 def PrintBigWarning(message): 289 def PrintBigWarning(message):
287 print '***** ' * 8 290 print '***** ' * 8
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 445
443 md5_check.CallAndRecordIfStale( 446 md5_check.CallAndRecordIfStale(
444 on_stale_md5, 447 on_stale_md5,
445 record_path=record_path, 448 record_path=record_path,
446 input_paths=input_paths, 449 input_paths=input_paths,
447 input_strings=input_strings, 450 input_strings=input_strings,
448 output_paths=output_paths, 451 output_paths=output_paths,
449 force=force, 452 force=force,
450 pass_changes=True) 453 pass_changes=True)
451 454
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