diff --git a/python/mozboot/mozboot/base.py b/python/mozboot/mozboot/base.py index 6921964..bc8dafd 100644 --- a/python/mozboot/mozboot/base.py +++ b/python/mozboot/mozboot/base.py @@ -50,6 +50,22 @@ If it continues to fail, consider installing Mercurial by following the instructions at http://mercurial.selenic.com/. """ +MERCURIAL_INSTALL_PROMPT = """ +Mercurial releases a new version every 3 months and your distro's package +may become out of date. This may cause incompatibility with some +Mercurial extensions that rely on new Mercurial features. As a result, +you may not have an optimal version control experience. + +To have the best Mercurial experience possible, we recommend installing +Mercurial via the "pip" Python packaging utility. This will likely result +in files being placed in /usr/local/bin and /usr/local/lib. + +How would you like to continue? + 1. Install a modern Mercurial via pip [default] + 2. Install a legacy Mercurial via the distro package manager + 3. Do not install Mercurial +Your choice: """ + PYTHON_UNABLE_UPGRADE = """ You are currently running Python %s. Running %s or newer (but not 3.x) is required. diff --git a/python/mozboot/mozboot/opensuse.py b/python/mozboot/mozboot/opensuse.py index d5ab72e..4aa89b6 100644 --- a/python/mozboot/mozboot/opensuse.py +++ b/python/mozboot/mozboot/opensuse.py @@ -4,9 +4,11 @@ from __future__ import absolute_import, print_function, unicode_literals -from mozboot.base import BaseBootstrapper +from mozboot.base import BaseBootstrapper, MERCURIAL_INSTALL_PROMPT from mozboot.linux_common import LinuxBootstrapper +import distro +import subprocess class OpenSUSEBootstrapper(LinuxBootstrapper, BaseBootstrapper): """openSUSE experimental bootstrapper.""" @@ -17,6 +19,7 @@ class OpenSUSEBootstrapper(LinuxBootstrapper, BaseBootstrapper): "rpmconf", "watchman", "which", + "unzip", ] BROWSER_PACKAGES = [ @@ -24,7 +27,6 @@ class OpenSUSEBootstrapper(LinuxBootstrapper, BaseBootstrapper): "gcc-c++", "gtk3-devel", "dbus-1-glib-devel", - "gconf2-devel", "glibc-devel-static", "libstdc++-devel", "libXt-devel", @@ -34,6 +36,10 @@ class OpenSUSEBootstrapper(LinuxBootstrapper, BaseBootstrapper): "patterns-gnome-devel_gnome", ] + OPTIONAL_BROWSER_PACKAGES = [ + "gconf2-devel", # https://bugzilla.mozilla.org/show_bug.cgi?id=1779931 + ] + BROWSER_GROUP_PACKAGES = ["devel_C_C++", "devel_gnome"] MOBILE_ANDROID_COMMON_PACKAGES = ["java-1_8_0-openjdk"] @@ -47,7 +53,18 @@ class OpenSUSEBootstrapper(LinuxBootstrapper, BaseBootstrapper): def install_browser_packages(self, mozconfig_builder, artifact_mode=False): # TODO: Figure out what not to install for artifact mode - self.zypper_install(*self.BROWSER_PACKAGES) + packages_to_install = self.BROWSER_PACKAGES.copy() + + for package in self.OPTIONAL_BROWSER_PACKAGES: + if self.zypper_can_install(package): + packages_to_install.append(package) + else: + print( + f"WARNING! zypper cannot find a package for '{package}' for {distro.name(True)}. " + "It will not be automatically installed." + ) + + self.zypper_install(*packages_to_install) def install_browser_group_packages(self): self.ensure_browser_group_packages() @@ -55,10 +72,6 @@ class OpenSUSEBootstrapper(LinuxBootstrapper, BaseBootstrapper): def install_browser_artifact_mode_packages(self, mozconfig_builder): self.install_browser_packages(mozconfig_builder, artifact_mode=True) - def install_mercurial(self): - self(["pip", "install", "--upgrade", "pip", "--user"]) - self(["pip", "install", "--upgrade", "Mercurial", "--user"]) - def ensure_clang_static_analysis_package(self): from mozboot import static_analysis @@ -92,35 +105,51 @@ class OpenSUSEBootstrapper(LinuxBootstrapper, BaseBootstrapper): ) def _update_package_manager(self): - self.zypper_update + self.zypper_update() def upgrade_mercurial(self, current): - self(["pip3", "install", "--upgrade", "pip", "--user"]) - self(["pip3", "install", "--upgrade", "Mercurial", "--user"]) - - def zypper_install(self, *packages): - command = ["zypper", "install"] + """Install Mercurial from pip because system packages could lag.""" if self.no_interactive: - command.append("-n") + # Install via zypper in non-interactive mode because it is the more + # conservative option and less likely to make people upset. + self.zypper_install("mercurial") + return - command.extend(packages) + res = self.prompt_int(MERCURIAL_INSTALL_PROMPT, 1, 3) - self.run_as_root(command) + # zypper. + if res == 2: + self.zypper_install("mercurial") + return False - def zypper_update(self, *packages): - command = ["zypper", "update"] - if self.no_interactive: - command.append("-n") + # No Mercurial. + if res == 3: + print("Not installing Mercurial.") + return False - command.extend(packages) + # pip. + assert res == 1 + self.run_as_root(["pip3", "install", "--upgrade", "Mercurial"]) + + def zypper(self, *args): + if self.no_interactive: + command = ["zypper", "-n", *args] + else: + command = ["zypper", *args] self.run_as_root(command) - def zypper_patterninstall(self, *packages): - command = ["zypper", "install", "-t", "pattern"] - if self.no_interactive: - command.append("-y") + def zypper_install(self, *packages): + self.zypper("install", *packages) - command.extend(packages) + def zypper_can_install(self, package): + return ( + subprocess.call(["zypper", "search", package], stdout=subprocess.DEVNULL) + == 0 + ) - self.run_as_root(command) + def zypper_update(self, *packages): + self.zypper("update", *packages) + + def zypper_patterninstall(self, *packages): + self.zypper("install", "-t", "pattern", *packages)