Bug 1904839 - [devtools] Support color picker in High Contrast Mode. r=accessibility...
[gecko.git] / python / mozboot / mozboot / archlinux.py
blob005c5a95779e9d443b1add954cdef08fc30154fb
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import subprocess
6 import sys
8 from mozboot.base import BaseBootstrapper
9 from mozboot.linux_common import LinuxBootstrapper
12 class ArchlinuxBootstrapper(LinuxBootstrapper, BaseBootstrapper):
13 """Archlinux experimental bootstrapper."""
15 def __init__(self, version, dist_id, **kwargs):
16 print("Using an experimental bootstrapper for Archlinux.", file=sys.stderr)
17 BaseBootstrapper.__init__(self, **kwargs)
19 def install_packages(self, packages):
20 # watchman is not available via pacman
21 packages = [p for p in packages if p != "watchman"]
22 self.pacman_install(*packages)
24 def upgrade_mercurial(self, current):
25 self.pacman_install("mercurial")
27 def pacman_install(self, *packages):
28 def is_installed(package):
29 pacman_query = subprocess.run(
30 ["pacman", "-Q", package],
31 stdout=subprocess.PIPE,
32 stderr=subprocess.STDOUT,
33 check=False,
35 if pacman_query.returncode not in [0, 1]:
36 raise Exception(
37 f'Failed to query pacman whether "{package}" is installed: "{pacman_query.stdout}"'
39 return pacman_query.returncode == 0
41 packages = [p for p in packages if not is_installed(p)]
42 # avoid sudo prompt if all packages are installed already
43 if not packages:
44 return
46 command = ["pacman", "-S", "--needed"]
47 if self.no_interactive:
48 command.append("--noconfirm")
50 command.extend(packages)
52 self.run_as_root(command)