1- From b6d0c246ec55919274446bcb7701a17eb5c4af7c Mon Sep 17 00:00:00 2001
1+ From 7a0c840a1732f84b1e1805fc7998a12fddca1af6 Mon Sep 17 00:00:00 2001
22From: Hibiki Tachibana <57486057+Hibbiki@users.noreply.github.com>
33Date: Wed, 12 Jun 2024 02:14:41 +0200
44Subject: [PATCH 2/4] Patch updater to work with unsigned and unbranded builds
55
66Signed-off-by: Hibiki Tachibana <57486057+Hibbiki@users.noreply.github.com>
77---
8- .../install_static/chromium_install_modes.h | 3 +--
8+ .../install_static/chromium_install_modes.h | 3 +-
99 chrome/updater/BUILD.gn | 1 +
10- chrome/updater/win/installer/installer.cc | 15 +++++++++++++
11- chrome/updater/win/signing/sign.py | 21 ++ -----------------
12- 4 files changed, 19 insertions(+), 21 deletions(-)
10+ chrome/updater/win/installer/installer.cc | 15 +++++++
11+ chrome/updater/win/signing/sign.py | 42 +- -----------------
12+ 4 files changed, 19 insertions(+), 42 deletions(-)
1313
1414diff --git a/chrome/install_static/chromium_install_modes.h b/chrome/install_static/chromium_install_modes.h
15- index 7de32cf745755..9bbb8ecadd23a 100644
15+ index 0cf937413e08a..e2b57a664660f 100644
1616--- a/chrome/install_static/chromium_install_modes.h
1717+++ b/chrome/install_static/chromium_install_modes.h
1818@@ -32,8 +32,7 @@ inline constexpr auto kInstallModes = std::to_array<InstallConstants>({
@@ -26,10 +26,10 @@ index 7de32cf745755..9bbb8ecadd23a 100644
2626 .base_app_id = L"Chromium", // A distinct base_app_id.
2727 .browser_prog_id_prefix = L"ChromiumHTM", // Browser ProgID prefix.
2828diff --git a/chrome/updater/BUILD.gn b/chrome/updater/BUILD.gn
29- index 58400305cb10a..b2fa2db65c701 100644
29+ index ae9d83075d2eb..64efb84497a14 100644
3030--- a/chrome/updater/BUILD.gn
3131+++ b/chrome/updater/BUILD.gn
32- @@ -358 ,6 +358 ,7 @@ if (is_win || is_mac || is_linux) {
32+ @@ -377 ,6 +377 ,7 @@ if (is_win || is_mac || is_linux) {
3333 "//chrome/installer/util:constants",
3434 "//chrome/installer/util:metainstaller_utils",
3535 "//chrome/installer/util:work_item",
@@ -38,7 +38,7 @@ index 58400305cb10a..b2fa2db65c701 100644
3838 "//chrome/updater/app/server/win:updater_idl_system",
3939 "//chrome/updater/app/server/win:updater_idl_user",
4040diff --git a/chrome/updater/win/installer/installer.cc b/chrome/updater/win/installer/installer.cc
41- index 2444634092235..71f13cfa910f5 100644
41+ index 543e55df64519..bd732c5103745 100644
4242--- a/chrome/updater/win/installer/installer.cc
4343+++ b/chrome/updater/win/installer/installer.cc
4444@@ -11,6 +11,11 @@
@@ -90,24 +90,24 @@ index 2444634092235..71f13cfa910f5 100644
9090
9191 // Shows a splash screen "Initializing...".
9292diff --git a/chrome/updater/win/signing/sign.py b/chrome/updater/win/signing/sign.py
93- index d22b29c4875fc..6f7a0bbfc616e 100755
93+ index 42becb59dd93c..8304169764b80 100755
9494--- a/chrome/updater/win/signing/sign.py
9595+++ b/chrome/updater/win/signing/sign.py
96- @@ -117,28 +117 ,11 @@ class Signer:
96+ @@ -124,49 +124 ,11 @@ class Signer:
9797 self._sign_flags = sign_flags
9898
9999 def _add_tagging_cert(self, in_file, out_file):
100100- """Adds the tagging cert. Returns the path to the tagged file."""
101101- subprocess.run(
102102- [self._tagging_exe, '--set-tag',
103103- '--out=%s' % out_file, in_file],
104- - check=True)
104+ - check=True,
105+ - stdout=subprocess.DEVNULL)
105106+ shutil.copy(in_file, out_file)
106107 return out_file
107108
108109 def _sign_item(self, in_file):
109110- """Sign an executable in-place."""
110- - # Retries may be required: lore states the timestamp server is flaky.
111111- for flags in self._sign_flags:
112112- command = [self._signtool_exe, 'sign']
113113- command += flags
@@ -119,7 +119,28 @@ index d22b29c4875fc..6f7a0bbfc616e 100755
119119- command += ['/s', 'My', '/n', self._identity]
120120-
121121- command += [in_file]
122- - subprocess.run(command, check=True)
122+ -
123+ - # Timestamp server is flaky, retry sign if timestamp server is used
124+ - attempts = 10 if ({'/tr', '/tseal'} & set(command)) else 1
125+ - delay = 1
126+ - for attempt in range(1, attempts + 1):
127+ - try:
128+ - subprocess.run(command,
129+ - check=True,
130+ - stdout=subprocess.DEVNULL)
131+ - except subprocess.CalledProcessError:
132+ - if attempt == attempts:
133+ - raise
134+ - logging.exception(
135+ - 'Sign attempt failed, attempts left: %d',
136+ - attempts - attempt
137+ - )
138+ - logging.info(
139+ - 'Waiting for %d seconds before next attempt...', delay
140+ - )
141+ - time.sleep(delay)
142+ - continue
143+ - break
123144+ return
124145
125146 def _generate_target_manifest(self, appid, installer_path, manifest_path,
0 commit comments