aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/formulary.rb16
-rw-r--r--Library/Homebrew/os/mac/linkage_checker.rb4
2 files changed, 13 insertions, 7 deletions
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index c53262db9..e4b11b664 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -219,10 +219,18 @@ class Formulary
# It will auto resolve formula's spec when requested spec is nil
def self.from_rack(rack, spec = nil)
kegs = rack.directory? ? rack.subdirs.map { |d| Keg.new(d) } : []
-
keg = kegs.detect(&:linked?) || kegs.detect(&:optlinked?) || kegs.max_by(&:version)
- return factory(rack.basename.to_s, spec || :stable) unless keg
+ if keg
+ from_keg(keg, spec)
+ else
+ factory(rack.basename.to_s, spec || :stable)
+ end
+ end
+
+ # Return a Formula instance for the given keg.
+ # It will auto resolve formula's spec when requested spec is nil
+ def self.from_keg(keg, spec = nil)
tab = Tab.for_keg(keg)
tap = tab.tap
spec ||= tab.spec
@@ -231,10 +239,10 @@ class Formulary
factory(rack.basename.to_s, spec)
else
begin
- factory("#{tap}/#{rack.basename}", spec)
+ factory("#{tap}/#{keg.rack.basename}", spec)
rescue FormulaUnavailableError
# formula may be migrated to different tap. Try to search in core and all taps.
- factory(rack.basename.to_s, spec)
+ factory(keg.rack.basename.to_s, spec)
end
end
f.build = tab
diff --git a/Library/Homebrew/os/mac/linkage_checker.rb b/Library/Homebrew/os/mac/linkage_checker.rb
index 590aaed23..8bf092323 100644
--- a/Library/Homebrew/os/mac/linkage_checker.rb
+++ b/Library/Homebrew/os/mac/linkage_checker.rb
@@ -129,9 +129,7 @@ class LinkageChecker
end
def resolve_formula(keg)
- f = Formulary.from_rack(keg.rack)
- f.build = Tab.for_keg(keg)
- f
+ Formulary.from_keg(keg)
rescue FormulaUnavailableError
opoo "Formula unavailable: #{keg.name}"
end