archlinux: Use tar.gz instead of git clone of ungoogled-chromium repo

This commit is contained in:
Eloston
2018-02-28 14:15:26 +00:00
parent 5133481c72
commit d6d30ea55a
4 changed files with 48 additions and 29 deletions

View File

@@ -26,7 +26,7 @@ from . import domain_substitution
from .common import (
CONFIG_BUNDLES_DIR, BUILDSPACE_DOWNLOADS, BUILDSPACE_TREE,
BUILDSPACE_TREE_PACKAGING, BUILDSPACE_USER_BUNDLE,
BuildkitAbort, get_resources_dir, get_logger)
BuildkitAbort, get_resources_dir, get_logger, get_current_commit)
from .config import ConfigBundle
# Classes
@@ -242,8 +242,13 @@ def _add_genpkg_archlinux(subparsers):
"""Generate Arch Linux packaging files"""
def _callback(args):
from .packaging import archlinux as packaging_archlinux
if args.repo_commit:
repo_version = get_current_commit()
else:
repo_version = None
try:
packaging_archlinux.generate_packaging(args.bundle, args.output)
packaging_archlinux.generate_packaging(args.bundle, args.output,
repo_version=repo_version)
except FileExistsError as exc:
get_logger().error('Output directory is not empty: %s', exc)
raise _CLIError()
@@ -259,6 +264,13 @@ def _add_genpkg_archlinux(subparsers):
help=('The directory to store packaging files. '
'It must not already exist, but the parent directories must exist. '
'Default: %(default)s'))
parser.add_argument(
'--repo-commit', action='store_true',
help=("Use the current git repo's commit hash to specify the "
"ungoogled-chromium repo to download instead of a tag determined "
"by the config bundle's version config file. Requires git to be "
"in PATH and buildkit to be invoked inside of a clone of "
"ungoogled-chromium's git repository."))
parser.set_defaults(callback=_callback)
def _add_genpkg_debian(subparsers):

View File

@@ -7,8 +7,9 @@
"""Common code and constants"""
import os
import pathlib
import logging
import subprocess
from pathlib import Path
# Constants
@@ -69,12 +70,12 @@ def get_resources_dir():
"""
env_value = os.environ.get(_ENV_FORMAT.format('RESOURCES'))
if env_value:
path = pathlib.Path(env_value)
path = Path(env_value)
get_logger().debug(
'Using %s environment variable value: %s', _ENV_FORMAT.format('RESOURCES'), path)
else:
# Assume that this resides in the repository
path = pathlib.Path(__file__).absolute().parent.parent / 'resources'
path = Path(__file__).absolute().parent.parent / 'resources'
if not path.is_dir():
raise NotADirectoryError(str(path))
return path
@@ -105,3 +106,20 @@ def ensure_empty_dir(path, parents=False):
except FileExistsError as exc:
if not dir_empty(path):
raise exc
def get_current_commit():
"""
Returns a string of the current commit hash.
It assumes "git" is in PATH, and that buildkit is run within a git repository.
Raises BuildkitAbort if invoking git fails.
"""
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')

View File

@@ -7,13 +7,9 @@
"""Arch Linux-specific build files generation code"""
import shutil
import subprocess
import hashlib
from pathlib import Path
from ..common import PACKAGING_DIR, BuildkitAbort, get_logger, get_resources_dir, ensure_empty_dir
from ._common import (
DEFAULT_BUILD_OUTPUT, SHARED_PACKAGING, process_templates)
from ..common import PACKAGING_DIR, get_resources_dir, ensure_empty_dir
from ._common import DEFAULT_BUILD_OUTPUT, SHARED_PACKAGING, process_templates
# Private definitions
@@ -31,17 +27,6 @@ def _copy_from_resources(name, output_dir, shared=False):
str(_get_packaging_resources(shared=shared) / name),
str(output_dir / name))
def _get_current_commit():
"""Use git to get the current commit for use as a download URL specifier"""
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')
def _generate_gn_flags(flags_items_iter):
"""Returns GN flags for the PKGBUILD"""
indentation = ' ' * _FLAGS_INDENTATION
@@ -49,21 +34,27 @@ def _generate_gn_flags(flags_items_iter):
# Public definitions
def generate_packaging(config_bundle, output_dir, build_output=DEFAULT_BUILD_OUTPUT):
def generate_packaging(config_bundle, output_dir, repo_version=None,
build_output=DEFAULT_BUILD_OUTPUT):
"""
Generates the archlinux packaging into output_dir
Generates an Arch Linux PKGBUILD into output_dir
config_bundle is the config.ConfigBundle to use for configuration
output_dir is the pathlib.Path directory that will be created to contain packaging files
repo_version is a string that specifies the ungoogled-chromium repository to
download for use within the PKGBUILD. Defaults to None, which causes the use
of the config bundle's version config file.
build_output is a pathlib.Path for building intermediates and outputs to be stored
template_url is a string URL with Python format keywords 'specifier' and 'path'
Raises FileExistsError if output_dir already exists and is not empty.
Raises FileNotFoundError if the parent directories for output_dir do not exist.
"""
if repo_version is None:
repo_version = config_bundle.version.version_string
build_file_subs = dict(
chromium_version=config_bundle.version.chromium_version,
release_revision=config_bundle.version.release_revision,
repo_version=repo_version,
build_output=build_output,
gn_flags=_generate_gn_flags(sorted(config_bundle.gn_flags.items())),
)

View File

@@ -31,7 +31,7 @@ conflicts=('chromium' 'inox' 'iridium')
source=(https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$pkgver.tar.xz
chromium-launcher-$_launcher_ver.tar.gz::https://github.com/foutrelis/chromium-launcher/archive/v$_launcher_ver.tar.gz
chromium-$pkgver.txt::https://chromium.googlesource.com/chromium/src.git/+/$pkgver?format=TEXT
'ungoogled-chromium::git+https://github.com/Eloston/ungoogled-chromium.git')
'https://github.com/Eloston/ungoogled-chromium/archive/$ungoog{repo_version}.tar.gz')
sha256sums=('5fd0218759231ac00cc729235823592f6fd1e4a00ff64780a5fed7ab210f1860'
'4dc3428f2c927955d9ae117f2fb24d098cc6dd67adb760ac9c82b522ec8b0587'
'e73f69942af1ba730a700151973fa6309b0586ff45bf35a7fea43f52b54a9cb5'
@@ -69,9 +69,7 @@ readonly _unwanted_bundled_libs=(
depends+=(${_system_libs[@]} freetype2 harfbuzz)
prepare() {
cd "$srcdir/ungoogled-chromium"
git checkout develop
cd "$srcdir/ungoogled-chromium-$ungoog{repo_version}"
msg2 'Processing sources'
python3 buildkit-launcher.py genbun -u "$srcdir/chromium-$pkgver/ungoogled" archlinux