Skip to content

Commit

Permalink
formula_installer: handle unexpected .brew presence/absence
Browse files Browse the repository at this point in the history
  • Loading branch information
EricFromCanada committed Apr 13, 2022
1 parent d2b1a9d commit 774537d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Library/Homebrew/formula_cellar_checks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,15 @@ def check_service_command(formula)
end

def check_cpuid_instruction(formula)
return unless formula.prefix.directory?
# TODO: add methods to `utils/ast` to allow checking for method use
return unless (formula.prefix/".brew/#{formula.name}.rb").read.include? "ENV.runtime_cpu_detection"
# Checking for `cpuid` only makes sense on Intel:
# https://en.wikipedia.org/wiki/CPUID
return unless Hardware::CPU.intel?

dot_brew_formula = formula.prefix/".brew/#{formula.name}.rb"
return unless dot_brew_formula.exist?
# TODO: add methods to `utils/ast` to allow checking for method use
return unless dot_brew_formula.read.include? "ENV.runtime_cpu_detection"

# macOS `objdump` is a bit slow, so we prioritise llvm's `llvm-objdump` (~5.7x faster)
# or binutils' `objdump` (~1.8x faster) if they are installed.
objdump = Formula["llvm"].opt_bin/"llvm-objdump" if Formula["llvm"].any_version_installed?
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def install
end
s = formula_contents.gsub(/ bottle do.+?end\n\n?/m, "")
brew_prefix = formula.prefix/".brew"
brew_prefix.mkdir
brew_prefix.mkpath
Pathname(brew_prefix/"#{formula.name}.rb").atomic_write(s)

keg = Keg.new(formula.prefix)
Expand Down

0 comments on commit 774537d

Please sign in to comment.