[cr140] Fix stub_out_signing_in_upstream to address signing failure on Mac

Signing with `--skip_signing` stopped working on Mac due to the following
upstream commit. This happened because we override the behavior of `run_command`
to scrub signing-related commands/arguments from the command-line when
`--skip_signing` is passed. However, this upstream commit added a new async
function named `run_command_all_output_async` which also needs to be scrubbed.

Chromium change:
https://source.chromium.org/chromium/chromium/src/+/8062ee35c902563309983726a37b90d5ca10caed

commit 8062ee35c902563309983726a37b90d5ca10caed
Author: Joshua Pawlicki <waffles@chromium.org>
Date:   Tue Jul 15 10:45:21 2025 -0700

    mac signing: Parallelize some per-distribution operations.

    This may speed up the per-distribution section of signing by up to 45%.

    codesign --verify and spctl --assess will now run in parallel. This is
    expected to provide a speed-up up to 20% depending on I/O throughput.

    The app bundle needs to be zipped prior to notarization. Previously,
    the execution would wait for zipping to be complete and then start
    notarization in the background (while continuing in parallel with
    processing the next distribution). Now, the zipping is also done in
    the background while execution moves on to the next distribution. This
    could provide a speed-up of up to 25% depending on I/O vs CPU
    bottlenecks.

    Bug: 426019706
    Change-Id: I0a054c43c2b51f56abd0a94e78a9caf337a2a216
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6699494
    Commit-Queue: Mark Mentovai <mark@chromium.org>
    Reviewed-by: Mark Mentovai <mark@chromium.org>
    Commit-Queue: Joshua Pawlicki <waffles@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1487061}
This commit is contained in:
Emerick Rogul
2025-08-19 19:54:27 +01:00
committed by Claudio DeSouza
parent 48a5eebcb5
commit 5145be6b18
+19 -6
View File
@@ -31,21 +31,34 @@ class Invoker(standard_invoker.Invoker):
def stub_out_signing_in_upstream():
run_command_orig = commands.run_command
run_command_all_output_async_orig = commands.run_command_all_output_async
def run_command(args, **kwargs):
def scrub_signing_args(args):
if args[0] == 'codesign':
# Even non-signing commands such as `codesign --verify` or
# `codesign --display` fail when signing is skipped. So don't invoke
# codesign at all:
return
return None # Indicates the command should not be run
if args[0] == 'productbuild':
try:
sign_index = args.index('--sign')
# Remove '--sign' and the following argument
del args[sign_index:sign_index + 2]
except ValueError:
pass
else:
for _ in range(2):
args.pop(sign_index)
run_command_orig(args, **kwargs)
return args
def run_command(args, **kwargs):
scrubbed = scrub_signing_args(args.copy())
if scrubbed is not None:
return run_command_orig(scrubbed, **kwargs)
return None
async def run_command_all_output_async(args, **kwargs):
scrubbed = scrub_signing_args(args.copy())
if scrubbed is not None:
return await run_command_all_output_async_orig(scrubbed, **kwargs)
return ('%s' % args, 0, '', '')
commands.run_command = run_command
commands.run_command_all_output_async = run_command_all_output_async