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

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

Issue 2400693002: Make apk_merger.py use hermetic timestamps. (Closed)
Patch Set: add var 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..65bd07b351ca6aaaf65b5f4a8aa050145d99d8f9 100644
--- a/build/android/gyp/util/build_utils.py
+++ b/build/android/gyp/util/build_utils.py
@@ -328,7 +328,14 @@ 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:
+ output_is_already_open = not isinstance(output, basestring)
+ if output_is_already_open:
+ assert isinstance(output, zipfile.ZipFile)
+ out_zip = output
+ else:
+ out_zip = zipfile.ZipFile(output, 'w')
+
+ try:
for in_file in inputs:
with zipfile.ZipFile(in_file, 'r') as in_zip:
in_zip._expected_crc = None
@@ -339,8 +346,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 not output_is_already_open:
+ 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