formula_installer: handle unexpected .brew presence/absence
This commit is contained in:
		
							parent
							
								
									d2b1a9d831
								
							
						
					
					
						commit
						774537d3c2
					
				@ -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?
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user