From a0183aad2a1526656ff2e74dd7105043dd980f3f Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Thu, 17 Jul 2025 13:11:42 +0200 Subject: [PATCH] Change BraveUpdater.app path in local checkout (#29986) --- DEPS | 3 ++- build/download_dep.py | 3 ++- patches/chrome-BUILD.gn.patch | 2 +- script/brave_license_helper.py | 1 + script/deps.py | 3 +-- script/lib/util.py | 15 ++++++++++++--- third_party/updater/.gitignore | 6 ++++++ 7 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 third_party/updater/.gitignore diff --git a/DEPS b/DEPS index e68bc0d854e..2558978bf5c 100644 --- a/DEPS +++ b/DEPS @@ -91,7 +91,8 @@ hooks = [ 'condition': 'checkout_mac', 'action': ['vpython3', 'build/download_dep.py', 'omaha4/BraveUpdater-136.1.79.71.zip', - '//third_party/updater/chrome_mac_universal_prod/cipd'], + '//brave/third_party/updater/mac', + 'BraveUpdater.app/'], }, { 'name': 'update_pip', diff --git a/build/download_dep.py b/build/download_dep.py index f5a71ccb7e8..22d49447ca4 100644 --- a/build/download_dep.py +++ b/build/download_dep.py @@ -18,7 +18,7 @@ def main(): dep_url = DEPS_PACKAGES_URL + '/' + args.dep_path dest_dir = wspath(args.dest_dir) if dep_url != get_url(dest_dir): - deps.DownloadAndUnpack(dep_url, dest_dir) + deps.DownloadAndUnpack(dep_url, dest_dir, args.path_prefix) set_url(dest_dir, dep_url) @@ -26,6 +26,7 @@ def parse_args(): parser = ArgumentParser(description='Download and extract an archive.') parser.add_argument('dep_path') parser.add_argument('dest_dir') + parser.add_argument('path_prefix', nargs='?', default=None) return parser.parse_args() diff --git a/patches/chrome-BUILD.gn.patch b/patches/chrome-BUILD.gn.patch index 5ae9e861ada..0aed6208aa5 100644 --- a/patches/chrome-BUILD.gn.patch +++ b/patches/chrome-BUILD.gn.patch @@ -64,7 +64,7 @@ index e294991e31dd65cb03c8e20dba5f6fa857b9ffc7..7b26b071663f605805d59de2c7b4cbb5 if (enable_updater) { if (is_chrome_branded) { sources += [ "//third_party/updater/chrome_mac_universal_prod/cipd/${updater_product_full_name}.app" ] -+ } else if (!enable_omaha4) {} else if (use_prebuilt_omaha4) { sources += ["//third_party/updater/chrome_mac_universal_prod/cipd/${updater_product_full_name}.app"] ++ } else if (!enable_omaha4) {} else if (use_prebuilt_omaha4) { sources += ["//brave/third_party/updater/mac/${updater_product_full_name}.app"] } else { sources += [ "$root_out_dir/${updater_product_full_name}.app" ] diff --git a/script/brave_license_helper.py b/script/brave_license_helper.py index cd4f1a0ef25..f0940f5d426 100644 --- a/script/brave_license_helper.py +++ b/script/brave_license_helper.py @@ -144,6 +144,7 @@ def AddBraveCredits(root, prune_paths, special_cases, prune_dirs, # Dependencies that are already in brave-core, and whose notices # therefore do not need to be repeated. + os.path.join('brave', 'third_party', 'updater'), os.path.join('brave', 'vendor', 'omaha', 'omaha', 'third_party', 'chrome'), os.path.join('brave', 'vendor', 'omaha', 'third_party', 'libzip'), diff --git a/script/deps.py b/script/deps.py index fddad999aa0..412d9a42950 100755 --- a/script/deps.py +++ b/script/deps.py @@ -85,8 +85,7 @@ def DownloadAndUnpack(url, output_dir, path_prefix=None): shutil.rmtree(output_dir, ignore_errors=True) EnsureDirExists(output_dir) if url.endswith('.zip'): - assert path_prefix is None - extract_zip(tmp_file.name, output_dir) + extract_zip(tmp_file.name, output_dir, path_prefix) else: with tarfile.open(tmp_file.name, mode='r:*') as t: members = None diff --git a/script/lib/util.py b/script/lib/util.py index ccc67e1875d..d9703df0b19 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -107,13 +107,22 @@ def get_lzma_exec(): return lzma_exec -def extract_zip(zip_path, destination): +def extract_zip(zip_path, destination, path_prefix=None): if sys.platform in ('darwin', 'linux'): # Use the unzip command to properly handle symbolic links. - execute(['unzip', zip_path, '-d', destination]) + args = ['unzip', zip_path] + if path_prefix: + args.append(path_prefix + '*') + args.extend(['-d', destination]) + execute(args) else: with zipfile.ZipFile(zip_path) as z: - z.extractall(destination) + members = None + if path_prefix is not None: + members = [ + m for m in z.namelist() if m.startswith(path_prefix) + ] + z.extractall(destination, members=members) def make_zip(zip_file_path, files, dirs): diff --git a/third_party/updater/.gitignore b/third_party/updater/.gitignore new file mode 100644 index 00000000000..61a0b8bc188 --- /dev/null +++ b/third_party/updater/.gitignore @@ -0,0 +1,6 @@ +# It would be nice to have file mac/.gitignore with entries `BraveUpdater.app/` +# and `.url`. But the `DownloadAndUnpack` function we are using deletes the +# destination directory, `mac/`, and thus also `mac/.gitignore`. We therefore +# maintain the .gitignore entries here: +mac/BraveUpdater.app/ +mac/.url