diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-08-25 10:50:40 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2022-09-03 15:54:07 +0900 |
commit | a9bf13a4dfaed27e485a8a3f3fd9abcd9fd163b2 (patch) | |
tree | aa84a270ff50bb09847124eee77f13287fa6ad8e /lib/rubygems | |
parent | 522b75f1b666051f86a3c8961fd4255e560c5020 (diff) |
Merge RubyGems-3.3.21 and Bundler-2.3.21
Diffstat (limited to 'lib/rubygems')
-rw-r--r-- | lib/rubygems/platform.rb | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index ed3571dbff..8c5e7993ca 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -25,7 +25,7 @@ class Gem::Platform platforms.any? do |local_platform| platform.nil? || local_platform == platform || - (local_platform != Gem::Platform::RUBY && local_platform =~ platform) + (local_platform != Gem::Platform::RUBY && platform =~ local_platform) end end private_class_method :match_platforms? @@ -70,7 +70,7 @@ class Gem::Platform when String then arch = arch.split "-" - if arch.length > 2 && arch.last !~ (/\d/) # reassemble x86-linux-gnu + if arch.length > 2 && arch.last !~ /\d+(\.\d+)?$/ # reassemble x86-linux-{libc} extra = arch.pop arch.last << "-#{extra}" end @@ -102,7 +102,7 @@ class Gem::Platform when /^dalvik(\d+)?$/ then [ "dalvik", $1 ] when /^dotnet$/ then [ "dotnet", nil ] when /^dotnet([\d.]*)/ then [ "dotnet", $1 ] - when /linux-?((?!gnu)\w+)?/ then [ "linux", $1 ] + when /linux-?(\w+)?/ then [ "linux", $1 ] when /mingw32/ then [ "mingw32", nil ] when /mingw-?(\w+)?/ then [ "mingw", $1 ] when /(mswin\d+)(\_(\d+))?/ then @@ -151,10 +151,17 @@ class Gem::Platform ## # Does +other+ match this platform? Two platforms match if they have the # same CPU, or either has a CPU of 'universal', they have the same OS, and - # they have the same version, or either has no version. + # they have the same version, or either one has no version # # Additionally, the platform will match if the local CPU is 'arm' and the # other CPU starts with "arm" (for generic ARM family support). + # + # Of note, this method is not commutative. Indeed the OS 'linux' has a + # special case: the version is the libc name, yet while "no version" stands + # as a wildcard for a binary gem platform (as for other OSes), for the + # runtime platform "no version" stands for 'gnu'. To be able to disinguish + # these, the method receiver is the gem platform, while the argument is + # the runtime platform. def ===(other) return nil unless Gem::Platform === other @@ -171,7 +178,11 @@ class Gem::Platform @os == other.os && # version - (@version.nil? || other.version.nil? || @version == other.version) + ( + (@os != "linux" && (@version.nil? || other.version.nil?)) || + (@os == "linux" && ((@version.nil? && ["gnu", "musl"].include?(other.version)) || (@version == "gnu" && other.version.nil?))) || + @version == other.version + ) end ## |