Commit 86dea68f authored by Joshua Pawlicki's avatar Joshua Pawlicki Committed by Commit Bot

Refactor chrome/installer/mac/signing in preparation for updater reuse.

The main thing here is to move get_parts into the parts.py.

Bug: 926234
Change-Id: Icf7d9129281ef45438d1dfa27c992c011d0306bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2016972
Auto-Submit: Joshua Pawlicki <waffles@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737374}
parent 3316bcc5
...@@ -113,6 +113,7 @@ group("mac_signing_tests") { ...@@ -113,6 +113,7 @@ group("mac_signing_tests") {
"signing/model_test.py", "signing/model_test.py",
"signing/modification_test.py", "signing/modification_test.py",
"signing/notarize_test.py", "signing/notarize_test.py",
"signing/parts_test.py",
"signing/pipeline_test.py", "signing/pipeline_test.py",
"signing/run_mac_signing_tests.py", "signing/run_mac_signing_tests.py",
"signing/signing_test.py", "signing/signing_test.py",
......
...@@ -10,6 +10,7 @@ mac_signing_sources = [ ...@@ -10,6 +10,7 @@ mac_signing_sources = [
"signing/model.py", "signing/model.py",
"signing/modification.py", "signing/modification.py",
"signing/notarize.py", "signing/notarize.py",
"signing/parts.py",
"signing/pipeline.py", "signing/pipeline.py",
"signing/signing.py", "signing/signing.py",
] ]
...@@ -10,7 +10,7 @@ be modified or renamed to support side-by-side channel installs. ...@@ -10,7 +10,7 @@ be modified or renamed to support side-by-side channel installs.
import os.path import os.path
from . import commands, signing from . import commands, parts
_CF_BUNDLE_EXE = 'CFBundleExecutable' _CF_BUNDLE_EXE = 'CFBundleExecutable'
_CF_BUNDLE_ID = 'CFBundleIdentifier' _CF_BUNDLE_ID = 'CFBundleIdentifier'
...@@ -145,7 +145,7 @@ def _process_entitlements(paths, dist, config): ...@@ -145,7 +145,7 @@ def _process_entitlements(paths, dist, config):
entitlements_names = [ entitlements_names = [
part.entitlements part.entitlements
for part in signing.get_parts(config).values() for part in parts.get_parts(config).values()
if part.entitlements if part.entitlements
] ]
for entitlements_name in entitlements_names: for entitlements_name in entitlements_names:
......
This diff is collapsed.
This diff is collapsed.
...@@ -11,7 +11,7 @@ The pipeline module orchestrates the entire signing process, which includes: ...@@ -11,7 +11,7 @@ The pipeline module orchestrates the entire signing process, which includes:
import os.path import os.path
from . import commands, model, modification, notarize, signing from . import commands, model, modification, notarize, parts, signing
def _customize_and_sign_chrome(paths, dist_config, dest_dir, signed_frameworks): def _customize_and_sign_chrome(paths, dist_config, dest_dir, signed_frameworks):
...@@ -74,13 +74,13 @@ def _customize_and_sign_chrome(paths, dist_config, dest_dir, signed_frameworks): ...@@ -74,13 +74,13 @@ def _customize_and_sign_chrome(paths, dist_config, dest_dir, signed_frameworks):
actual_framework_change_count, actual_framework_change_count,
signed_framework_change_count)) signed_framework_change_count))
signing.sign_chrome(paths, dist_config, sign_framework=False) parts.sign_chrome(paths, dist_config, sign_framework=False)
else: else:
unsigned_framework_path = os.path.join(paths.work, unsigned_framework_path = os.path.join(paths.work,
'modified_unsigned_framework') 'modified_unsigned_framework')
commands.copy_dir_overwrite_and_count_changes( commands.copy_dir_overwrite_and_count_changes(
work_dir_framework_path, unsigned_framework_path, dry_run=False) work_dir_framework_path, unsigned_framework_path, dry_run=False)
signing.sign_chrome(paths, dist_config, sign_framework=True) parts.sign_chrome(paths, dist_config, sign_framework=True)
actual_framework_change_count = commands.copy_dir_overwrite_and_count_changes( actual_framework_change_count = commands.copy_dir_overwrite_and_count_changes(
work_dir_framework_path, unsigned_framework_path, dry_run=True) work_dir_framework_path, unsigned_framework_path, dry_run=True)
if signed_frameworks is not None: if signed_frameworks is not None:
...@@ -101,11 +101,10 @@ def _staple_chrome(paths, dist_config): ...@@ -101,11 +101,10 @@ def _staple_chrome(paths, dist_config):
paths: A |model.Paths| object. paths: A |model.Paths| object.
dist_config: A |config.CodeSignConfig| for the customized product. dist_config: A |config.CodeSignConfig| for the customized product.
""" """
parts = signing.get_parts(dist_config)
# Only staple the signed, bundled executables. # Only staple the signed, bundled executables.
part_paths = [ part_paths = [
part.path part.path
for part in parts.values() for part in parts.get_parts(dist_config).values()
# TODO(https://crbug.com/979725): Reinstate .xpc bundle stapling once # TODO(https://crbug.com/979725): Reinstate .xpc bundle stapling once
# the signing environment is on a macOS release that supports # the signing environment is on a macOS release that supports
# Xcode 10.2 or newer. # Xcode 10.2 or newer.
...@@ -382,7 +381,7 @@ def _package_installer_tools(paths, config): ...@@ -382,7 +381,7 @@ def _package_installer_tools(paths, config):
""" """
DIFF_TOOLS = 'diff_tools' DIFF_TOOLS = 'diff_tools'
tools_to_sign = signing.get_installer_tools(config) tools_to_sign = parts.get_installer_tools(config)
chrome_tools = ( chrome_tools = (
'keystone_install.sh',) if config.is_chrome_branded() else () 'keystone_install.sh',) if config.is_chrome_branded() else ()
other_tools = ( other_tools = (
...@@ -430,7 +429,7 @@ def _intermediate_work_dir_name(dist_config): ...@@ -430,7 +429,7 @@ def _intermediate_work_dir_name(dist_config):
return dist_config.packaging_basename return dist_config.packaging_basename
def sign_all(orig_paths, def sign_chrome(orig_paths,
config, config,
disable_packaging=False, disable_packaging=False,
do_notarization=True, do_notarization=True,
......
...@@ -55,9 +55,9 @@ def _get_adjacent_item(l, o): ...@@ -55,9 +55,9 @@ def _get_adjacent_item(l, o):
'copy_dir_overwrite_and_count_changes', 'run_command', 'copy_dir_overwrite_and_count_changes', 'run_command',
'make_dir', 'shutil', 'write_file', 'set_executable') 'make_dir', 'shutil', 'write_file', 'set_executable')
}) })
@mock.patch.multiple( @mock.patch.multiple('signing.signing',
'signing.signing', **{m: mock.DEFAULT for m in ('sign_part', 'verify_part')})
**{m: mock.DEFAULT for m in ('sign_part', 'sign_chrome', 'verify_part')}) @mock.patch.multiple('signing.parts', **{'sign_chrome': mock.DEFAULT})
@mock.patch('signing.commands.tempfile.mkdtemp', _get_work_dir) @mock.patch('signing.commands.tempfile.mkdtemp', _get_work_dir)
class TestPipelineHelpers(unittest.TestCase): class TestPipelineHelpers(unittest.TestCase):
...@@ -203,8 +203,7 @@ class TestPipelineHelpers(unittest.TestCase): ...@@ -203,8 +203,7 @@ class TestPipelineHelpers(unittest.TestCase):
'$W/App Product Canary.app/Contents/Frameworks/Product Framework.framework', '$W/App Product Canary.app/Contents/Frameworks/Product Framework.framework',
'$W/modified_unsigned_framework', '$W/modified_unsigned_framework',
dry_run=False), dry_run=False),
mock.call.sign_chrome( mock.call.sign_chrome(paths, channel_dist_config, sign_framework=True),
paths, channel_dist_config, sign_framework=True),
mock.call.copy_dir_overwrite_and_count_changes( mock.call.copy_dir_overwrite_and_count_changes(
'$W/App Product Canary.app/Contents/Frameworks/Product Framework.framework', '$W/App Product Canary.app/Contents/Frameworks/Product Framework.framework',
'$W/modified_unsigned_framework', '$W/modified_unsigned_framework',
...@@ -716,7 +715,7 @@ class TestSignAll(unittest.TestCase): ...@@ -716,7 +715,7 @@ class TestSignAll(unittest.TestCase):
] ]
config = Config() config = Config()
pipeline.sign_all(self.paths, config) pipeline.sign_chrome(self.paths, config)
self.assertEqual(1, kwargs['_package_installer_tools'].call_count) self.assertEqual(1, kwargs['_package_installer_tools'].call_count)
...@@ -779,7 +778,7 @@ class TestSignAll(unittest.TestCase): ...@@ -779,7 +778,7 @@ class TestSignAll(unittest.TestCase):
] ]
config = Config() config = Config()
pipeline.sign_all(self.paths, config) pipeline.sign_chrome(self.paths, config)
self.assertEqual(1, kwargs['_package_installer_tools'].call_count) self.assertEqual(1, kwargs['_package_installer_tools'].call_count)
...@@ -845,7 +844,7 @@ class TestSignAll(unittest.TestCase): ...@@ -845,7 +844,7 @@ class TestSignAll(unittest.TestCase):
] ]
config = Config() config = Config()
pipeline.sign_all(self.paths, config) pipeline.sign_chrome(self.paths, config)
self.assertEqual(1, kwargs['_package_installer_tools'].call_count) self.assertEqual(1, kwargs['_package_installer_tools'].call_count)
...@@ -900,7 +899,7 @@ class TestSignAll(unittest.TestCase): ...@@ -900,7 +899,7 @@ class TestSignAll(unittest.TestCase):
kwargs['wait_for_results'].return_value = iter([app_uuid]) kwargs['wait_for_results'].return_value = iter([app_uuid])
config = test_config.TestConfig() config = test_config.TestConfig()
pipeline.sign_all(self.paths, config, disable_packaging=True) pipeline.sign_chrome(self.paths, config, disable_packaging=True)
manager.assert_has_calls([ manager.assert_has_calls([
# First customize the distribution and sign it. # First customize the distribution and sign it.
...@@ -936,7 +935,7 @@ class TestSignAll(unittest.TestCase): ...@@ -936,7 +935,7 @@ class TestSignAll(unittest.TestCase):
manager.attach_mock(kwargs[attr], attr) manager.attach_mock(kwargs[attr], attr)
config = test_config.TestConfig() config = test_config.TestConfig()
pipeline.sign_all(self.paths, config, do_notarization=False) pipeline.sign_chrome(self.paths, config, do_notarization=False)
self.assertEqual(1, kwargs['_package_installer_tools'].call_count) self.assertEqual(1, kwargs['_package_installer_tools'].call_count)
...@@ -960,7 +959,7 @@ class TestSignAll(unittest.TestCase): ...@@ -960,7 +959,7 @@ class TestSignAll(unittest.TestCase):
manager.attach_mock(kwargs[attr], attr) manager.attach_mock(kwargs[attr], attr)
config = test_config.TestConfig() config = test_config.TestConfig()
pipeline.sign_all( pipeline.sign_chrome(
self.paths, config, disable_packaging=True, do_notarization=False) self.paths, config, disable_packaging=True, do_notarization=False)
manager.assert_has_calls([ manager.assert_has_calls([
...@@ -1006,7 +1005,7 @@ class TestSignAll(unittest.TestCase): ...@@ -1006,7 +1005,7 @@ class TestSignAll(unittest.TestCase):
] ]
config = Config() config = Config()
pipeline.sign_all(self.paths, config, do_notarization=False) pipeline.sign_chrome(self.paths, config, do_notarization=False)
self.assertEqual(1, kwargs['_package_installer_tools'].call_count) self.assertEqual(1, kwargs['_package_installer_tools'].call_count)
self.assertEqual(4, kwargs['_customize_and_sign_chrome'].call_count) self.assertEqual(4, kwargs['_customize_and_sign_chrome'].call_count)
......
This diff is collapsed.
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