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) }
def minor?; end
sig { returns(T.nilable(String)) }
def bottle_tag; end
sig { returns(T.nilable(String)) }
def tag; end

View File

@ -6,7 +6,9 @@ module Utils
class << self
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)
end
end

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,9 @@ module Utils
class << self
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,
arch: T.must(ENV["HOMEBREW_PROCESSOR"]).downcase.to_sym)
end