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

ruby-changes:73811

From: David <ko1@a...>
Date: Sat, 1 Oct 2022 05:46:52 +0900 (JST)
Subject: [ruby-changes:73811] 8252ea2140 (master): [rubygems/rubygems] Fix matching of linux platforms with eabi modifiers

https://git.ruby-lang.org/ruby.git/commit/?id=8252ea2140

From 8252ea214061e1e8601ecfe178d010ed92ee8600 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 28 Sep 2022 12:12:13 +0200
Subject: [rubygems/rubygems] Fix matching of linux platforms with eabi
 modifiers

https://github.com/rubygems/rubygems/commit/89362c18ef

Co-authored-by: Mike Dalessio <mike.dalessio@g...>
---
 lib/bundler/rubygems_ext.rb        |  8 ++++----
 lib/rubygems/platform.rb           |  8 ++++----
 test/rubygems/test_gem_platform.rb | 20 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 201d2fef17..1747b7cf22 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -261,7 +261,7 @@ 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" && (normalized_linux_version_ext == other.normalized_linux_version_ext || other.version == "musl#{@version}")) ||
+            (@os == "linux" && (normalized_linux_version_ext == other.normalized_linux_version_ext || other.version == "musl#{@version}" || other.version == "musleabi#{@version}")) ||
             @version == other.version
           )
       end
@@ -271,10 +271,10 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_ext.rb#L271
       def normalized_linux_version_ext
         return nil unless @version
 
-        without_gnu = @version.sub(/\Agnu/, "")
-        return nil if without_gnu.empty?
+        without_gnu_nor_abi_modifiers = @version.sub(/\Agnu/, "").sub(/eabi\Z/, "")
+        return nil if without_gnu_nor_abi_modifiers.empty?
 
-        without_gnu
+        without_gnu_nor_abi_modifiers
       end
     end
   end
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index 1144879f9c..0935fd8971 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -181,7 +181,7 @@ 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" && (normalized_linux_version == other.normalized_linux_version || other.version == "musl#{@version}")) ||
+        (@os == "linux" && (normalized_linux_version == other.normalized_linux_version || other.version == "musl#{@version}" || other.version == "musleabi#{@version}")) ||
         @version == other.version
       )
   end
@@ -189,10 +189,10 @@ class Gem::Platform https://github.com/ruby/ruby/blob/trunk/lib/rubygems/platform.rb#L189
   def normalized_linux_version
     return nil unless @version
 
-    without_gnu = @version.sub(/\Agnu/, "")
-    return nil if without_gnu.empty?
+    without_gnu_nor_abi_modifiers = @version.sub(/\Agnu/, "").sub(/eabi\Z/, "")
+    return nil if without_gnu_nor_abi_modifiers.empty?
 
-    without_gnu
+    without_gnu_nor_abi_modifiers
   end
 
   ##
diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb
index 3bd4a862c5..03417d755a 100644
--- a/test/rubygems/test_gem_platform.rb
+++ b/test/rubygems/test_gem_platform.rb
@@ -333,6 +333,26 @@ class TestGemPlatform < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_platform.rb#L333
     refute(arm_linux_uclibceabi === arm_linux_eabi, "linux-uclibceabi =~ linux-eabi")
   end
 
+  def test_eabi_and_nil_version_combination_strictness
+    arm_linux = Gem::Platform.new "arm-linux"
+    arm_linux_eabi = Gem::Platform.new "arm-linux-eabi"
+    arm_linux_gnueabi = Gem::Platform.new "arm-linux-gnueabi"
+    arm_linux_musleabi = Gem::Platform.new "arm-linux-musleabi"
+    arm_linux_uclibceabi = Gem::Platform.new "arm-linux-uclibceabi"
+
+    # generic arm host runtime with eabi modifier accepts generic arm gems
+    assert(arm_linux === arm_linux_eabi, "arm-linux =~ arm-linux-eabi")
+
+    # explicit gnu arm host runtime with eabi modifier accepts generic arm gems
+    assert(arm_linux === arm_linux_gnueabi, "arm-linux =~ arm-linux-gnueabi")
+
+    # musl arm host runtime accepts libc-generic or statically linked gems...
+    assert(arm_linux === arm_linux_musleabi, "arm-linux =~ arm-linux-musleabi")
+
+    # other libc arm hosts are not glibc compatible
+    refute(arm_linux === arm_linux_uclibceabi, "arm-linux =~ arm-linux-uclibceabi")
+  end
+
   def test_equals3_cpu_arm
     arm   = Gem::Platform.new "arm-linux"
     armv5 = Gem::Platform.new "armv5-linux"
-- 
cgit v1.2.1


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

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