Commit 458476e8 authored by Joshua Pawlicki's avatar Joshua Pawlicki Committed by Chromium LUCI CQ

Mac signing: Add support for inflated distributions.

Inflated distributions are useful for running A/B tests to understand
the impact of shipping larger binaries.

Bug: 1154844
Change-Id: Ifdfeeb200b58174e5c3e7f346ecf013780111d25
Fixed: 1154844
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2625888
Commit-Queue: Joshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844117}
parent e3c8bfeb
......@@ -178,7 +178,8 @@ class Distribution(object):
creator_code=None,
channel_customize=False,
package_as_dmg=True,
package_as_pkg=False):
package_as_pkg=False,
inflation_kilobytes=0):
"""Creates a new Distribution object. All arguments are optional.
Args:
......@@ -208,6 +209,8 @@ class Distribution(object):
the product.
package_as_pkg: If True, then a .pkg file will be created containing
the product.
inflation_kilobytes: If non-zero, a blob of this size will be
inserted into the DMG. Incompatible with package_as_pkg = True.
"""
if channel_customize:
# Side-by-side channels must have a distinct names and creator
......@@ -226,6 +229,10 @@ class Distribution(object):
self.channel_customize = channel_customize
self.package_as_dmg = package_as_dmg
self.package_as_pkg = package_as_pkg
self.inflation_kilobytes = inflation_kilobytes
# inflation_kilobytes are only inserted into DMGs
assert not self.inflation_kilobytes or self.package_as_dmg
def brandless_copy(self):
"""Derives and returns a copy of this Distribution object, identical
......
......@@ -413,6 +413,12 @@ def _package_dmg(paths, dist, config):
]
# yapf: enable
if dist.inflation_kilobytes:
pkg_dmg += [
'--copy',
'{}/inflation.bin:/.background/inflation.bin'.format(packaging_dir)
]
if config.is_chrome_branded():
# yapf: disable
pkg_dmg += [
......@@ -506,6 +512,8 @@ def _intermediate_work_dir_name(dist):
customizations.append(dist.creator_code)
if dist.branding_code and _include_branding_code_in_app(dist):
customizations.append(dist.branding_code)
if dist.inflation_kilobytes:
customizations.append(str(dist.inflation_kilobytes))
return '-'.join(customizations)
......@@ -607,6 +615,14 @@ def sign_all(orig_paths,
notary_paths.work,
_intermediate_work_dir_name(dist_config.distribution)))
if dist.inflation_kilobytes:
inflation_path = os.path.join(
paths.packaging_dir(config), 'inflation.bin')
commands.run_command([
'dd', 'if=/dev/urandom', 'of=' + inflation_path,
'bs=1000', 'count={}'.format(dist.inflation_kilobytes)
])
if dist.package_as_dmg:
dmg_path = _package_and_sign_dmg(paths, dist_config)
......
......@@ -823,6 +823,72 @@ class TestSignAll(unittest.TestCase):
mock.call._package_installer_tools(mock.ANY, mock.ANY),
])
def test_sign_inflated_distribution_dmg(self, **kwargs):
manager = mock.Mock()
for attr in kwargs:
manager.attach_mock(kwargs[attr], attr)
app_uuid = 'f38ee49c-c55b-4a10-a4f5-aaaa17636b76'
dmg_uuid = '9f49067e-a13d-436a-8016-3a22a4f6ef92'
kwargs['submit'].side_effect = [app_uuid, dmg_uuid]
kwargs['wait_for_results'].side_effect = [
iter([app_uuid]), iter([dmg_uuid])
]
kwargs[
'_package_and_sign_dmg'].return_value = '/$O/AppProduct-99.0.9999.99.dmg'
class Config(test_config.TestConfig):
@property
def distributions(self):
return [
model.Distribution(
inflation_kilobytes=5000,
package_as_dmg=True,
package_as_pkg=False),
]
config = Config()
pipeline.sign_all(self.paths, config)
self.assertEqual(1, kwargs['_package_installer_tools'].call_count)
manager.assert_has_calls([
# First customize the distribution and sign it.
mock.call._customize_and_sign_chrome(mock.ANY, mock.ANY,
'/$W_1/stable-5000', mock.ANY),
# Prepare the app for notarization.
mock.call.run_command([
'zip', '--recurse-paths', '--symlinks', '--quiet',
'/$W_1/AppProduct-99.0.9999.99.zip', 'App Product.app'
],
cwd='/$W_1/stable-5000'),
mock.call.submit('/$W_1/AppProduct-99.0.9999.99.zip', mock.ANY),
mock.call.shutil.rmtree('/$W_2'),
mock.call.wait_for_results({app_uuid: None}.keys(), mock.ANY),
mock.call._staple_chrome(
self.paths.replace_work('/$W_1/stable-5000'), mock.ANY),
mock.call.run_command([
'dd', 'if=/dev/urandom',
'of=/$I/Product Packaging/inflation.bin', 'bs=1000',
'count=5000'
]),
# Make the DMG.
mock.call._package_and_sign_dmg(mock.ANY, mock.ANY),
# Notarize the DMG.
mock.call.submit('/$O/AppProduct-99.0.9999.99.dmg', mock.ANY),
mock.call.wait_for_results({dmg_uuid: None}.keys(), mock.ANY),
mock.call.staple('/$O/AppProduct-99.0.9999.99.dmg'),
mock.call.shutil.rmtree('/$W_1'),
# Package the installer tools.
mock.call._package_installer_tools(mock.ANY, mock.ANY),
])
def test_sign_basic_distribution_pkg(self, **kwargs):
manager = mock.Mock()
for attr in kwargs:
......
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