Commit e2a95639 authored by Nico Weber's avatar Nico Weber

win: Make chrome.7z generation more deterministic.

mini_installer.exe embeds chrome.7z, and chrome.7z contains timestamps
of all files in the archive. To make chrome.7z more deterministic, give
all files in it deterministic timestamps.

Bug: 330260
Change-Id: Ia251dd38177acbebdde288b86826986f441b2d4d
Reviewed-on: https://chromium-review.googlesource.com/c/1302393Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603171}
parent 6616a799
...@@ -13,10 +13,10 @@ import sys ...@@ -13,10 +13,10 @@ import sys
def main(): def main():
argument_parser = argparse.ArgumentParser() argument_parser = argparse.ArgumentParser()
argument_parser.add_argument('output_file', help='The file to write to') argument_parser.add_argument('output_file', help='The file to write to')
argument_parser.add_argument('timestamp') argument_parser.add_argument('timestamp', type=int)
args = argument_parser.parse_args() args = argument_parser.parse_args()
date = datetime.datetime.utcfromtimestamp(int(args.timestamp)) date = datetime.datetime.utcfromtimestamp(args.timestamp)
output = ('// Generated by //build/write_build_date_header.py\n' output = ('// Generated by //build/write_build_date_header.py\n'
'#ifndef BUILD_DATE\n' '#ifndef BUILD_DATE\n'
'#define BUILD_DATE "{:%b %d %Y %H:%M:%S}"\n' '#define BUILD_DATE "{:%b %d %Y %H:%M:%S}"\n'
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import("//build/config/compiler/compiler.gni") import("//build/config/compiler/compiler.gni")
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/config/ui.gni") import("//build/config/ui.gni")
import("//build/timestamp.gni")
import("//chrome/process_version_rc_template.gni") import("//chrome/process_version_rc_template.gni")
import("//components/nacl/features.gni") import("//components/nacl/features.gni")
import("//third_party/icu/config.gni") import("//third_party/icu/config.gni")
...@@ -146,6 +147,8 @@ template("generate_mini_installer") { ...@@ -146,6 +147,8 @@ template("generate_mini_installer") {
packed_files_rc_file, packed_files_rc_file,
] ]
args = [ args = [
"--timestamp",
build_timestamp,
"--build_dir", "--build_dir",
rebase_path(root_out_dir, root_build_dir), rebase_path(root_out_dir, root_build_dir),
"--staging_dir", "--staging_dir",
......
...@@ -94,11 +94,12 @@ def CompressUsingLZMA(build_dir, compressed_file, input_file, verbose): ...@@ -94,11 +94,12 @@ def CompressUsingLZMA(build_dir, compressed_file, input_file, verbose):
RunSystemCommand(cmd, verbose) RunSystemCommand(cmd, verbose)
def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir, def CopyAllNonComponentFilesToStagingDir(config, distribution, staging_dir,
enable_hidpi): build_dir, enable_hidpi):
"""Copies the files required for installer archive. """Copies the files required for installer archive.
Copies all common files required for various distributions of Chromium and Copies all common files required for various distributions of Chromium and
also files for the specific Chromium build specified by distribution. also files for the specific Chromium build specified by distribution.
Files that might be needed in a component build are copied later.
""" """
CopySectionFilesToStagingDir(config, 'GENERAL', staging_dir, build_dir) CopySectionFilesToStagingDir(config, 'GENERAL', staging_dir, build_dir)
if distribution: if distribution:
...@@ -541,15 +542,27 @@ def main(options): ...@@ -541,15 +542,27 @@ def main(options):
options.output_name) options.output_name)
# Copy the files from the build dir. # Copy the files from the build dir.
CopyAllFilesToStagingDir(config, options.distribution, CopyAllNonComponentFilesToStagingDir(config, options.distribution,
staging_dir, options.build_dir, staging_dir, options.build_dir,
options.enable_hidpi) options.enable_hidpi)
if options.component_build == '1': if options.component_build == '1':
DoComponentBuildTasks(staging_dir, options.build_dir, DoComponentBuildTasks(staging_dir, options.build_dir,
options.target_arch, options.setup_runtime_deps, options.target_arch, options.setup_runtime_deps,
options.chrome_runtime_deps, current_version) options.chrome_runtime_deps, current_version)
# 7za/7zr don't have a flag to set the timestamp of files in the archive
# (important for build reproducibility). Since everything gets copied into
# a staging dir, just set the on-disk mtime of everything in the staging
# dir instead.
if options.timestamp is not None:
timestamp_mtime_atime = (options.timestamp, options.timestamp)
for path, dirs, files in os.walk(staging_dir):
for f in files:
os.utime(os.path.join(path, f), timestamp_mtime_atime)
for d in dirs:
os.utime(os.path.join(path, d), timestamp_mtime_atime)
version_numbers = current_version.split('.') version_numbers = current_version.split('.')
current_build_number = version_numbers[2] + '.' + version_numbers[3] current_build_number = version_numbers[2] + '.' + version_numbers[3]
prev_build_number = '' prev_build_number = ''
...@@ -623,6 +636,8 @@ def _ParseOptions(): ...@@ -623,6 +636,8 @@ def _ParseOptions():
help='Specify the target architecture for installer - this is used ' help='Specify the target architecture for installer - this is used '
'to determine which CRT runtime files to pull and package ' 'to determine which CRT runtime files to pull and package '
'with the installer archive {x86|x64}.') 'with the installer archive {x86|x64}.')
parser.add_option('--timestamp', type=int,
help='If set, used as timestamp for all files in the archive.')
parser.add_option('-v', '--verbose', action='store_true', dest='verbose', parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
default=False) default=False)
......
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