mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
Bug 1651403 - Clean up bootstrap
code post-Python 3 migration r=nalexander
Since bug 1647865, we're no longer allowing `bootstrap` to be run with Python 2. Therefore we have leeway to make a bunch of simplifications. Differential Revision: https://phabricator.services.mozilla.com/D82737
This commit is contained in:
parent
ff699eadb0
commit
9dec41defd
@ -442,14 +442,6 @@ class BaseBootstrapper(object):
|
||||
|
||||
self.run_as_root(command)
|
||||
|
||||
def check_output(self, *args, **kwargs):
|
||||
"""Run subprocess.check_output even if Python doesn't provide it."""
|
||||
# TODO Legacy Python 2.6 code, can be removed.
|
||||
# We had a custom check_output() function for Python 2.6 backward
|
||||
# compatibility. Since py2.6 support was dropped we can remove this
|
||||
# method.
|
||||
return subprocess.check_output(*args, **kwargs)
|
||||
|
||||
def prompt_int(self, prompt, low, high, limit=5):
|
||||
''' Prompts the user with prompt and requires an integer between low and high. '''
|
||||
valid = False
|
||||
@ -517,11 +509,11 @@ class BaseBootstrapper(object):
|
||||
if name.endswith('.exe'):
|
||||
name = name[:-4]
|
||||
|
||||
info = self.check_output([path, version_param],
|
||||
env=env,
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True)
|
||||
info = subprocess.check_output(
|
||||
[path, version_param], env=env, stderr=subprocess.STDOUT,
|
||||
universal_newlines=True)
|
||||
match = re.search(name + ' ([a-z0-9\.]+)', info)
|
||||
|
||||
if not match:
|
||||
print('ERROR! Unable to identify %s version.' % name)
|
||||
return None
|
||||
|
@ -473,7 +473,6 @@ class Bootstrapper(object):
|
||||
# We need to enable the loading of hgrc in case extensions are
|
||||
# required to open the repo.
|
||||
r = current_firefox_checkout(
|
||||
check_output=self.instance.check_output,
|
||||
env=self.instance._hg_cleanenv(load_hgrc=True),
|
||||
hg=self.instance.which('hg'))
|
||||
(checkout_type, checkout_root) = r
|
||||
@ -502,8 +501,7 @@ class Bootstrapper(object):
|
||||
|
||||
# We need to enable the loading of hgrc in case extensions are
|
||||
# required to open the repo.
|
||||
r = current_firefox_checkout(check_output=self.instance.check_output,
|
||||
env=self.instance._hg_cleanenv(load_hgrc=True),
|
||||
r = current_firefox_checkout(env=self.instance._hg_cleanenv(load_hgrc=True),
|
||||
hg=self.instance.which('hg'))
|
||||
(checkout_type, checkout_root) = r
|
||||
|
||||
@ -721,7 +719,7 @@ def hg_clone_firefox(hg, dest):
|
||||
return True
|
||||
|
||||
|
||||
def current_firefox_checkout(check_output, env, hg=None):
|
||||
def current_firefox_checkout(env, hg=None):
|
||||
"""Determine whether we're in a Firefox checkout.
|
||||
|
||||
Returns one of None, ``git``, or ``hg``.
|
||||
@ -738,10 +736,9 @@ def current_firefox_checkout(check_output, env, hg=None):
|
||||
if hg and os.path.exists(hg_dir):
|
||||
# Verify the hg repo is a Firefox repo by looking at rev 0.
|
||||
try:
|
||||
node = check_output([hg, 'log', '-r', '0', '--template', '{node}'],
|
||||
cwd=path,
|
||||
env=env,
|
||||
universal_newlines=True)
|
||||
node = subprocess.check_output(
|
||||
[hg, 'log', '-r', '0', '--template', '{node}'],
|
||||
cwd=path, env=env, universal_newlines=True)
|
||||
if node in HG_ROOT_REVISIONS:
|
||||
_warn_if_risky_revision(path)
|
||||
return ('hg', path)
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import subprocess
|
||||
|
||||
from mozboot.base import BaseBootstrapper
|
||||
from mozboot.linux_common import LinuxBootstrapper
|
||||
|
||||
@ -116,7 +118,7 @@ class DebianBootstrapper(
|
||||
have_python3 = any([self.which('python3'), self.which('python3.8'),
|
||||
self.which('python3.7'), self.which('python3.6'),
|
||||
self.which('python3.5')])
|
||||
python3_packages = self.check_output(
|
||||
python3_packages = subprocess.check_output(
|
||||
['apt-cache', 'pkgnames', 'python3'], universal_newlines=True)
|
||||
python3_packages = python3_packages.splitlines()
|
||||
|
||||
|
@ -228,8 +228,8 @@ class OSXBootstrapper(BaseBootstrapper):
|
||||
elif self.os_version >= StrictVersion('10.7'):
|
||||
select = self.which('xcode-select')
|
||||
try:
|
||||
output = self.check_output([select, '--print-path'],
|
||||
stderr=subprocess.STDOUT)
|
||||
output = subprocess.check_output([select, '--print-path'],
|
||||
stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
# This seems to appear on fresh OS X machines before any Xcode
|
||||
# has been installed. It may only occur on OS X 10.9 and later.
|
||||
@ -251,14 +251,14 @@ class OSXBootstrapper(BaseBootstrapper):
|
||||
# Once Xcode is installed, you need to agree to the license before you can
|
||||
# use it.
|
||||
try:
|
||||
output = self.check_output(['/usr/bin/xcrun', 'clang'],
|
||||
stderr=subprocess.STDOUT)
|
||||
output = subprocess.check_output(['/usr/bin/xcrun', 'clang'],
|
||||
stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
if b'license' in e.output:
|
||||
xcodebuild = self.which('xcodebuild')
|
||||
try:
|
||||
self.check_output([xcodebuild, '-license'],
|
||||
stderr=subprocess.STDOUT)
|
||||
subprocess.check_output([xcodebuild, '-license'],
|
||||
stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as e:
|
||||
if b'requires admin privileges' in e.output:
|
||||
self.run_as_root([xcodebuild, '-license'])
|
||||
@ -272,8 +272,8 @@ class OSXBootstrapper(BaseBootstrapper):
|
||||
print(INSTALL_XCODE_COMMAND_LINE_TOOLS_STEPS)
|
||||
sys.exit(1)
|
||||
|
||||
output = self.check_output(['/usr/bin/clang', '--version'],
|
||||
universal_newlines=True)
|
||||
output = subprocess.check_output(['/usr/bin/clang', '--version'],
|
||||
universal_newlines=True)
|
||||
match = RE_CLANG_VERSION.search(output)
|
||||
if match is None:
|
||||
raise Exception('Could not determine Clang version.')
|
||||
@ -302,15 +302,15 @@ class OSXBootstrapper(BaseBootstrapper):
|
||||
self._ensure_package_manager_updated()
|
||||
cmd = [self.brew] + extra_brew_args
|
||||
|
||||
installed = set(self.check_output(cmd + ['list'],
|
||||
universal_newlines=True).split())
|
||||
installed = set(subprocess.check_output(
|
||||
cmd + ['list'], universal_newlines=True).split())
|
||||
to_install = set(
|
||||
package for package in packages if package not in installed)
|
||||
|
||||
# The "--quiet" tells "brew" to only list the package names, and not the
|
||||
# comparison between current and new version.
|
||||
outdated = set(self.check_output(cmd + ['outdated', '--quiet'],
|
||||
universal_newlines=True).split())
|
||||
outdated = set(subprocess.check_output(cmd + ['outdated', '--quiet'],
|
||||
universal_newlines=True).split())
|
||||
to_upgrade = set(package for package in packages if package in outdated)
|
||||
|
||||
if to_install or to_upgrade:
|
||||
@ -332,18 +332,19 @@ class OSXBootstrapper(BaseBootstrapper):
|
||||
def _ensure_homebrew_casks(self, casks):
|
||||
self._ensure_homebrew_found()
|
||||
|
||||
known_taps = self.check_output([self.brew, 'tap'])
|
||||
known_taps = subprocess.check_output([self.brew, 'tap'])
|
||||
|
||||
# Ensure that we can access old versions of packages.
|
||||
if b'homebrew/cask-versions' not in known_taps:
|
||||
self.check_output([self.brew, 'tap', 'homebrew/cask-versions'])
|
||||
subprocess.check_output([self.brew, 'tap',
|
||||
'homebrew/cask-versions'])
|
||||
|
||||
# "caskroom/versions" has been renamed to "homebrew/cask-versions", so
|
||||
# it is safe to remove the old tap. Removing the old tap is necessary
|
||||
# to avoid the error "Cask [name of cask] exists in multiple taps".
|
||||
# See https://bugzilla.mozilla.org/show_bug.cgi?id=1544981
|
||||
if b'caskroom/versions' in known_taps:
|
||||
self.check_output([self.brew, 'untap', 'caskroom/versions'])
|
||||
subprocess.check_output([self.brew, 'untap', 'caskroom/versions'])
|
||||
|
||||
# Change |brew install cask| into |brew cask install cask|.
|
||||
self._ensure_homebrew_packages(casks, extra_brew_args=['cask'])
|
||||
@ -415,7 +416,7 @@ class OSXBootstrapper(BaseBootstrapper):
|
||||
assert self.port is not None
|
||||
|
||||
installed = set(
|
||||
self.check_output(
|
||||
subprocess.check_output(
|
||||
[self.port, 'installed'],
|
||||
universal_newlines=True).split())
|
||||
|
||||
@ -440,7 +441,7 @@ class OSXBootstrapper(BaseBootstrapper):
|
||||
self._ensure_macports_packages(packages)
|
||||
|
||||
pythons = set(
|
||||
self.check_output(
|
||||
subprocess.check_output(
|
||||
[self.port, 'select', '--list', 'python'],
|
||||
universal_newlines=True).split('\n'))
|
||||
active = ''
|
||||
|
@ -22,6 +22,7 @@ class VoidBootstrapper(
|
||||
'make',
|
||||
'mercurial',
|
||||
'nodejs',
|
||||
'python3-pip',
|
||||
'unzip',
|
||||
'zip',
|
||||
]
|
||||
@ -54,12 +55,6 @@ class VoidBootstrapper(
|
||||
self.browser_packages = self.BROWSER_PACKAGES
|
||||
self.mobile_android_packages = self.MOBILE_ANDROID_PACKAGES
|
||||
|
||||
# Check if we need Python2 or Python3 pip.
|
||||
if sys.version_info[0] == 3:
|
||||
self.packages.append('python3-pip')
|
||||
else:
|
||||
self.packages.append('python-pip')
|
||||
|
||||
def run_as_root(self, command):
|
||||
# VoidLinux doesn't support users sudo'ing most commands by default because of the group
|
||||
# configuration.
|
||||
|
Loading…
Reference in New Issue
Block a user