[前][次][番号順一覧][スレッド一覧]

ruby-changes:73810

From: David <ko1@a...>
Date: Sat, 1 Oct 2022 05:46:51 +0900 (JST)
Subject: [ruby-changes:73810] 4d58ee3de0 (master): [rubygems/rubygems] Refactor platform matching on Linux

https://git.ruby-lang.org/ruby.git/commit/?id=4d58ee3de0

From 4d58ee3de0ecf8a3b3201359f3c593142cf92d7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 28 Sep 2022 10:57:54 +0200
Subject: [rubygems/rubygems] Refactor platform matching on Linux

I think this highlights better how musl is special.

https://github.com/rubygems/rubygems/commit/4075771697
---
 lib/bundler/rubygems_ext.rb | 13 ++++++++++++-
 lib/rubygems/platform.rb    | 11 ++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 8b46d7ece4..201d2fef17 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -261,10 +261,21 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_ext.rb#L261
           # version
           (
             (@os != "linux" && (@version.nil? || other.version.nil?)) ||
-            (@os == "linux" && (other.version == "gnu#{@version}" || other.version == "musl#{@version}" || @version == "gnu#{other.version}")) ||
+            (@os == "linux" && (normalized_linux_version_ext == other.normalized_linux_version_ext || other.version == "musl#{@version}")) ||
             @version == other.version
           )
       end
+
+      # This is a copy of RubyGems 3.3.23 or higher `normalized_linux_method`.
+      # Once only 3.3.23 is supported, we can use the method in RubyGems.
+      def normalized_linux_version_ext
+        return nil unless @version
+
+        without_gnu = @version.sub(/\Agnu/, "")
+        return nil if without_gnu.empty?
+
+        without_gnu
+      end
     end
   end
 
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index 1dacc596c4..1144879f9c 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -181,11 +181,20 @@ class Gem::Platform https://github.com/ruby/ruby/blob/trunk/lib/rubygems/platform.rb#L181
       # version
       (
         (@os != "linux" && (@version.nil? || other.version.nil?)) ||
-        (@os == "linux" && (other.version == "gnu#{@version}" || other.version == "musl#{@version}" || @version == "gnu#{other.version}")) ||
+        (@os == "linux" && (normalized_linux_version == other.normalized_linux_version || other.version == "musl#{@version}")) ||
         @version == other.version
       )
   end
 
+  def normalized_linux_version
+    return nil unless @version
+
+    without_gnu = @version.sub(/\Agnu/, "")
+    return nil if without_gnu.empty?
+
+    without_gnu
+  end
+
   ##
   # Does +other+ match this platform?  If +other+ is a String it will be
   # converted to a Gem::Platform first.  See #=== for matching rules.
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]