2024-08-10 00:20:30 +01:00
|
|
|
# typed: strict
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
module OS
|
|
|
|
module Mac
|
|
|
|
module Bottles
|
|
|
|
module ClassMethods
|
|
|
|
sig { params(tag: T.nilable(T.any(Symbol, Utils::Bottles::Tag))).returns(Utils::Bottles::Tag) }
|
2023-04-14 15:33:40 +02:00
|
|
|
def tag(tag = nil)
|
2025-06-13 16:59:10 +01:00
|
|
|
if tag.nil?
|
|
|
|
Utils::Bottles::Tag.new(system: MacOS.version.to_sym, arch: ::Hardware::CPU.arch)
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
2023-04-14 15:33:40 +02:00
|
|
|
end
|
2016-04-25 17:57:51 +01:00
|
|
|
end
|
2023-04-14 15:33:40 +02:00
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
module Collector
|
|
|
|
extend T::Helpers
|
2016-04-25 17:57:51 +01:00
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
requires_ancestor { Utils::Bottles::Collector }
|
2016-04-25 17:57:51 +01:00
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
sig {
|
|
|
|
params(tag: Utils::Bottles::Tag,
|
|
|
|
no_older_versions: T::Boolean).returns(T.nilable(Utils::Bottles::Tag))
|
|
|
|
}
|
|
|
|
def find_matching_tag(tag, no_older_versions: false)
|
|
|
|
# Used primarily by developers testing beta macOS releases.
|
|
|
|
if no_older_versions ||
|
|
|
|
(OS::Mac.version.prerelease? &&
|
|
|
|
Homebrew::EnvConfig.developer? &&
|
|
|
|
Homebrew::EnvConfig.skip_or_later_bottles?)
|
|
|
|
super(tag)
|
|
|
|
else
|
|
|
|
super(tag) || find_older_compatible_tag(tag)
|
|
|
|
end
|
2016-04-25 17:57:51 +01:00
|
|
|
end
|
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
# Find a bottle built for a previous version of macOS.
|
|
|
|
sig { params(tag: Utils::Bottles::Tag).returns(T.nilable(Utils::Bottles::Tag)) }
|
|
|
|
def find_older_compatible_tag(tag)
|
|
|
|
tag_version = begin
|
|
|
|
tag.to_macos_version
|
|
|
|
rescue MacOSVersion::Error
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
return if tag_version.blank?
|
2020-11-10 00:11:22 +11:00
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
tags.find do |candidate|
|
|
|
|
next if candidate.standardized_arch != tag.standardized_arch
|
2020-12-09 11:55:27 +00:00
|
|
|
|
2025-06-13 16:59:10 +01:00
|
|
|
candidate.to_macos_version <= tag_version
|
|
|
|
rescue MacOSVersion::Error
|
|
|
|
false
|
|
|
|
end
|
2016-04-25 17:57:51 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2025-06-13 16:59:10 +01:00
|
|
|
|
|
|
|
Utils::Bottles.singleton_class.prepend(OS::Mac::Bottles::ClassMethods)
|
|
|
|
Utils::Bottles::Collector.prepend(OS::Mac::Bottles::Collector)
|