fetch: fix --bottle-tag when unbottled on host system

This commit is contained in:
FnControlOption 2021-08-26 14:36:49 -07:00
parent 5633f49277
commit b9fc4e36f0
7 changed files with 19 additions and 16 deletions

View File

@ -159,6 +159,9 @@ module Homebrew
sig { returns(T::Boolean) } sig { returns(T::Boolean) }
def minor?; end def minor?; end
sig { returns(T.nilable(String)) }
def bottle_tag; end
sig { returns(T.nilable(String)) } sig { returns(T.nilable(String)) }
def tag; end def tag; end

View File

@ -6,7 +6,9 @@ module Utils
class << self class << self
undef tag undef tag
def tag def tag(symbol = nil)
return Utils::Bottles::Tag.from_symbol(symbol) if symbol.present?
Utils::Bottles::Tag.new(system: MacOS.version.to_sym, arch: Hardware::CPU.arch) Utils::Bottles::Tag.new(system: MacOS.version.to_sym, arch: Hardware::CPU.arch)
end end
end end

View File

@ -11,6 +11,7 @@ module Homebrew
bottle = f.bottle bottle = f.bottle
return true if args.force_bottle? && bottle.present? return true if args.force_bottle? && bottle.present?
return true if args.bottle_tag.present? && f.bottled?(args.bottle_tag)
bottle.present? && bottle.present? &&
f.pour_bottle? && f.pour_bottle? &&

View File

@ -373,7 +373,7 @@ class Formula
# @private # @private
sig { params(tag: T.nilable(String)).returns(T.nilable(Bottle)) } sig { params(tag: T.nilable(String)).returns(T.nilable(Bottle)) }
def bottle_for_tag(tag = nil) def bottle_for_tag(tag = nil)
Bottle.new(self, bottle_specification, tag) if bottled? Bottle.new(self, bottle_specification, tag) if bottled?(tag)
end end
# The description of the software. # The description of the software.

View File

@ -7,8 +7,8 @@ class Formula
def bottle_disabled?; end def bottle_disabled?; end
def bottle_disable_reason; end def bottle_disable_reason; end
def bottle_defined?; end def bottle_defined?; end
def bottle_tag?; end def bottle_tag?(tag = nil); end
def bottled?; end def bottled?(tag = nil); end
def bottle_specification; end def bottle_specification; end
def downloader; end def downloader; end

View File

@ -93,13 +93,13 @@ class SoftwareSpec
!bottle_specification.collector.keys.empty? !bottle_specification.collector.keys.empty?
end end
def bottle_tag? def bottle_tag?(tag = nil)
bottle_specification.tag?(Utils::Bottles.tag) bottle_specification.tag?(Utils::Bottles.tag(tag))
end end
def bottled? def bottled?(tag = nil)
bottle_tag? && \ bottle_tag?(tag) && \
(bottle_specification.compatible_locations? || owner.force_bottle) (tag.present? || bottle_specification.compatible_locations? || owner.force_bottle)
end end
def bottle(disable_type = nil, disable_reason = nil, &block) def bottle(disable_type = nil, disable_reason = nil, &block)
@ -306,12 +306,7 @@ class Bottle
@resource.specs[:bottle] = true @resource.specs[:bottle] = true
@spec = spec @spec = spec
bottle_tag = if tag.present? checksum, tag, cellar = spec.checksum_for(Utils::Bottles.tag(tag))
Utils::Bottles::Tag.from_symbol(tag)
else
Utils::Bottles.tag
end
checksum, tag, cellar = spec.checksum_for(bottle_tag)
@prefix = spec.prefix @prefix = spec.prefix
@tag = tag @tag = tag

View File

@ -11,7 +11,9 @@ module Utils
class << self class << self
extend T::Sig extend T::Sig
def tag def tag(symbol = nil)
return Tag.from_symbol(symbol) if symbol.present?
@tag ||= Tag.new(system: T.must(ENV["HOMEBREW_SYSTEM"]).downcase.to_sym, @tag ||= Tag.new(system: T.must(ENV["HOMEBREW_SYSTEM"]).downcase.to_sym,
arch: T.must(ENV["HOMEBREW_PROCESSOR"]).downcase.to_sym) arch: T.must(ENV["HOMEBREW_PROCESSOR"]).downcase.to_sym)
end end