diff --git a/python/mozboot/mozboot/base.py b/python/mozboot/mozboot/base.py index d4087deeff1e..30a2dcded2e7 100644 --- a/python/mozboot/mozboot/base.py +++ b/python/mozboot/mozboot/base.py @@ -77,7 +77,7 @@ the $PATH environment variable. We recommend the following tools for installing Python: - pyenv -- https://github.com/yyuu/pyenv) + pyenv -- https://github.com/yyuu/pyenv pythonz -- https://github.com/saghul/pythonz official installers -- http://www.python.org/ ''' diff --git a/python/mozboot/mozboot/bootstrap.py b/python/mozboot/mozboot/bootstrap.py index 1668a35866ea..cca6a6efded9 100644 --- a/python/mozboot/mozboot/bootstrap.py +++ b/python/mozboot/mozboot/bootstrap.py @@ -31,6 +31,7 @@ else: # list in bin/bootstrap.py! from mozboot.base import MODERN_RUST_VERSION from mozboot.centosfedora import CentOSFedoraBootstrapper +from mozboot.opensuse import OpenSUSEBootstrapper from mozboot.debian import DebianBootstrapper from mozboot.freebsd import FreeBSDBootstrapper from mozboot.gentoo import GentooBootstrapper @@ -274,6 +275,8 @@ class Bootstrapper(object): cls = SolusBootstrapper elif dist_id in ('arch') or os.path.exists('/etc/arch-release'): cls = ArchlinuxBootstrapper + elif os.path.exists('/etc/SUSE-brand'): + cls = OpenSUSEBootstrapper else: raise NotImplementedError('Bootstrap support for this Linux ' 'distro not yet available: ' + dist_id) diff --git a/python/mozboot/mozboot/opensuse.py b/python/mozboot/mozboot/opensuse.py new file mode 100644 index 000000000000..58129502e9c9 --- /dev/null +++ b/python/mozboot/mozboot/opensuse.py @@ -0,0 +1,169 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +from __future__ import absolute_import, print_function, unicode_literals + +from mozboot.base import BaseBootstrapper +from mozboot.linux_common import ( + ClangStaticAnalysisInstall, + LucetcInstall, + NasmInstall, + NodeInstall, + SccacheInstall, + StyloInstall, + WasiSysrootInstall, +) + + +class OpenSUSEBootstrapper( + NasmInstall, NodeInstall, StyloInstall, ClangStaticAnalysisInstall, + SccacheInstall, LucetcInstall, WasiSysrootInstall, BaseBootstrapper): + '''openSUSE experimental bootstrapper.''' + + SYSTEM_PACKAGES = [ + 'autoconf213', + 'nodejs', + 'npm', + 'which', + 'python3-devel', + 'rpmconf', + 'libcurl-devel', + 'libpulse-devel', + ] + + BROWSER_PACKAGES = [ + 'alsa-devel', + 'gcc-c++', + 'python3-dbus-python', + 'python3-wheel', + 'gtk3-devel', + 'dbus-1-glib-devel', + 'gconf2-devel', + 'glibc-devel-static', + 'libstdc++-devel', + 'libXt-devel', + 'libproxy-devel', + 'libuuid-devel', + 'yasm', + 'gtk2-devel', + 'clang-devel', + 'patterns-gnome-devel_gnome', + ] + + BROWSER_GROUP_PACKAGES = [ + 'devel_C_C++', + 'devel_gnome', + ] + + MOBILE_ANDROID_COMMON_PACKAGES = [ + 'java-1_8_0-openjdk', + 'wget', + ] + + def __init__(self, version, dist_id, **kwargs): + print('Using an experimental bootstrapper for openSUSE.') + BaseBootstrapper.__init__(self, **kwargs) + + def install_system_packages(self): + self.zypper_install(*self.SYSTEM_PACKAGES) + + def install_browser_packages(self): + self.ensure_browser_packages() + + def install_browser_group_packages(self): + self.ensure_browser_group_packages() + + def install_browser_artifact_mode_packages(self): + self.ensure_browser_packages(artifact_mode=True) + + def install_mobile_android_packages(self): + self.ensure_mobile_android_packages() + + def install_mobile_android_artifact_mode_packages(self): + self.ensure_mobile_android_packages(artifact_mode=True) + + def install_mercurial(self): + self.run_as_root(['pip', 'install', '--upgrade', 'pip']) + self.run_as_root(['pip', 'install', '--upgrade', 'Mercurial']) + + def ensure_clang_static_analysis_package(self, state_dir, checkout_root): + from mozboot import static_analysis + self.install_toolchain_static_analysis( + state_dir, checkout_root, static_analysis.LINUX_CLANG_TIDY) + + def ensure_browser_packages(self, artifact_mode=False): + # TODO: Figure out what not to install for artifact mode + self.zypper_install(*self.BROWSER_PACKAGES) + + def ensure_browser_group_packages(self, artifact_mode=False): + # TODO: Figure out what not to install for artifact mode + self.zypper_patterninstall(*self.BROWSER_GROUP_PACKAGES) + + def ensure_mobile_android_packages(self, artifact_mode=False): + # Multi-part process: + # 1. System packages. + # 2. Android SDK. Android NDK only if we are not in artifact mode. Android packages. + + # 1. This is hard to believe, but the Android SDK binaries are 32-bit + # and that conflicts with 64-bit Arch installations out of the box. The + # solution is to add the multilibs repository; unfortunately, this + # requires manual intervention. + try: + self.zypper_install(*self.MOBILE_ANDROID_COMMON_PACKAGES) + except Exception as e: + print('Failed to install all packages. The Android developer ' + 'toolchain requires 32 bit binaries be enabled') + raise e + + # 2. Android pieces. + from mozboot import android + android.ensure_android('linux', artifact_mode=artifact_mode, + no_interactive=self.no_interactive) + + def suggest_mobile_android_mozconfig(self, artifact_mode=False): + from mozboot import android + android.suggest_mozconfig('linux', artifact_mode=artifact_mode) + + def suggest_mobile_android_artifact_mode_mozconfig(self): + self.suggest_mobile_android_mozconfig(artifact_mode=True) + + def _update_package_manager(self): + self.zypper_update + + def upgrade_mercurial(self, current): + self.run_as_root(['pip3', 'install', '--upgrade', 'pip']) + self.run_as_root(['pip3', 'install', '--upgrade', 'Mercurial']) + + def ensure_nasm_packages(self, state_dir, checkout_root): + self.zypper_install('nasm') + + def upgrade_python(self, current): + self.zypper_install('python3') + + def zypper_install(self, *packages): + command = ['zypper', 'install'] + if self.no_interactive: + command.append('-n') + + command.extend(packages) + + self.run_as_root(command) + + def zypper_update(self, *packages): + command = ['zypper', 'update'] + if self.no_interactive: + command.append('-n') + + command.extend(packages) + + self.run_as_root(command) + + def zypper_patterninstall(self, *packages): + command = ['zypper', 'install', '-t', 'pattern'] + if self.no_interactive: + command.append('-y') + + command.extend(packages) + + self.run_as_root(command)