Skip to content

Commit

Permalink
Make create_installer_archive.py work a bit better on non-Win hosts.
Browse files Browse the repository at this point in the history
- copy api-ms-* files with r bit set so that the installer script
  can read them when it tries to copy them
- convert \ to / when reading chrome/installer/mini_installer/chrome.release
- use 7za instead of 7za.exe (and assume it's already installed)

Also don't create the same directory twice in MakeStagingDirectories(), see
https://codereview.chromium.org/8615002/diff/3005/chrome/tools/build/win/create_installer_archive.py#newcode154
(this is unrelated to the cross-build).

Still doesn't work in cross-builds because of (at least) makecab.exe,
and I don't have a good idea on how to tackle that yet, but this seems
like a good intermediate step.

Bug: 762073
Change-Id: I297ea0c87afe6a67246c018e188ac4edf4a3b865
Reviewed-on: https://chromium-review.googlesource.com/650839
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#499794}
  • Loading branch information
nico authored and Commit Bot committed Sep 5, 2017
1 parent ebaa668 commit c6faad1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
10 changes: 6 additions & 4 deletions build/vs_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ def _CopyRuntimeImpl(target, source, verbose=True):
if verbose:
print 'Copying %s to %s...' % (source, target)
if os.path.exists(target):
# Make the file writable so that we can delete it now.
os.chmod(target, stat.S_IWRITE)
# Make the file writable so that we can delete it now, and keep it
# readable.
os.chmod(target, stat.S_IWRITE | stat.S_IREAD)
os.unlink(target)
shutil.copy2(source, target)
# Make the file writable so that we can overwrite or delete it later.
os.chmod(target, stat.S_IWRITE)
# Make the file writable so that we can overwrite or delete it later,
# keep it readable.
os.chmod(target, stat.S_IWRITE | stat.S_IREAD)


def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, dll_pattern, suffix):
Expand Down
21 changes: 10 additions & 11 deletions chrome/tools/build/win/create_installer_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def CopySectionFilesToStagingDir(config, section, staging_dir, src_dir):
continue

dst_dir = os.path.join(staging_dir, config.get(section, option))
dst_dir = dst_dir.replace('\\', os.sep)
src_paths = glob.glob(os.path.join(src_dir, option))
if src_paths and not os.path.exists(dst_dir):
os.makedirs(dst_dir)
Expand All @@ -139,8 +140,11 @@ def GenerateDiffPatch(options, orig_file, new_file, patch_file):
RunSystemCommand(cmd, options.verbose)

def GetLZMAExec(build_dir):
lzma_exec = os.path.join(build_dir, "..", "..", "third_party",
"lzma_sdk", "Executable", "7za.exe")
if sys.platform == 'win32':
lzma_exec = os.path.join(build_dir, "..", "..", "third_party",
"lzma_sdk", "Executable", "7za.exe")
else:
lzma_exec = '7za' # Use system 7za.
return lzma_exec

def GetPrevVersion(build_dir, temp_dir, last_chrome_installer, output_name):
Expand All @@ -159,20 +163,15 @@ def GetPrevVersion(build_dir, temp_dir, last_chrome_installer, output_name):
dll_path = glob.glob(os.path.join(temp_dir, 'Chrome-bin', '*', 'chrome.dll'))
return os.path.split(os.path.split(dll_path[0])[0])[1]

def MakeStagingDirectories(staging_dir):
def MakeStagingDirectory(staging_dir):
"""Creates a staging path for installer archive. If directory exists already,
deletes the existing directory.
"""
file_path = os.path.join(staging_dir, TEMP_ARCHIVE_DIR)
if os.path.exists(file_path):
shutil.rmtree(file_path)
os.makedirs(file_path)

temp_file_path = os.path.join(staging_dir, TEMP_ARCHIVE_DIR)
if os.path.exists(temp_file_path):
shutil.rmtree(temp_file_path)
os.makedirs(temp_file_path)
return (file_path, temp_file_path)
return file_path

def Readconfig(input_file, current_version):
"""Reads config information from input file after setting default value of
Expand Down Expand Up @@ -532,9 +531,9 @@ def main(options):

config = Readconfig(options.input_file, current_version)

(staging_dir, temp_dir) = MakeStagingDirectories(options.staging_dir)
staging_dir = MakeStagingDirectory(options.staging_dir)

prev_version = GetPrevVersion(options.build_dir, temp_dir,
prev_version = GetPrevVersion(options.build_dir, staging_dir,
options.last_chrome_installer,
options.output_name)

Expand Down

0 comments on commit c6faad1

Please sign in to comment.