From 268a32f0aac4e36935d8cb922bb678a524c4e925 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Fri, 29 Oct 2021 14:03:24 -0400 Subject: [PATCH 1/3] Handle `depends_on "homebrew/core/foo"` for `HOMEBREW_INSTALL_FROM_API` --- Library/Homebrew/dependency.rb | 5 +++++ Library/Homebrew/formula_installer.rb | 2 +- Library/Homebrew/formulary.rb | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index aa5375112a..79874077d5 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -44,6 +44,11 @@ class Dependency formula = Formulary.factory(name) formula.build = BuildOptions.new(options, formula.options) formula + rescue CoreTapFormulaUnavailableError + raise if !Homebrew::EnvConfig.install_from_api? || !Homebrew::API::Bottle.available?(name) + + Homebrew::API::Bottle.fetch_bottles(name) + retry end def unavailable_core_formula? diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 78aacaab5a..4c3fd9e547 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -213,7 +213,7 @@ class FormulaInstaller begin compute_dependencies rescue TapFormulaUnavailableError => e - raise if e.tap.installed? + raise if e.tap.installed? || e.tap.core_tap? e.tap.install retry diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 4696e1a708..ed492477a6 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -343,6 +343,8 @@ module Formulary rescue FormulaClassUnavailableError => e raise TapFormulaClassUnavailableError.new(tap, name, e.path, e.class_name, e.class_list), "", e.backtrace rescue FormulaUnavailableError => e + raise CoreTapFormulaUnavailableError.new(name), "", e.backtrace if tap.core_tap? + raise TapFormulaUnavailableError.new(tap, name), "", e.backtrace end From ae457a80286d168b1adf9486f74d12fad503f964 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Sat, 30 Oct 2021 23:54:01 -0400 Subject: [PATCH 2/3] Fix loading formulae from core tap --- Library/Homebrew/dependency.rb | 5 ----- Library/Homebrew/formula_installer.rb | 5 +++++ Library/Homebrew/formulary.rb | 7 +++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 79874077d5..aa5375112a 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -44,11 +44,6 @@ class Dependency formula = Formulary.factory(name) formula.build = BuildOptions.new(options, formula.options) formula - rescue CoreTapFormulaUnavailableError - raise if !Homebrew::EnvConfig.install_from_api? || !Homebrew::API::Bottle.available?(name) - - Homebrew::API::Bottle.fetch_bottles(name) - retry end def unavailable_core_formula? diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 4c3fd9e547..51dc58f2d4 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -212,6 +212,11 @@ class FormulaInstaller def verify_deps_exist begin compute_dependencies + rescue CoreTapFormulaUnavailableError => e + raise unless Homebrew::API::Bottle.available? e.name + + Homebrew::API::Bottle.fetch_bottles(e.name) + retry rescue TapFormulaUnavailableError => e raise if e.tap.installed? || e.tap.core_tap? diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index ed492477a6..768e49bb7e 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -535,6 +535,13 @@ module Formulary when URL_START_REGEX return FromUrlLoader.new(ref) when HOMEBREW_TAP_FORMULA_REGEX + # If `homebrew/core` is specified and not installed, check whether the formula is already installed. + if ref.start_with?("homebrew/core/") && !CoreTap.instance.installed? && Homebrew::EnvConfig.install_from_api? + name = ref.split("/", 3).last + possible_keg_formula = Pathname.new("#{HOMEBREW_PREFIX}/opt/#{name}/.brew/#{name}.rb") + return FormulaLoader.new(name, possible_keg_formula) if possible_keg_formula.file? + end + return TapLoader.new(ref, from: from) end From 5f4d4fb3fbfd1d52855c17468cca129fcc9a2bbf Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Sun, 31 Oct 2021 00:27:05 -0400 Subject: [PATCH 3/3] Cleanup --- Library/Homebrew/formula_installer.rb | 2 +- Library/Homebrew/formulary.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 51dc58f2d4..cab34ccc8c 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -218,7 +218,7 @@ class FormulaInstaller Homebrew::API::Bottle.fetch_bottles(e.name) retry rescue TapFormulaUnavailableError => e - raise if e.tap.installed? || e.tap.core_tap? + raise if e.tap.installed? e.tap.install retry diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 768e49bb7e..2e40aba574 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -343,7 +343,9 @@ module Formulary rescue FormulaClassUnavailableError => e raise TapFormulaClassUnavailableError.new(tap, name, e.path, e.class_name, e.class_list), "", e.backtrace rescue FormulaUnavailableError => e - raise CoreTapFormulaUnavailableError.new(name), "", e.backtrace if tap.core_tap? + if tap.core_tap? && Homebrew::EnvConfig.install_from_api? + raise CoreTapFormulaUnavailableError.new(name), "", e.backtrace + end raise TapFormulaUnavailableError.new(tap, name), "", e.backtrace end