From 774537d3c2be6cc26dc583f0314871026a9b7bec Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Tue, 12 Apr 2022 17:34:48 -0400 Subject: [PATCH] formula_installer: handle unexpected .brew presence/absence --- Library/Homebrew/formula_cellar_checks.rb | 8 +++++--- Library/Homebrew/formula_installer.rb | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/formula_cellar_checks.rb b/Library/Homebrew/formula_cellar_checks.rb index b55ef9b7b2..46d9ac63ef 100644 --- a/Library/Homebrew/formula_cellar_checks.rb +++ b/Library/Homebrew/formula_cellar_checks.rb @@ -285,13 +285,15 @@ module FormulaCellarChecks 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? diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 288fc09eff..d2c854e3be 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -460,7 +460,7 @@ class FormulaInstaller 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)