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 dcaa7e9ddbb23555b011aa7b3e67a82b9afa056d..94935d2d490dddbb91e175cd396c24e51117f046 100644 |
--- a/build/android/gyp/util/build_utils.py |
+++ b/build/android/gyp/util/build_utils.py |
@@ -224,6 +224,14 @@ def ExtractAll(zip_path, path=None, no_clobber=True, pattern=None, |
z.extract(name, path) |
+def CreateHermeticZipInfo(zip_path): |
+ """Creates a ZipInfo with a zero'ed out timestamp.""" |
+ CheckZipPath(zip_path) |
+ zipinfo = zipfile.ZipInfo(filename=zip_path, date_time=HERMETIC_TIMESTAMP) |
+ zipinfo.external_attr = HERMETIC_FILE_ATTR |
+ return zipinfo |
+ |
+ |
def DoZip(inputs, output, base_dir=None): |
"""Creates a zip file from a list of files. |
@@ -242,12 +250,9 @@ def DoZip(inputs, output, base_dir=None): |
input_tuples.sort(key=lambda tup: tup[0]) |
with zipfile.ZipFile(output, 'w') as outfile: |
for zip_path, fs_path in input_tuples: |
- CheckZipPath(zip_path) |
- zipinfo = zipfile.ZipInfo(filename=zip_path, date_time=HERMETIC_TIMESTAMP) |
- zipinfo.external_attr = HERMETIC_FILE_ATTR |
with file(fs_path) as f: |
contents = f.read() |
- outfile.writestr(zipinfo, contents) |
+ outfile.writestr(CreateHermeticZipInfo(zip_path), contents) |
def ZipDir(output, base_dir): |
@@ -272,13 +277,13 @@ def MergeZips(output, inputs, exclude_patterns=None, path_transform=None): |
for in_file in inputs: |
with zipfile.ZipFile(in_file, 'r') as in_zip: |
for name in in_zip.namelist(): |
+ # Ignore directories. |
+ if name[-1] == '/': |
+ continue |
dst_name = path_transform(name, in_file) |
already_added = dst_name in added_names |
if not already_added and not MatchesGlob(dst_name, exclude_patterns): |
- zipinfo = zipfile.ZipInfo(filename=dst_name, |
- date_time=HERMETIC_TIMESTAMP) |
- zipinfo.external_attr = HERMETIC_FILE_ATTR |
- out_zip.writestr(zipinfo, in_zip.read(name)) |
+ out_zip.writestr(CreateHermeticZipInfo(dst_name), in_zip.read(name)) |
added_names.add(dst_name) |