lib/bundler/rubygems_ext.rb in bundler-2.3.20 vs lib/bundler/rubygems_ext.rb in bundler-2.3.21

- old
+ new

@@ -13,10 +13,11 @@ # require, which would trigger a monitor error and cause the `autoload` to # eventually fail. A better solution is probably to completely avoid autoloading # `Gem::Source` from the redefined `Gem::Specification#source`. require "rubygems/source" +require_relative "match_metadata" require_relative "match_platform" # Cherry-pick fixes to `Gem.ruby_version` to be useful for modern Bundler # versions and ignore patchlevels # (https://github.com/rubygems/rubygems/pull/5472, @@ -26,10 +27,11 @@ Gem.instance_variable_set(:@ruby_version, Gem::Version.new(RUBY_VERSION)) end module Gem class Specification + include ::Bundler::MatchMetadata include ::Bundler::MatchPlatform attr_accessor :remote, :location, :relative_loaded_from remove_method :source @@ -233,9 +235,35 @@ MSWIN = Gem::Platform.new("mswin32") MSWIN64 = Gem::Platform.new("mswin64") MINGW = Gem::Platform.new("x86-mingw32") X64_MINGW = [Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw-ucrt")].freeze + + if Gem::Platform.new("x86_64-linux-musl") === Gem::Platform.new("x86_64-linux") + remove_method :=== + + def ===(other) + return nil unless Gem::Platform === other + + # universal-mingw32 matches x64-mingw-ucrt + return true if (@cpu == "universal" || other.cpu == "universal") && + @os.start_with?("mingw") && other.os.start_with?("mingw") + + # cpu + ([nil,"universal"].include?(@cpu) || [nil, "universal"].include?(other.cpu) || @cpu == other.cpu || + (@cpu == "arm" && other.cpu.start_with?("arm"))) && + + # os + @os == other.os && + + # 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 + end end Platform.singleton_class.module_eval do unless Platform.singleton_methods.include?(:match_spec?) def match_spec?(spec)