Bug 1684348 - Patching error occuring while running brew cask list as this method has been deprecated by homebrew r=mhentges

Differential Revision: https://phabricator.services.mozilla.com/D100496
This commit is contained in:
ankushduacodes 2021-01-08 19:51:41 +00:00
Родитель 91041bcbe0
Коммит fd084434a1
1 изменённых файлов: 14 добавлений и 12 удалений

Просмотреть файл

@ -329,33 +329,36 @@ class OSXBootstrapper(BaseBootstrapper):
# which('brew') is found. # which('brew') is found.
assert self.brew is not None assert self.brew is not None
def _ensure_homebrew_packages(self, packages, extra_brew_args=[]): def _ensure_homebrew_packages(self, packages, is_for_cask=False):
package_type_flag = "--cask" if is_for_cask else "--formula"
self._ensure_homebrew_found() self._ensure_homebrew_found()
self._ensure_package_manager_updated() self._ensure_package_manager_updated()
cmd = [self.brew] + extra_brew_args
def create_homebrew_cmd(*parameters):
base_cmd = [self.brew]
base_cmd.extend(parameters)
return base_cmd + [package_type_flag]
installed = set( installed = set(
subprocess.check_output( subprocess.check_output(
cmd + ["list", "--formula"], universal_newlines=True create_homebrew_cmd("list"), universal_newlines=True
).split() ).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( outdated = set(
subprocess.check_output( subprocess.check_output(
cmd + ["outdated", "--quiet"], universal_newlines=True create_homebrew_cmd("outdated", "--quiet"), universal_newlines=True
).split() ).split()
) )
to_install = set(package for package in packages if package not in installed)
to_upgrade = set(package for package in packages if package in outdated) to_upgrade = set(package for package in packages if package in outdated)
if to_install or to_upgrade: if to_install or to_upgrade:
print(PACKAGE_MANAGER_PACKAGES % ("Homebrew",)) print(PACKAGE_MANAGER_PACKAGES % ("Homebrew",))
if to_install: if to_install:
subprocess.check_call(cmd + ["install"] + list(to_install)) subprocess.check_call(create_homebrew_cmd("install") + list(to_install))
if to_upgrade: if to_upgrade:
subprocess.check_call(cmd + ["upgrade"] + list(to_upgrade)) subprocess.check_call(create_homebrew_cmd("upgrade") + list(to_upgrade))
def _ensure_homebrew_casks(self, casks): def _ensure_homebrew_casks(self, casks):
self._ensure_homebrew_found() self._ensure_homebrew_found()
@ -373,8 +376,7 @@ class OSXBootstrapper(BaseBootstrapper):
if b"caskroom/versions" in known_taps: if b"caskroom/versions" in known_taps:
subprocess.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, is_for_cask=True)
self._ensure_homebrew_packages(casks, extra_brew_args=["cask"])
def ensure_homebrew_system_packages(self, install_mercurial): def ensure_homebrew_system_packages(self, install_mercurial):
packages = [ packages = [