From 86fc0e84b433065dee07d10d09a5d93bc692063c Mon Sep 17 00:00:00 2001 From: Timothy Vaccarelli Date: Sat, 17 Mar 2018 14:07:59 -0400 Subject: [PATCH] Add instructions for OpenSUSE and fix the OpenSUSE build --- BUILDING.md | 47 ++++++++++++++ buildkit/cli.py | 24 +++++++ buildkit/packaging/opensuse.py | 62 +++++++++++++++++++ .../config_bundles/opensuse/gn_flags.map | 4 +- resources/packaging/opensuse/build.sh.in | 3 +- .../debian/fixes/incomplete-type.patch | 14 +++++ ...03-disable-autofill-download-manager.patch | 1 + 7 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 buildkit/packaging/opensuse.py diff --git a/BUILDING.md b/BUILDING.md index 022f0429..b05f265e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -23,6 +23,7 @@ Contents: * [Windows](#windows) * [macOS](#macos) * [Arch Linux](#arch-linux) +* [OpenSUSE](#OpenSUSE) * [Other Linux distributions](#other-linux-distributions) ### Debian and its derivatives @@ -220,6 +221,52 @@ Requirements: Same as the build dependencies in the PKGBUILD (which can be seen The instructions are the same as [Other Linux distributions](#other-linux-distributions), except that the `archlinux` base bundle is used in the `genbun` command. +### OpenSUSE + +Tested on OpenSUSE Leap 42.3 + +#### Setting up the build environment + +Install ninja, if not done so already: `# sudo zypper install ninja` + +Follow the following guide to set up Python 3.6.4: [https://gist.github.com/antivanov/01ed4eac2d7486a170be598b5a0a4ac7](https://gist.github.com/antivanov/01ed4eac2d7486a170be598b5a0a4ac7) + +As of Chromium 65.0.3325.162, clang/llvm version 5 or greater is required to avoid compiler errors. + +Since Leap 42.3 only offers clang 3.8 in the base repos, add the following repository in YaST (YaST --> Software Repositories): `http://download.opensuse.org/repositories/home:/frispete:/llvm/openSUSE_Leap_42.3/` and give it a name such as LLVM 5. + +Then go to YaST --> Software Management and click on the Repositories tab. From there, select the LLVM 5 repo that was just added. + +If given the option, elect to switch system packages to the versions in the LLVM repository. Additionally, ensure the following packages are selected from the LLVM repo: +* clang +* libclang5 +* lld +* llvm +* llvm5-gold +* libllvm5 + +#### Setting up the buildspace tree and packaging files + +Before executing the following commands, make sure you are using python 3.6 as was mentioned in the build environment section of this guide. + +``` +mkdir -p buildspace/downloads +./buildkit-launcher.py genbun opensuse +./buildkit-launcher.py subdom +./buildkit-launcher.py genpkg opensuse +``` + +Before proceeding to the build chromium, open a new tab or otherwise exit the python 3.6 virtual environment, as it will cause errors in the next step. + +#### Invoking build + +``` +cd buildspace/tree +./ungoogled_packaging/build.sh +``` + +The binaries for chromium will be located in the folder `out/Default` + ### Other Linux distributions These are for building on Linux distributions that do not have support already. It builds without distribution-optimized flags and patches for maximum compatibility. diff --git a/buildkit/cli.py b/buildkit/cli.py index 678febf0..51a3b897 100644 --- a/buildkit/cli.py +++ b/buildkit/cli.py @@ -324,6 +324,29 @@ def _add_genpkg_linux_simple(subparsers): 'Default: %(default)s')) parser.set_defaults(callback=_callback) +def _add_genpkg_opensuse(subparsers): + """Generate OpenSUSE packaging files""" + def _callback(args): + from .packaging import opensuse as packaging_opensuse + try: + packaging_opensuse.generate_packaging(args.bundle, args.output) + except FileExistsError as exc: + get_logger().error('Output directory is not empty: %s', exc) + raise _CLIError() + except FileNotFoundError as exc: + get_logger().error( + 'Parent directories do not exist for path: %s', exc) + raise _CLIError() + parser = subparsers.add_parser( + 'opensuse', help=_add_genpkg_opensuse.__doc__, + description=_add_genpkg_opensuse.__doc__) + parser.add_argument( + '-o', '--output', type=Path, default=BUILDSPACE_TREE_PACKAGING, + help=('The directory to store packaging files. ' + 'It must not already exist, but the parent directories must exist. ' + 'Default: %(default)s')) + parser.set_defaults(callback=_callback) + def _add_genpkg_windows(subparsers): """Generate Microsoft Windows packaging files""" def _callback(args): @@ -382,6 +405,7 @@ def _add_genpkg(subparsers): _add_genpkg_archlinux(subsubparsers) _add_genpkg_debian(subsubparsers) _add_genpkg_linux_simple(subsubparsers) + _add_genpkg_opensuse(subsubparsers) _add_genpkg_windows(subsubparsers) _add_genpkg_macos(subsubparsers) diff --git a/buildkit/packaging/opensuse.py b/buildkit/packaging/opensuse.py new file mode 100644 index 00000000..6ef4c7e1 --- /dev/null +++ b/buildkit/packaging/opensuse.py @@ -0,0 +1,62 @@ +# -*- coding: UTF-8 -*- + +# Copyright (c) 2017 The ungoogled-chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""OpenSUSE-specific build files generation code""" + +import shutil + +from ..common import PACKAGING_DIR, PATCHES_DIR, get_resources_dir, ensure_empty_dir +from ._common import ( + DEFAULT_BUILD_OUTPUT, SHARED_PACKAGING, LIST_BUILD_OUTPUTS, process_templates) + +# Private definitions + +def _get_packaging_resources(shared=False): + if shared: + return get_resources_dir() / PACKAGING_DIR / SHARED_PACKAGING + else: + return get_resources_dir() / PACKAGING_DIR / 'opensuse' + +def _copy_from_resources(name, output_dir, shared=False): + shutil.copy( + str(_get_packaging_resources(shared=shared) / name), + str(output_dir / name)) + +# Public definitions + +def generate_packaging(config_bundle, output_dir, build_output=DEFAULT_BUILD_OUTPUT): + """ + Generates the opensuse packaging 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 + build_output is a pathlib.Path for building intermediates and outputs to be stored + + Raises FileExistsError if output_dir already exists and is not empty. + Raises FileNotFoundError if the parent directories for output_dir do not exist. + """ + build_file_subs = dict( + build_output=build_output, + gn_args_string=' '.join( + '{}={}'.format(flag, value) for flag, value in config_bundle.gn_flags.items()), + version_string=config_bundle.version.version_string + ) + + ensure_empty_dir(output_dir) # Raises FileNotFoundError, FileExistsError + (output_dir / 'scripts').mkdir() + (output_dir / 'archive_include').mkdir() + + # Build and packaging scripts + _copy_from_resources('build.sh.in', output_dir) + _copy_from_resources('package.sh.in', output_dir) + _copy_from_resources(LIST_BUILD_OUTPUTS, output_dir / 'scripts', shared=True) + process_templates(output_dir, build_file_subs) + + # Other resources to package + _copy_from_resources('README', output_dir / 'archive_include') + + # Patches + config_bundle.patches.export_patches(output_dir / PATCHES_DIR) diff --git a/resources/config_bundles/opensuse/gn_flags.map b/resources/config_bundles/opensuse/gn_flags.map index ef47700a..98278250 100644 --- a/resources/config_bundles/opensuse/gn_flags.map +++ b/resources/config_bundles/opensuse/gn_flags.map @@ -4,11 +4,13 @@ is_component_build=false is_component_ffmpeg=true link_pulseaudio=true linux_use_bundled_binutils=false -use_allocator="tcmalloc" use_aura=true use_cups=true use_custom_libcxx=false use_gold=true +goma_dir="" +gold_path="" +use_lld=true use_gtk3=true use_kerberos=false use_pulseaudio=true diff --git a/resources/packaging/opensuse/build.sh.in b/resources/packaging/opensuse/build.sh.in index a631c9d3..6e0d2bf9 100755 --- a/resources/packaging/opensuse/build.sh.in +++ b/resources/packaging/opensuse/build.sh.in @@ -11,7 +11,8 @@ true ${CLANG_BASE_PATH:=/usr} # http://www.tldp.org/LDP/abs/html/parameter-subst rm -rf out || true mkdir out mkdir $ungoog{build_output} -env QUILT_PATCHES=./ungoogled_packaging/patches quilt push -a +env QUILT_PATCHES=$(dirname $(readlink -f $0))/patches quilt push -a +export LD_LIBRARY_PATH=$(pwd)/out/Default:$LD_LIBRARY_PATH ./tools/gn/bootstrap/bootstrap.py -o $ungoog{build_output}/gn -s -j 4 ./$ungoog{build_output}/gn gen $ungoog{build_output} --args='$ungoog{gn_args_string}' --fail-on-unused-args ninja -C $ungoog{build_output} chrome chrome_sandbox chromedriver diff --git a/resources/patches/debian/fixes/incomplete-type.patch b/resources/patches/debian/fixes/incomplete-type.patch index 3ed3a326..64ef60ef 100644 --- a/resources/patches/debian/fixes/incomplete-type.patch +++ b/resources/patches/debian/fixes/incomplete-type.patch @@ -16,3 +16,17 @@ author: Michael Gilbert class PrefService; namespace base { +--- a/components/policy/core/browser/browser_policy_connector_base.h ++++ b/components/policy/core/browser/browser_policy_connector_base.h +@@ -15,10 +15,10 @@ + #include "components/policy/core/common/schema.h" + #include "components/policy/core/common/schema_registry.h" + #include "components/policy/policy_export.h" ++#include "components/policy/core/common/configuration_policy_provider.h" + + namespace policy { + +-class ConfigurationPolicyProvider; + class PolicyService; + class PolicyServiceImpl; + diff --git a/resources/patches/inox-patchset/0003-disable-autofill-download-manager.patch b/resources/patches/inox-patchset/0003-disable-autofill-download-manager.patch index c0667ebe..cd7cb6e9 100644 --- a/resources/patches/inox-patchset/0003-disable-autofill-download-manager.patch +++ b/resources/patches/inox-patchset/0003-disable-autofill-download-manager.patch @@ -48,3 +48,4 @@ - return true; } +