Merge pull request #9064 from MikeMcQuaid/force-bottle

formula_installer: improve --force-bottle behaviour.
This commit is contained in:
Mike McQuaid 2020-11-06 13:15:40 +00:00 committed by GitHub
commit ebe5a83b1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View File

@ -105,10 +105,6 @@ class Formula
# @private
attr_reader :tap
# Whether or not to force the use of a bottle.
# @private
attr_reader :force_bottle
# The stable (and default) {SoftwareSpec} for this {Formula}.
# This contains all the attributes (e.g. URL, checksum) that apply to the
# stable version of this formula.
@ -187,6 +183,11 @@ class Formula
alias follow_installed_alias? follow_installed_alias
# Whether or not to force the use of a bottle.
# @return [Boolean]
# @private
attr_accessor :force_bottle
# @private
def initialize(name, path, spec, alias_path: nil, force_bottle: false)
@name = name

View File

@ -70,7 +70,8 @@ class FormulaInstaller
@build_from_source_formulae = build_from_source_formulae
@build_bottle = false
@bottle_arch = nil
@force_bottle = force_bottle
@formula.force_bottle ||= force_bottle
@force_bottle = @formula.force_bottle
@include_test_formulae = include_test_formulae
@interactive = false
@git = false
@ -205,6 +206,10 @@ class FormulaInstaller
def check_install_sanity
raise FormulaInstallationAlreadyAttemptedError, formula if self.class.attempted.include?(formula)
if force_bottle? && !pour_bottle?
raise CannotInstallFormulaError, "--force-bottle passed but #{formula.full_name} has no bottle!"
end
type, reason = DeprecateDisable.deprecate_disable_info formula
if type.present?
@ -217,10 +222,10 @@ class FormulaInstaller
end
when :disabled
if reason.present?
odie "#{formula.full_name} has been disabled because it #{reason}!"
else
odie "#{formula.full_name} has been disabled!"
raise CannotInstallFormulaError, "#{formula.full_name} has been disabled because it #{reason}!"
end
raise CannotInstallFormulaError, "#{formula.full_name} has been disabled!"
end
end
@ -328,7 +333,7 @@ class FormulaInstaller
return if only_deps?
if build_bottle? && (arch = bottle_arch) && !Hardware::CPU.optimization_flags.include?(arch.to_sym)
raise "Unrecognized architecture for --bottle-arch: #{arch}"
raise CannotInstallFormulaError, "Unrecognized architecture for --bottle-arch: #{arch}"
end
formula.deprecated_flags.each do |deprecated_option|
@ -367,6 +372,7 @@ class FormulaInstaller
end
raise if Homebrew::EnvConfig.developer? ||
Homebrew::EnvConfig.no_bottle_source_fallback? ||
force_bottle? ||
e.is_a?(Interrupt)
@pour_failed = true
@ -1035,6 +1041,7 @@ class FormulaInstaller
rescue Exception => e # rubocop:disable Lint/RescueException
raise if Homebrew::EnvConfig.developer? ||
Homebrew::EnvConfig.no_bottle_source_fallback? ||
force_bottle? ||
e.is_a?(Interrupt)
@pour_failed = true