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

Unified Diff: build/android/gyp/util/build_utils.py

Issue 2400693002: Make apk_merger.py use hermetic timestamps. (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/tools/apk_merger.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/util/build_utils.py
diff --git a/build/android/gyp/util/build_utils.py b/build/android/gyp/util/build_utils.py
index fea8e1f79e6afbec4650a0266f01ca5eea19f6fb..4a953cdb1aa4d37da4c75ca5236bf3224c753982 100644
--- a/build/android/gyp/util/build_utils.py
+++ b/build/android/gyp/util/build_utils.py
@@ -328,7 +328,13 @@ def MergeZips(output, inputs, exclude_patterns=None, path_transform=None):
path_transform = path_transform or (lambda p, z: p)
added_names = set()
- with zipfile.ZipFile(output, 'w') as out_zip:
+ if isinstance(output, basestring):
+ out_zip = zipfile.ZipFile(output, 'w')
+ else:
+ assert isinstance(output, zipfile.ZipFile)
+ out_zip = output
+
+ try:
for in_file in inputs:
with zipfile.ZipFile(in_file, 'r') as in_zip:
in_zip._expected_crc = None
@@ -339,8 +345,12 @@ def MergeZips(output, inputs, exclude_patterns=None, path_transform=None):
dst_name = path_transform(info.filename, in_file)
already_added = dst_name in added_names
if not already_added and not MatchesGlob(dst_name, exclude_patterns):
- AddToZipHermetic(out_zip, dst_name, data=in_zip.read(info))
+ AddToZipHermetic(out_zip, dst_name, data=in_zip.read(info),
+ compress=info.compress_type != zipfile.ZIP_STORED)
added_names.add(dst_name)
+ finally:
+ if isinstance(output, basestring):
michaelbai 2016/10/06 18:05:41 nit, use variable instead of checking twice?
agrieve 2016/10/06 18:17:02 Done.
+ out_zip.close()
def PrintWarning(message):
« no previous file with comments | « android_webview/tools/apk_merger.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698