OS::Mac: Move version methods into ::Version
This commit is contained in:
parent
41803ebf93
commit
0752d25125
@ -107,9 +107,9 @@ module Homebrew
|
|||||||
return if Homebrew::EnvConfig.developer?
|
return if Homebrew::EnvConfig.developer?
|
||||||
|
|
||||||
who = +"We"
|
who = +"We"
|
||||||
what = if OS::Mac.prerelease?
|
what = if OS::Mac.version.prerelease?
|
||||||
"pre-release version"
|
"pre-release version"
|
||||||
elsif OS::Mac.outdated_release?
|
elsif OS::Mac.version.outdated_release?
|
||||||
who << " (and Apple)"
|
who << " (and Apple)"
|
||||||
"old version"
|
"old version"
|
||||||
end
|
end
|
||||||
@ -139,7 +139,7 @@ module Homebrew
|
|||||||
#{MacOS::Xcode.update_instructions}
|
#{MacOS::Xcode.update_instructions}
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
if OS::Mac.prerelease?
|
if OS::Mac.version.prerelease?
|
||||||
current_path = Utils.popen_read("/usr/bin/xcode-select", "-p")
|
current_path = Utils.popen_read("/usr/bin/xcode-select", "-p")
|
||||||
message += <<~EOS
|
message += <<~EOS
|
||||||
If #{MacOS::Xcode.latest_version} is installed, you may need to:
|
If #{MacOS::Xcode.latest_version} is installed, you may need to:
|
||||||
@ -199,7 +199,7 @@ module Homebrew
|
|||||||
|
|
||||||
def check_ruby_version
|
def check_ruby_version
|
||||||
return if RUBY_VERSION == HOMEBREW_REQUIRED_RUBY_VERSION
|
return if RUBY_VERSION == HOMEBREW_REQUIRED_RUBY_VERSION
|
||||||
return if Homebrew::EnvConfig.developer? && OS::Mac.prerelease?
|
return if Homebrew::EnvConfig.developer? && OS::Mac.version.prerelease?
|
||||||
|
|
||||||
<<~EOS
|
<<~EOS
|
||||||
Ruby version #{RUBY_VERSION} is unsupported on #{MacOS.version}. Homebrew
|
Ruby version #{RUBY_VERSION} is unsupported on #{MacOS.version}. Homebrew
|
||||||
|
@ -19,7 +19,9 @@ module Utils
|
|||||||
def find_matching_tag(tag, no_older_versions: false)
|
def find_matching_tag(tag, no_older_versions: false)
|
||||||
# Used primarily by developers testing beta macOS releases.
|
# Used primarily by developers testing beta macOS releases.
|
||||||
if no_older_versions ||
|
if no_older_versions ||
|
||||||
(OS::Mac.prerelease? && Homebrew::EnvConfig.developer? && Homebrew::EnvConfig.skip_or_later_bottles?)
|
(OS::Mac.version.prerelease? &&
|
||||||
|
Homebrew::EnvConfig.developer? &&
|
||||||
|
Homebrew::EnvConfig.skip_or_later_bottles?)
|
||||||
generic_find_matching_tag(tag)
|
generic_find_matching_tag(tag)
|
||||||
else
|
else
|
||||||
generic_find_matching_tag(tag) ||
|
generic_find_matching_tag(tag) ||
|
||||||
|
@ -246,7 +246,7 @@ class FormulaInstaller
|
|||||||
# check fails)
|
# check fails)
|
||||||
elsif !Homebrew::EnvConfig.developer? &&
|
elsif !Homebrew::EnvConfig.developer? &&
|
||||||
(!installed_as_dependency? || !formula.any_version_installed?) &&
|
(!installed_as_dependency? || !formula.any_version_installed?) &&
|
||||||
(!OS.mac? || !OS::Mac.outdated_release?)
|
(!OS.mac? || !OS::Mac.version.outdated_release?)
|
||||||
<<~EOS
|
<<~EOS
|
||||||
#{formula}: no bottle available!
|
#{formula}: no bottle available!
|
||||||
EOS
|
EOS
|
||||||
|
@ -43,8 +43,8 @@ module OS
|
|||||||
if OS.mac?
|
if OS.mac?
|
||||||
require "os/mac"
|
require "os/mac"
|
||||||
# Don't tell people to report issues on unsupported configurations.
|
# Don't tell people to report issues on unsupported configurations.
|
||||||
if !OS::Mac.prerelease? &&
|
if !OS::Mac.version.prerelease? &&
|
||||||
!OS::Mac.outdated_release? &&
|
!OS::Mac.version.outdated_release? &&
|
||||||
ARGV.none? { |v| v.start_with?("--cc=") } &&
|
ARGV.none? { |v| v.start_with?("--cc=") } &&
|
||||||
ENV["HOMEBREW_PREFIX"] == "/usr/local"
|
ENV["HOMEBREW_PREFIX"] == "/usr/local"
|
||||||
ISSUES_URL = "https://docs.brew.sh/Troubleshooting"
|
ISSUES_URL = "https://docs.brew.sh/Troubleshooting"
|
||||||
|
@ -46,20 +46,6 @@ module OS
|
|||||||
end
|
end
|
||||||
private :latest_sdk_version
|
private :latest_sdk_version
|
||||||
|
|
||||||
def outdated_release?
|
|
||||||
# TODO: bump version when new macOS is released and also update
|
|
||||||
# references in docs/Installation.md and
|
|
||||||
# https://github.com/Homebrew/install/blob/HEAD/install.sh
|
|
||||||
version < "10.14"
|
|
||||||
end
|
|
||||||
|
|
||||||
def prerelease?
|
|
||||||
# TODO: bump version when new macOS is released or announced
|
|
||||||
# and also update references in docs/Installation.md and
|
|
||||||
# https://github.com/Homebrew/install/blob/HEAD/install.sh
|
|
||||||
version >= "12"
|
|
||||||
end
|
|
||||||
|
|
||||||
sig { returns(String) }
|
sig { returns(String) }
|
||||||
def preferred_perl_version
|
def preferred_perl_version
|
||||||
if version >= :big_sur
|
if version >= :big_sur
|
||||||
|
@ -24,6 +24,18 @@ module OS
|
|||||||
yosemite: "10.10",
|
yosemite: "10.10",
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
# TODO: bump version when new macOS is released or announced
|
||||||
|
# and also update references in docs/Installation.md and
|
||||||
|
# https://github.com/Homebrew/install/blob/HEAD/install.sh
|
||||||
|
MACOS_NEWEST_UNSUPPORTED = "12.0"
|
||||||
|
private_constant :MACOS_NEWEST_UNSUPPORTED
|
||||||
|
|
||||||
|
# TODO: bump version when new macOS is released and also update
|
||||||
|
# references in docs/Installation.md and
|
||||||
|
# https://github.com/Homebrew/install/blob/HEAD/install.sh
|
||||||
|
MACOS_OLDEST_SUPPORTED = "10.14"
|
||||||
|
private_constant :MACOS_OLDEST_SUPPORTED
|
||||||
|
|
||||||
sig { params(version: Symbol).returns(T.attached_class) }
|
sig { params(version: Symbol).returns(T.attached_class) }
|
||||||
def self.from_symbol(version)
|
def self.from_symbol(version)
|
||||||
str = SYMBOLS.fetch(version) { raise MacOSVersionError, version }
|
str = SYMBOLS.fetch(version) { raise MacOSVersionError, version }
|
||||||
@ -73,6 +85,16 @@ module OS
|
|||||||
@pretty_name ||= to_sym.to_s.split("_").map(&:capitalize).join(" ").freeze
|
@pretty_name ||= to_sym.to_s.split("_").map(&:capitalize).join(" ").freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def outdated_release?
|
||||||
|
self < MACOS_OLDEST_SUPPORTED
|
||||||
|
end
|
||||||
|
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def prerelease?
|
||||||
|
self >= MACOS_NEWEST_UNSUPPORTED
|
||||||
|
end
|
||||||
|
|
||||||
# For {OS::Mac::Version} compatibility.
|
# For {OS::Mac::Version} compatibility.
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def requires_nehalem_cpu?
|
def requires_nehalem_cpu?
|
||||||
|
@ -32,7 +32,7 @@ module OS
|
|||||||
when "10.10" then "7.2.1"
|
when "10.10" then "7.2.1"
|
||||||
when "10.9" then "6.2"
|
when "10.9" then "6.2"
|
||||||
else
|
else
|
||||||
raise "macOS '#{MacOS.version}' is invalid" unless OS::Mac.prerelease?
|
raise "macOS '#{MacOS.version}' is invalid" unless OS::Mac.version.prerelease?
|
||||||
|
|
||||||
# Default to newest known version of Xcode for unreleased macOS versions.
|
# Default to newest known version of Xcode for unreleased macOS versions.
|
||||||
latest_stable
|
latest_stable
|
||||||
@ -137,7 +137,7 @@ module OS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def installation_instructions
|
def installation_instructions
|
||||||
if OS::Mac.prerelease?
|
if OS::Mac.version.prerelease?
|
||||||
<<~EOS
|
<<~EOS
|
||||||
Xcode can be installed from:
|
Xcode can be installed from:
|
||||||
#{Formatter.url("https://developer.apple.com/download/more/")}
|
#{Formatter.url("https://developer.apple.com/download/more/")}
|
||||||
@ -151,7 +151,7 @@ module OS
|
|||||||
|
|
||||||
sig { returns(String) }
|
sig { returns(String) }
|
||||||
def update_instructions
|
def update_instructions
|
||||||
if OS::Mac.prerelease?
|
if OS::Mac.version.prerelease?
|
||||||
<<~EOS
|
<<~EOS
|
||||||
Xcode can be updated from:
|
Xcode can be updated from:
|
||||||
#{Formatter.url("https://developer.apple.com/download/more/")}
|
#{Formatter.url("https://developer.apple.com/download/more/")}
|
||||||
|
@ -12,7 +12,8 @@ describe Homebrew::Diagnostic::Checks do
|
|||||||
macos_version = OS::Mac::Version.new("10.14")
|
macos_version = OS::Mac::Version.new("10.14")
|
||||||
allow(OS::Mac).to receive(:version).and_return(macos_version)
|
allow(OS::Mac).to receive(:version).and_return(macos_version)
|
||||||
allow(OS::Mac).to receive(:full_version).and_return(macos_version)
|
allow(OS::Mac).to receive(:full_version).and_return(macos_version)
|
||||||
allow(OS::Mac).to receive(:prerelease?).and_return(true)
|
allow(OS::Mac.version).to receive(:outdated_release?).and_return(false)
|
||||||
|
allow(OS::Mac.version).to receive(:prerelease?).and_return(true)
|
||||||
|
|
||||||
expect(checks.check_for_unsupported_macos)
|
expect(checks.check_for_unsupported_macos)
|
||||||
.to match("We do not provide support for this pre-release version.")
|
.to match("We do not provide support for this pre-release version.")
|
||||||
|
@ -31,7 +31,7 @@ describe Utils::Bottles::Collector do
|
|||||||
it "does not use older tags when requested not to", :needs_macos do
|
it "does not use older tags when requested not to", :needs_macos do
|
||||||
allow(Homebrew::EnvConfig).to receive(:developer?).and_return(true)
|
allow(Homebrew::EnvConfig).to receive(:developer?).and_return(true)
|
||||||
allow(Homebrew::EnvConfig).to receive(:skip_or_later_bottles?).and_return(true)
|
allow(Homebrew::EnvConfig).to receive(:skip_or_later_bottles?).and_return(true)
|
||||||
allow(OS::Mac).to receive(:prerelease?).and_return(true)
|
allow(OS::Mac.version).to receive(:prerelease?).and_return(true)
|
||||||
collector[:mojave] = "foo"
|
collector[:mojave] = "foo"
|
||||||
expect(collector.send(:find_matching_tag, Utils::Bottles::Tag.from_symbol(:mojave))).to eq(:mojave)
|
expect(collector.send(:find_matching_tag, Utils::Bottles::Tag.from_symbol(:mojave))).to eq(:mojave)
|
||||||
expect(collector.send(:find_matching_tag, Utils::Bottles::Tag.from_symbol(:catalina))).to be_nil
|
expect(collector.send(:find_matching_tag, Utils::Bottles::Tag.from_symbol(:catalina))).to be_nil
|
||||||
@ -39,7 +39,7 @@ describe Utils::Bottles::Collector do
|
|||||||
|
|
||||||
it "ignores HOMEBREW_SKIP_OR_LATER_BOTTLES on release versions", :needs_macos do
|
it "ignores HOMEBREW_SKIP_OR_LATER_BOTTLES on release versions", :needs_macos do
|
||||||
allow(Homebrew::EnvConfig).to receive(:skip_or_later_bottles?).and_return(true)
|
allow(Homebrew::EnvConfig).to receive(:skip_or_later_bottles?).and_return(true)
|
||||||
allow(OS::Mac).to receive(:prerelease?).and_return(false)
|
allow(OS::Mac.version).to receive(:prerelease?).and_return(false)
|
||||||
collector[:mojave] = "foo"
|
collector[:mojave] = "foo"
|
||||||
expect(collector.send(:find_matching_tag, Utils::Bottles::Tag.from_symbol(:mojave))).to eq(:mojave)
|
expect(collector.send(:find_matching_tag, Utils::Bottles::Tag.from_symbol(:mojave))).to eq(:mojave)
|
||||||
expect(collector.send(:find_matching_tag, Utils::Bottles::Tag.from_symbol(:catalina))).to eq(:mojave)
|
expect(collector.send(:find_matching_tag, Utils::Bottles::Tag.from_symbol(:catalina))).to eq(:mojave)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user