Ejemplo n.º 1
0
def _get_last_chromium_modification():
    """Returns the last modification date of the chromium-browser-official tar file"""
    response = requests.head(
        'https://storage.googleapis.com/chromium-browser-official/chromium-{}.tar.xz'
        .format(get_chromium_version()))
    response.raise_for_status()
    return email.utils.parsedate_to_datetime(response.headers['Last-Modified'])
Ejemplo n.º 2
0
def main():
    """CLI Entrypoint"""
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('name', help='Name of packaging to generate')
    parser.add_argument('destination',
                        type=Path,
                        help='Directory to store packaging files')
    args = _validate_and_get_args(parser)

    if not args.destination.exists():
        args.destination.mkdir()

    # Copy packaging files to destination
    pkgmeta = validate_and_get_ini(_PKGMETA, _PKGMETA_SCHEMA)
    template_files = set()
    for relative_path, actual_path in _get_package_files(
            _get_package_dir_list(args.name, pkgmeta)):
        target_path = args.destination / relative_path
        if actual_path.is_dir():
            if not target_path.exists():
                target_path.mkdir()
            shutil.copymode(str(actual_path), str(target_path))
        else:
            shutil.copy(str(actual_path), str(target_path))
            if target_path.suffix.lower() == _TEMPLATE_SUFFIX:
                template_files.add(target_path)

    patch_stage_dir = str(args.destination / 'patches')
    os.mkdir(patch_stage_dir)
    patch_info = _get_spec_format_patch_list('config_bundles', patch_stage_dir)
    gn_map = _get_gn_flag_map('config_bundles')

    # Substitute template files
    packaging_subs = dict(chromium_version=get_chromium_version(),
                          release_revision=get_release_revision(),
                          numbered_patch_list=patch_info['patchString'],
                          apply_patches_cmd=_get_patch_apply_spec_cmd(
                              patch_info['numPatches']),
                          gn_flags=_get_parsed_gn_flags(gn_map),
                          current_commit_or_tag=_get_current_commit_or_tag())
    _process_templates(template_files, packaging_subs)

    # Copy buildkit and config files, if necessary
    _copy_buildkit_files(args,
                         pkgmeta,
                         files=('version.ini', 'run_buildkit_cli.py'),
                         dirs=('buildkit', 'config_bundles', 'patches'))
Ejemplo n.º 3
0
def _initialize_deps_tree():
    """
    Initializes and returns a dependency tree for DEPS files

    The DEPS tree is a dict has the following format:
    key - pathlib.Path relative to the DEPS file's path
    value - tuple(repo_url, version, recursive dict here)
        repo_url is the URL to the dependency's repository root
        If the recursive dict is a string, then it is a string to the DEPS file to load
            if needed

    download_session is an active requests.Session() object
    """
    root_deps_tree = {
        Path('src'): ('https://chromium.googlesource.com/chromium/src.git',
                      get_chromium_version(), 'DEPS')
    }
    return root_deps_tree
Ejemplo n.º 4
0
def main():
    """Entrypoint"""

    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument(
        '--cpu-arch',
        metavar='ARCH',
        default=platform.architecture()[0],
        choices=('64bit', '32bit'),
        help=('Filter build outputs by a target CPU. '
              'This is the same as the "arch" key in FILES.cfg. '
              'Default (from platform.architecture()): %(default)s'))
    args = parser.parse_args()

    build_outputs = Path('out/Default')
    output = Path('../ungoogled-chromium_{}-{}_windows.zip'.format(
        get_chromium_version(), get_release_revision()))

    files_generator = buildkit.filescfg.filescfg_generator(
        Path('chrome/tools/build/win/FILES.cfg'), build_outputs, args.cpu_arch)
    buildkit.filescfg.create_archive(files_generator, tuple(), build_outputs,
                                     output)
def _get_current_commit_or_tag():
    """
    Returns a string of the current commit hash, or the tag name based
    on version.ini if the script is not in a git repo.

    It assumes "git" is in PATH, and that buildkit is run within a git repository.

    Raises BuildkitAbort if invoking git fails.
    """
    # Use presence of .git directory to determine if using git or not
    # since git will be aggressive in finding a git repository otherwise
    if not (Path(__file__).parent / '.git').exists(): #pylint: disable=no-member
        # Probably not in a git checkout; extrapolate tag name based on
        # version.ini
        return '{}-{}'.format(get_chromium_version(), get_release_revision())
    result = subprocess.run(['git', 'rev-parse', '--verify', 'HEAD'],
                            stdout=subprocess.PIPE,
                            universal_newlines=True,
                            cwd=str(Path(__file__).resolve().parent))
    if result.returncode:
        get_logger().error('Unexpected return code %s', result.returncode)
        get_logger().error('Command output: %s', result.stdout)
        raise BuildkitAbort()
    return result.stdout.strip('\n')
Ejemplo n.º 6
0
def main():  #pylint: disable=too-many-branches
    """CLI Entrypoint"""
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('name', help='Name of packaging to generate')
    parser.add_argument('destination',
                        type=Path,
                        help='Directory to store packaging files')
    args = parser.parse_args()

    # Argument validation
    if not args.destination.parent.exists():
        parser.error('Destination parent directory "{}" does not exist'.format(
            args.destination.parent))
    if not _PACKAGING_ROOT.exists():  #pylint: disable=no-member
        parser.error('Cannot find "packaging" directory next to this script')
    packaging_dir = _PACKAGING_ROOT / args.name
    if not packaging_dir.exists():
        parser.error('Packaging "{}" does not exist'.format(args.name))
    if not _PKGMETA.exists():  #pylint: disable=no-member
        parser.error('Cannot find pkgmeta.ini in packaging directory')

    if not args.destination.exists():
        args.destination.mkdir()

    # Copy packaging files to destination
    pkgmeta = validate_and_get_ini(_PKGMETA, _PKGMETA_SCHEMA)
    for relative_path, actual_path in _get_package_files(
            _get_package_dir_list(args.name, pkgmeta)):
        if actual_path.is_dir():
            if not (args.destination / relative_path).exists():
                (args.destination / relative_path).mkdir()
            shutil.copymode(str(actual_path),
                            str(args.destination / relative_path))
        else:
            shutil.copy(str(actual_path),
                        str(args.destination / relative_path))

    # Substitute .ungoogin files
    packaging_subs = dict(
        chromium_version=get_chromium_version(),
        release_revision=get_release_revision(),
        current_commit=_get_current_commit(),
    )
    _process_templates(args.destination, packaging_subs)

    # Copy buildkit and config files, if necessary
    buildkit_copy_relative = _get_buildkit_copy(args.name, pkgmeta)
    if buildkit_copy_relative:
        if not (args.destination / buildkit_copy_relative).exists():
            (args.destination / buildkit_copy_relative).mkdir()
        shutil.copy(
            str(_ROOT_DIR / 'version.ini'),
            str(args.destination / buildkit_copy_relative / 'version.ini'))
        if (args.destination / buildkit_copy_relative / 'buildkit').exists():
            shutil.rmtree(
                str(args.destination / buildkit_copy_relative / 'buildkit'))
        shutil.copytree(
            str(_ROOT_DIR / 'buildkit'),
            str(args.destination / buildkit_copy_relative / 'buildkit'))
        if (args.destination / buildkit_copy_relative / 'patches').exists():
            shutil.rmtree(
                str(args.destination / buildkit_copy_relative / 'patches'))
        shutil.copytree(
            str(_ROOT_DIR / 'patches'),
            str(args.destination / buildkit_copy_relative / 'patches'))
        if (args.destination / buildkit_copy_relative /
                'config_bundles').exists():
            shutil.rmtree(
                str(args.destination / buildkit_copy_relative /
                    'config_bundles'))
        shutil.copytree(
            str(_ROOT_DIR / 'config_bundles'),
            str(args.destination / buildkit_copy_relative / 'config_bundles'))