chrome/installer/mac/signing/pipeline.py
def _package_and_sign_pkg(paths, dist_config):
    """Packages, signs, and verifies a PKG for a signed build product.

    Args:
        paths: A |model.Paths| object.
        dist_config: The |config.CodeSignConfig| object.

    Returns:
        The path to the signed PKG file.
    """
    assert dist_config.installer_identity

    # Because several .pkg distributions might be built from the same underlying
    # .app, separate the .pkg construction into its own work directory.
    with commands.WorkDirectory(paths) as pkg_paths:
        # There are two .pkg files to be built:
        #   1. The inner component package (which is the one that can contain
        #      things like postinstall scripts). This is built with `pkgbuild`.
        #   2. The outer distribution package (which is the installable thing
        #      that has pre-install requirements). This is built with
        #      `productbuild`.

        ## The component package.

        # Because the component package is built using the --root option, copy
        # the .app into a directory by itself, as `pkgbuild` archives the entire
        # directory specified as the root directory.
        root_directory = os.path.join(pkg_paths.work, 'payload')
        commands.make_dir(root_directory)
        app_path = os.path.join(paths.work, dist_config.app_dir)
        new_app_path = os.path.join(root_directory, dist_config.app_dir)
        commands.copy_files(app_path, root_directory)

        # The spaces are removed from |dist_config.app_product| for the
        # component package path due to a bug in Installer.app that causes the
        # "Show Files" window to be blank if there is a space in a component
        # package name. https://stackoverflow.com/questions/43031272/
        component_pkg_name = '{}.pkg'.format(dist_config.app_product).replace(
            ' ', '')
        component_pkg_path = os.path.join(pkg_paths.work, component_pkg_name)
        component_property_path = _component_property_path(
            pkg_paths, dist_config)
        scripts_path = _create_pkgbuild_scripts(pkg_paths, dist_config)

        command = [
            'pkgbuild', '--root', root_directory, '--component-plist',
            component_property_path, '--identifier', dist_config.base_bundle_id,
            '--version', dist_config.version, '--install-location',
            '/Applications', '--scripts', scripts_path
        ]
        # The pkgbuild command on macOS 12 Monterey gained the ability to
        # compress component packages based on the minimum OS requirement for
        # their contents. If running under at least macOS 12, take advantage of
        # this.
        if commands.macos_version() >= [12, 0]:
            command.append('--compression')
            command.append('latest')
            command.append('--min-os-version')
            command.append(_minimum_os_version(paths, dist_config))
        command.append(component_pkg_path)
        commands.run_command(command)

        ## The distribution package.

        distribution_path = _productbuild_distribution_path(
            paths, pkg_paths, dist_config, component_pkg_path)

        product_pkg_path = os.path.join(
            pkg_paths.output, '{}.pkg'.format(dist_config.packaging_basename))

        command = [
            'productbuild', '--identifier', dist_config.base_bundle_id,
            '--version', dist_config.version, '--distribution',
            distribution_path, '--package-path', pkg_paths.work, '--sign',
            dist_config.installer_identity
        ]
        if dist_config.notary_user:
            # Assume if the config has notary authentication information that
            # the products will be notarized, which requires a secure
            # timestamp.
            command.append('--timestamp')
        command.append(product_pkg_path)
        commands.run_command(command)

        return product_pkg_path
Packages, signs, and verifies a PKG for a signed build product.

    Args:
        paths: A |model.Paths| object.
        dist_config: The |config.CodeSignConfig| object.

    Returns:
        The path to the signed PKG file.
    
Packages, signs, and verifies a PKG for a signed build product.
Packages signs and verifies a PKG for a signed build product .
def _package_and_sign_pkg(paths, dist_config):
    assert dist_config.installer_identity
    with commands.WorkDirectory(paths) as pkg_paths:
        root_directory = os.path.join(pkg_paths.work, 'payload')
        commands.make_dir(root_directory)
        app_path = os.path.join(paths.work, dist_config.app_dir)
        new_app_path = os.path.join(root_directory, dist_config.app_dir)
        commands.copy_files(app_path, root_directory)
        component_pkg_name = '{}.pkg'.format(dist_config.app_product).replace(
            ' ', '')
        component_pkg_path = os.path.join(pkg_paths.work, component_pkg_name)
        component_property_path = _component_property_path(
            pkg_paths, dist_config)
        scripts_path = _create_pkgbuild_scripts(pkg_paths, dist_config)
        command = [
            'pkgbuild', '--root', root_directory, '--component-plist',
            component_property_path, '--identifier', dist_config.base_bundle_id,
            '--version', dist_config.version, '--install-location',
            '/Applications', '--scripts', scripts_path
        ]
        if commands.macos_version() >= [12, 0]:
            command.append('--compression')
            command.append('latest')
            command.append('--min-os-version')
            command.append(_minimum_os_version(paths, dist_config))
        command.append(component_pkg_path)
        commands.run_command(command)
        distribution_path = _productbuild_distribution_path(
            paths, pkg_paths, dist_config, component_pkg_path)
        product_pkg_path = os.path.join(
            pkg_paths.output, '{}.pkg'.format(dist_config.packaging_basename))
        command = [
            'productbuild', '--identifier', dist_config.base_bundle_id,
            '--version', dist_config.version, '--distribution',
            distribution_path, '--package-path', pkg_paths.work, '--sign',
            dist_config.installer_identity
        ]
        if dist_config.notary_user:
            command.append('--timestamp')
        command.append(product_pkg_path)
        commands.run_command(command)
        return product_pkg_path
def _package_and_sign_pkg ( paths , dist_config ) : assert dist_config . installer_identity with commands . WorkDirectory ( paths ) as pkg_paths : root_directory = os . path . join ( pkg_paths . work , 'payload' ) commands . make_dir ( root_directory ) app_path = os . path . join ( paths . work , dist_config . app_dir ) new_app_path = os . path . join ( root_directory , dist_config . app_dir ) commands . copy_files ( app_path , root_directory ) component_pkg_name = '{}.pkg' . format ( dist_config . app_product ) . replace ( ' ' , '' ) component_pkg_path = os . path . join ( pkg_paths . work , component_pkg_name ) component_property_path = _component_property_path ( pkg_paths , dist_config ) scripts_path = _create_pkgbuild_scripts ( pkg_paths , dist_config ) command = [ 'pkgbuild' , '--root' , root_directory , '--component-plist' , component_property_path , '--identifier' , dist_config . base_bundle_id , '--version' , dist_config . version , '--install-location' , '/Applications' , '--scripts' , scripts_path ] if commands . macos_version ( ) >= [ 12 , 0 ] : command . append ( '--compression' ) command . append ( 'latest' ) command . append ( '--min-os-version' ) command . append ( _minimum_os_version ( paths , dist_config ) ) command . append ( component_pkg_path ) commands . run_command ( command ) distribution_path = _productbuild_distribution_path ( paths , pkg_paths , dist_config , component_pkg_path ) product_pkg_path = os . path . join ( pkg_paths . output , '{}.pkg' . format ( dist_config . packaging_basename ) ) command = [ 'productbuild' , '--identifier' , dist_config . base_bundle_id , '--version' , dist_config . version , '--distribution' , distribution_path , '--package-path' , pkg_paths . work , '--sign' , dist_config . installer_identity ] if dist_config . notary_user : command . append ( '--timestamp' ) command . append ( product_pkg_path ) commands . run_command ( command ) return product_pkg_path
Packages, signs, and verifies a PKG for a signed build product.
Packages signs and verifies a PKG for a signed build product .
"""Packages, signs, and verifies a PKG for a signed build product.

    Args:
        paths: A |model.Paths| object.
        dist_config: The |config.CodeSignConfig| object.

    Returns:
        The path to the signed PKG file.
    """ # Because several .pkg distributions might be built from the same underlying # .app, separate the .pkg construction into its own work directory. # There are two .pkg files to be built: #   1. The inner component package (which is the one that can contain #      things like postinstall scripts). This is built with `pkgbuild`. #   2. The outer distribution package (which is the installable thing #      that has pre-install requirements). This is built with #      `productbuild`. ## The component package. # Because the component package is built using the --root option, copy # the .app into a directory by itself, as `pkgbuild` archives the entire # directory specified as the root directory. # The spaces are removed from |dist_config.app_product| for the # component package path due to a bug in Installer.app that causes the # "Show Files" window to be blank if there is a space in a component # package name. https://stackoverflow.com/questions/43031272/ # The pkgbuild command on macOS 12 Monterey gained the ability to # compress component packages based on the minimum OS requirement for # their contents. If running under at least macOS 12, take advantage of # this. ## The distribution package. # Assume if the config has notary authentication information that # the products will be notarized, which requires a secure # timestamp.
The path to the signed PKG file.
The path to the signed PKG file .
paths
A |model.Paths| object.
A |model . Paths| object .
dist_config
The |config.CodeSignConfig| object.
The |config . CodeSignConfig| object .