Commit 338ed667 authored by Matvey Larionov's avatar Matvey Larionov Committed by Commit Bot

Make policy_templates.zip deterministic on win

Bug: 330260
Change-Id: I93b00f0c992d879c26f883132eece92a382bb3d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1890413
Auto-Submit: Matvey Larionov <matthewtff@yandex-team.ru>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711710}
parent aca616ca
......@@ -6,26 +6,13 @@
"""
import optparse
import os
import sys
import zipfile
def add_files_to_zip(zip_file, base_dir, file_list):
"""Pack a list of files into a zip archive, that is already opened for
writing.
Args:
zip_file: An object representing the zip archive.
base_dir: Base path of all the files in the real file system.
file_list: List of absolute file paths to add. Must start with base_dir.
The base_dir is stripped in the zip file entries.
"""
if (base_dir[-1] != '/'):
base_dir += '/'
for file_path in file_list:
assert file_path.startswith(base_dir)
zip_file.write(file_path, file_path[len(base_dir):])
return 0
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)),
os.pardir, os.pardir, os.pardir,
'build', 'android', 'gyp'))
from util import build_utils
def main(argv):
......@@ -56,11 +43,8 @@ def main(argv):
else:
file_list.append(file_to_add)
zip_file = zipfile.ZipFile(options.output, 'w', zipfile.ZIP_DEFLATED)
try:
return add_files_to_zip(zip_file, options.base_dir, file_list)
finally:
zip_file.close()
with build_utils.AtomicOutput(options.output) as f:
build_utils.DoZip(file_list, f, options.base_dir)
if '__main__' == __name__:
......
......@@ -66,6 +66,5 @@
# These probably have mtimes in the zip headers and the scripts creating
# them probably should use build_utils.ZipDir() instead.
'mini_installer_tests.zip',
'policy_templates.zip',
],
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment