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

Unified Diff: build/android/gyp/finalize_apk.py

Issue 2193063002: [Android] [Reland] Sanitize APK signing file timestamps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set proper import path. Created 4 years, 5 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 | « no previous file | build/android/gyp/util/build_utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/finalize_apk.py
diff --git a/build/android/gyp/finalize_apk.py b/build/android/gyp/finalize_apk.py
index d71cb8fc7e7704fa58c20bebb2af6e83789d59bd..17e47038843a9ba39b0396a07a95b21e757bfb6e 100755
--- a/build/android/gyp/finalize_apk.py
+++ b/build/android/gyp/finalize_apk.py
@@ -7,10 +7,19 @@
"""
+# pylint: disable=unused-import
+# resource_sizes modifies zipfile for zip64 compatibility. See
+# https://bugs.python.org/issue14315.
+import os
+import sys
+sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir))
+import resource_sizes
jbudorick 2016/07/29 19:11:45 Why are these out of order?
ghost stip (do not use) 2016/07/29 20:12:09 need os and sys to do the PYTHONPATH adjustment
jbudorick 2016/07/29 20:18:08 Right, but the standard python imports should prec
+
import optparse
import shutil
import sys
import tempfile
+import zipfile
from util import build_utils
@@ -143,6 +152,15 @@ def FinalizeApk(options):
JarSigner(options.key_path, options.key_name, options.key_passwd,
apk_to_sign, signed_apk_path)
+ # Make the signing files hermetic.
+ with tempfile.NamedTemporaryFile(suffix='.zip') as hermetic_signed_apk:
+ with zipfile.ZipFile(signed_apk_path, 'r') as zi:
+ with zipfile.ZipFile(hermetic_signed_apk, 'w') as zo:
+ for info in zi.infolist():
+ info.date_time = build_utils.HERMETIC_TIMESTAMP
+ zo.writestr(info, zi.read(info.filename))
+ shutil.copy(hermetic_signed_apk.name, signed_apk_path)
+
if options.load_library_from_zip:
# Reorder the contents of the APK. This re-establishes the canonical
# order which means the library will be back at its page aligned location.
« no previous file with comments | « no previous file | build/android/gyp/util/build_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698