Handle macOS versions >= 11.1 correctly.
This commit is contained in:
parent
1ba26be103
commit
8598b1186a
@ -7,7 +7,7 @@ module Stdenv
|
||||
undef homebrew_extra_pkg_config_paths, x11
|
||||
|
||||
def homebrew_extra_pkg_config_paths
|
||||
["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
|
||||
["#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.sdk_version}"]
|
||||
end
|
||||
|
||||
def x11
|
||||
|
||||
@ -34,7 +34,7 @@ module Superenv
|
||||
# @private
|
||||
def homebrew_extra_pkg_config_paths
|
||||
paths = \
|
||||
["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.version}"]
|
||||
["/usr/lib/pkgconfig", "#{HOMEBREW_LIBRARY}/Homebrew/os/mac/pkgconfig/#{MacOS.sdk_version}"]
|
||||
paths << "#{MacOS::XQuartz.lib}/pkgconfig" << "#{MacOS::XQuartz.share}/pkgconfig" if x11?
|
||||
paths
|
||||
end
|
||||
|
||||
@ -25,7 +25,7 @@ module OS
|
||||
# This can be compared to numerics, strings, or symbols
|
||||
# using the standard Ruby Comparable methods.
|
||||
def version
|
||||
@version ||= Version.new(full_version.to_s[/^\d+\.\d+/])
|
||||
@version ||= Version.from_symbol(full_version.to_sym)
|
||||
end
|
||||
|
||||
# This can be compared to numerics, strings, or symbols
|
||||
@ -39,9 +39,16 @@ module OS
|
||||
@version = nil
|
||||
end
|
||||
|
||||
sig { returns(::Version) }
|
||||
def latest_sdk_version
|
||||
# TODO: bump version when new Xcode macOS SDK is released
|
||||
Version.new "11.0"
|
||||
::Version.new("11.0")
|
||||
end
|
||||
private :latest_sdk_version
|
||||
|
||||
sig { returns(::Version) }
|
||||
def sdk_version
|
||||
full_version.major_minor
|
||||
end
|
||||
|
||||
def outdated_release?
|
||||
@ -55,7 +62,7 @@ module OS
|
||||
# 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.0"
|
||||
version >= "12"
|
||||
end
|
||||
|
||||
def languages
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "exceptions"
|
||||
require "hardware"
|
||||
require "version"
|
||||
|
||||
@ -10,8 +11,10 @@ module OS
|
||||
#
|
||||
# @api private
|
||||
class Version < ::Version
|
||||
extend T::Sig
|
||||
|
||||
SYMBOLS = {
|
||||
big_sur: "11.0",
|
||||
big_sur: "11",
|
||||
catalina: "10.15",
|
||||
mojave: "10.14",
|
||||
high_sierra: "10.13",
|
||||
@ -20,35 +23,44 @@ module OS
|
||||
yosemite: "10.10",
|
||||
}.freeze
|
||||
|
||||
sig { params(sym: Symbol).returns(T.attached_class) }
|
||||
def self.from_symbol(sym)
|
||||
str = SYMBOLS.fetch(sym) { raise MacOSVersionError, sym }
|
||||
new(str)
|
||||
end
|
||||
|
||||
sig { params(value: T.nilable(String)).void }
|
||||
def initialize(value)
|
||||
super(value)
|
||||
raise MacOSVersionError, value unless /\A1\d+(?:\.\d+){0,2}\Z/.match?(value)
|
||||
|
||||
raise MacOSVersionError, value unless value.match?(/\A1\d+(?:\.\d+){0,2}\Z/)
|
||||
super(value)
|
||||
|
||||
@comparison_cache = {}
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
@comparison_cache.fetch(other) do
|
||||
v = SYMBOLS.fetch(other) { other.to_s }
|
||||
@comparison_cache[other] = super(::Version.new(v))
|
||||
if SYMBOLS.key?(other) && to_sym == other
|
||||
0
|
||||
else
|
||||
v = SYMBOLS.fetch(other) { other.to_s }
|
||||
@comparison_cache[other] = super(::Version.new(v))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sig { returns(Symbol) }
|
||||
def to_sym
|
||||
SYMBOLS.invert.fetch(@version, :dunno)
|
||||
@to_sym ||= SYMBOLS.invert.fetch((major >= 11 ? major : major_minor).to_s, :dunno)
|
||||
end
|
||||
|
||||
sig { returns(String) }
|
||||
def pretty_name
|
||||
to_sym.to_s.split("_").map(&:capitalize).join(" ")
|
||||
@pretty_name ||= to_sym.to_s.split("_").map(&:capitalize).join(" ").freeze
|
||||
end
|
||||
|
||||
# For {OS::Mac::Version} compatibility.
|
||||
sig { returns(T::Boolean) }
|
||||
def requires_nehalem_cpu?
|
||||
unless Hardware::CPU.intel?
|
||||
raise "Unexpected architecture: #{Hardware::CPU.arch}. This only works with Intel architecture."
|
||||
|
||||
@ -22,7 +22,7 @@ module OS
|
||||
def latest_version
|
||||
latest_stable = "12.2"
|
||||
case MacOS.version
|
||||
when /^11\./ then latest_stable
|
||||
when "11" then latest_stable
|
||||
when "10.15" then "12.2"
|
||||
when "10.14" then "11.3.1"
|
||||
when "10.13" then "10.1"
|
||||
@ -45,7 +45,7 @@ module OS
|
||||
sig { returns(String) }
|
||||
def minimum_version
|
||||
case MacOS.version
|
||||
when /^11\./ then "12.2"
|
||||
when "11" then "12.2"
|
||||
when "10.15" then "11.0"
|
||||
when "10.14" then "10.2"
|
||||
when "10.13" then "9.0"
|
||||
@ -54,28 +54,33 @@ module OS
|
||||
end
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def below_minimum_version?
|
||||
return false unless installed?
|
||||
|
||||
version < minimum_version
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def latest_sdk_version?
|
||||
OS::Mac.version >= OS::Mac.latest_sdk_version
|
||||
OS::Mac.full_version >= OS::Mac.latest_sdk_version
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def needs_clt_installed?
|
||||
return false if latest_sdk_version?
|
||||
|
||||
without_clt?
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def outdated?
|
||||
return false unless installed?
|
||||
|
||||
version < latest_version
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def without_clt?
|
||||
!MacOS::CLT.installed?
|
||||
end
|
||||
@ -275,7 +280,7 @@ module OS
|
||||
sig { returns(String) }
|
||||
def latest_clang_version
|
||||
case MacOS.version
|
||||
when /^11\./, "10.15" then "1200.0.32.27"
|
||||
when "11", "10.15" then "1200.0.32.27"
|
||||
when "10.14" then "1100.0.33.17"
|
||||
when "10.13" then "1000.10.44.2"
|
||||
when "10.12" then "900.0.39.2"
|
||||
@ -291,7 +296,7 @@ module OS
|
||||
sig { returns(String) }
|
||||
def minimum_version
|
||||
case MacOS.version
|
||||
when /^11\./ then "12.0.0"
|
||||
when "11" then "12.0.0"
|
||||
when "10.15" then "11.0.0"
|
||||
when "10.14" then "10.0.0"
|
||||
when "10.13" then "9.0.0"
|
||||
|
||||
@ -6,7 +6,7 @@ HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-.@]+)$}.freeze
|
||||
# Match taps' casks, e.g. `someuser/sometap/somecask`
|
||||
HOMEBREW_TAP_CASK_REGEX = %r{^([\w-]+)/([\w-]+)/([a-z0-9\-]+)$}.freeze
|
||||
# Match taps' directory paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap`
|
||||
HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY)}/Taps/(?<user>[\w-]+)/(?<repo>[\w-]+)}.freeze
|
||||
HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/(?<user>[\w-]+)/(?<repo>[\w-]+)}.freeze
|
||||
# Match taps' formula paths, e.g. `HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula`
|
||||
HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{(?:/.*)?$}.source).freeze
|
||||
# Match official taps' casks, e.g. `homebrew/cask/somecask or homebrew/cask-versions/somecask`
|
||||
|
||||
@ -6,7 +6,10 @@ require "diagnostic"
|
||||
describe Homebrew::Diagnostic::Checks do
|
||||
specify "#check_for_unsupported_macos" do
|
||||
ENV.delete("HOMEBREW_DEVELOPER")
|
||||
allow(OS::Mac).to receive(:version).and_return(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(:full_version).and_return(macos_version)
|
||||
allow(OS::Mac).to receive(:prerelease?).and_return(true)
|
||||
|
||||
expect(subject.check_for_unsupported_macos)
|
||||
@ -14,17 +17,21 @@ describe Homebrew::Diagnostic::Checks do
|
||||
end
|
||||
|
||||
specify "#check_if_xcode_needs_clt_installed" do
|
||||
allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.11"))
|
||||
allow(MacOS::Xcode).to receive(:installed?).and_return(true)
|
||||
allow(MacOS::Xcode).to receive(:version).and_return("8.0")
|
||||
allow(MacOS::Xcode).to receive(:without_clt?).and_return(true)
|
||||
macos_version = OS::Mac::Version.new("10.11")
|
||||
allow(OS::Mac).to receive(:version).and_return(macos_version)
|
||||
allow(OS::Mac).to receive(:full_version).and_return(macos_version)
|
||||
allow(OS::Mac::Xcode).to receive(:installed?).and_return(true)
|
||||
allow(OS::Mac::Xcode).to receive(:version).and_return("8.0")
|
||||
allow(OS::Mac::Xcode).to receive(:without_clt?).and_return(true)
|
||||
|
||||
expect(subject.check_if_xcode_needs_clt_installed)
|
||||
.to match("Xcode alone is not sufficient on El Capitan")
|
||||
end
|
||||
|
||||
specify "#check_ruby_version" do
|
||||
allow(MacOS).to receive(:version).and_return(OS::Mac::Version.new("10.12"))
|
||||
macos_version = OS::Mac::Version.new("10.12")
|
||||
allow(OS::Mac).to receive(:version).and_return(macos_version)
|
||||
allow(OS::Mac).to receive(:full_version).and_return(macos_version)
|
||||
stub_const("RUBY_VERSION", "1.8.6")
|
||||
|
||||
expect(subject.check_ruby_version)
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
# For indeterminable cases, consult https://opensource.apple.com for the version used.
|
||||
describe "pkg-config" do
|
||||
def pc_version(library)
|
||||
path = HOMEBREW_LIBRARY_PATH/"os/mac/pkgconfig/#{MacOS.version}/#{library}.pc"
|
||||
path = HOMEBREW_LIBRARY_PATH/"os/mac/pkgconfig/#{MacOS.sdk_version}/#{library}.pc"
|
||||
version = File.foreach(path)
|
||||
.lazy
|
||||
.grep(/^Version:\s*?(.+)$/) { Regexp.last_match(1) }
|
||||
|
||||
@ -5,7 +5,9 @@ require "version"
|
||||
require "os/mac/version"
|
||||
|
||||
describe OS::Mac::Version do
|
||||
subject(:version) { described_class.new("10.14") }
|
||||
let(:version) { described_class.new("10.14") }
|
||||
let(:big_sur_major) { described_class.new("11.0") }
|
||||
let(:big_sur_update) { described_class.new("11.1") }
|
||||
|
||||
specify "comparison with Symbol" do
|
||||
expect(version).to be > :high_sierra
|
||||
@ -38,6 +40,22 @@ describe OS::Mac::Version do
|
||||
expect(version).to be < Version.create("10.15")
|
||||
end
|
||||
|
||||
context "after Big Sur" do
|
||||
specify "comparison with :big_sur" do
|
||||
expect(big_sur_major).to eq :big_sur
|
||||
expect(big_sur_major).to be <= :big_sur
|
||||
expect(big_sur_major).to be >= :big_sur
|
||||
expect(big_sur_major).not_to be > :big_sur
|
||||
expect(big_sur_major).not_to be < :big_sur
|
||||
|
||||
expect(big_sur_update).to eq :big_sur
|
||||
expect(big_sur_update).to be <= :big_sur
|
||||
expect(big_sur_update).to be >= :big_sur
|
||||
expect(big_sur_update).not_to be > :big_sur
|
||||
expect(big_sur_update).not_to be < :big_sur
|
||||
end
|
||||
end
|
||||
|
||||
describe "#new" do
|
||||
it "raises an error if the version is not a valid macOS version" do
|
||||
expect {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# typed: false
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "context"
|
||||
require "erb"
|
||||
|
||||
module Utils
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user