Merge pull request #13136 from EricFromCanada/reinstall-fixes

formula_installer: handle unexpected .brew presence/absence
This commit is contained in:
Mike McQuaid 2022-04-13 16:20:48 +01:00 committed by GitHub
commit 62fe3014e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -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?

View File

@ -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)