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

ruby-changes:71697

From: Hiroshi <ko1@a...>
Date: Tue, 12 Apr 2022 14:07:45 +0900 (JST)
Subject: [ruby-changes:71697] 48be8051ef (ruby_3_0): Merge RubyGems-3.2.33

https://git.ruby-lang.org/ruby.git/commit/?id=48be8051ef

From 48be8051ef26dd93e714846d94a2c3794c5b101b Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Mon, 11 Apr 2022 19:45:23 +0900
Subject: Merge RubyGems-3.2.33

---
 lib/rubygems.rb                                  | 10 ++---
 lib/rubygems/command_manager.rb                  |  4 +-
 lib/rubygems/commands/pristine_command.rb        | 10 ++++-
 lib/rubygems/commands/setup_command.rb           | 23 +++++++---
 lib/rubygems/exceptions.rb                       |  1 +
 lib/rubygems/installer.rb                        | 14 ++----
 lib/rubygems/optparse/.document                  |  1 +
 lib/rubygems/optparse/COPYING                    | 56 ++++++++++++++++++++++++
 lib/rubygems/resolver/molinillo/LICENSE          |  9 ++++
 lib/rubygems/specification.rb                    | 14 +++---
 lib/rubygems/tsort/.document                     |  1 +
 lib/rubygems/tsort/LICENSE.txt                   | 22 ++++++++++
 test/rubygems/test_gem_command_manager.rb        | 12 +++++
 test/rubygems/test_gem_commands_setup_command.rb | 17 +++++++
 test/rubygems/test_gem_installer.rb              | 42 +++++++++++++++---
 test/rubygems/test_require.rb                    | 30 ++-----------
 16 files changed, 205 insertions(+), 61 deletions(-)
 create mode 100644 lib/rubygems/optparse/.document
 create mode 100644 lib/rubygems/optparse/COPYING
 create mode 100644 lib/rubygems/resolver/molinillo/LICENSE
 create mode 100644 lib/rubygems/tsort/.document
 create mode 100644 lib/rubygems/tsort/LICENSE.txt

diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 79857b80b9..6a7e56fa3c 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L8
 require 'rbconfig'
 
 module Gem
-  VERSION = "3.2.32".freeze
+  VERSION = "3.2.33".freeze
 end
 
 # Must be first since it unloads the prelude from 1.9.2
@@ -800,11 +800,11 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L800
   ##
   # Safely write a file in binary mode on all platforms.
   def self.write_binary(path, data)
+    File.open(path, File::RDWR | File::CREAT | File::BINARY | File::LOCK_EX) do |io|
+      io.write data
+    end
+  rescue *WRITE_BINARY_ERRORS
     File.open(path, 'wb') do |io|
-      begin
-        io.flock(File::LOCK_EX)
-      rescue *WRITE_BINARY_ERRORS
-      end
       io.write data
     end
   rescue Errno::ENOLCK # NFS
diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb
index 3f4cd4bcfa..cb07757700 100644
--- a/lib/rubygems/command_manager.rb
+++ b/lib/rubygems/command_manager.rb
@@ -73,7 +73,9 @@ class Gem::CommandManager https://github.com/ruby/ruby/blob/trunk/lib/rubygems/command_manager.rb#L73
   ].freeze
 
   ALIAS_COMMANDS = {
-    'i' => 'install',
+    'i'      => 'install',
+    'login'  => 'signin',
+    'logout' => 'signout',
   }.freeze
 
   ##
diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb
index 41547ce73b..13979b0a59 100644
--- a/lib/rubygems/commands/pristine_command.rb
+++ b/lib/rubygems/commands/pristine_command.rb
@@ -50,6 +50,11 @@ class Gem::Commands::PristineCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/pristine_command.rb#L50
       options[:env_shebang] = value
     end
 
+    add_option('-i', '--install-dir DIR',
+               'Gem repository to get binstubs and plugins installed') do |value, options|
+      options[:install_dir] = File.expand_path(value)
+    end
+
     add_option('-n', '--bindir DIR',
                'Directory where executables are',
                'located') do |value, options|
@@ -163,11 +168,12 @@ extensions will be restored. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/pristine_command.rb#L168
         end
 
       bin_dir = options[:bin_dir] if options[:bin_dir]
+      install_dir = options[:install_dir] if options[:install_dir]
 
       installer_options = {
         :wrappers => true,
         :force => true,
-        :install_dir => spec.base_dir,
+        :install_dir => install_dir || spec.base_dir,
         :env_shebang => env_shebang,
         :build_args => spec.build_args,
         :bin_dir => bin_dir,
@@ -177,7 +183,7 @@ extensions will be restored. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/pristine_command.rb#L183
         installer = Gem::Installer.for_spec(spec, installer_options)
         installer.generate_bin
       elsif options[:only_plugins]
-        installer = Gem::Installer.for_spec(spec)
+        installer = Gem::Installer.for_spec(spec, installer_options)
         installer.generate_plugins
       else
         installer = Gem::Installer.at(gem, installer_options)
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 04247368ab..894f94b484 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -182,8 +182,8 @@ By default, this RubyGems will install gem as: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L182
 
     say "RubyGems #{Gem::VERSION} installed"
 
-    regenerate_binstubs if options[:regenerate_binstubs]
-    regenerate_plugins if options[:regenerate_plugins]
+    regenerate_binstubs(bin_dir) if options[:regenerate_binstubs]
+    regenerate_plugins(bin_dir) if options[:regenerate_plugins]
 
     uninstall_old_gemcutter
 
@@ -411,8 +411,16 @@ By default, this RubyGems will install gem as: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L411
     Dir.chdir("bundler") do
       built_gem = Gem::Package.build(bundler_spec)
       begin
-        installer = Gem::Installer.at(built_gem, env_shebang: options[:env_shebang], format_executable: options[:format_executable], force: options[:force], install_as_default: true, bin_dir: bin_dir, wrappers: true)
-        installer.install
+        Gem::Installer.at(
+          built_gem,
+          env_shebang: options[:env_shebang],
+          format_executable: options[:format_executable],
+          force: options[:force],
+          install_as_default: true,
+          bin_dir: bin_dir,
+          install_dir: default_dir,
+          wrappers: true
+        ).install
       ensure
         FileUtils.rm_f built_gem
       end
@@ -594,11 +602,12 @@ abort "#{deprecation_message}" https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L602
   rescue Gem::InstallError
   end
 
-  def regenerate_binstubs
+  def regenerate_binstubs(bindir)
     require_relative "pristine_command"
     say "Regenerating binstubs"
 
     args = %w[--all --only-executables --silent]
+    args << "--bindir=#{bindir}"
     if options[:env_shebang]
       args << "--env-shebang"
     end
@@ -607,11 +616,13 @@ abort "#{deprecation_message}" https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L616
     command.invoke(*args)
   end
 
-  def regenerate_plugins
+  def regenerate_plugins(bindir)
     require_relative "pristine_command"
     say "Regenerating plugins"
 
     args = %w[--all --only-plugins --silent]
+    args << "--bindir=#{bindir}"
+    args << "--install-dir=#{default_dir}"
 
     command = Gem::Commands::PristineCommand.new
     command.invoke(*args)
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index ca485de30e..5f20dfaed0 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -259,3 +259,4 @@ end https://github.com/ruby/ruby/blob/trunk/lib/rubygems/exceptions.rb#L259
 # Backwards compatible typo'd exception class for early RubyGems 2.0.x
 
 Gem::UnsatisfiableDepedencyError = Gem::UnsatisfiableDependencyError # :nodoc:
+Gem.deprecate_constant :UnsatisfiableDepedencyError
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 10341a9398..8e3965ef92 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -293,8 +293,6 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L293
   def install
     pre_install_checks
 
-    FileUtils.rm_f File.join gem_home, 'specifications', spec.spec_name
-
     run_pre_install_hooks
 
     # Set loaded_from to ensure extension_dir is correct
@@ -448,13 +446,9 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L446
   # specifications directory.
 
   def write_spec
-    File.open spec_file, 'w' do |file|
-      spec.installed_by_version = Gem.rubygems_version
-
-      file.puts spec.to_ruby_for_cache
+    spec.installed_by_version = Gem.rubygems_version
 
-      file.fsync rescue nil # for filesystems without fsync(2)
-    end
+    Gem.write_binary(spec_file, spec.to_ruby_for_cache)
   end
 
   ##
@@ -462,9 +456,7 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L456
   # specifications/default directory.
 
   def write_default_spec
-    File.open(default_spec_file, "w") do |file|
-      file.puts spec.to_ruby
-    end
+    Gem.write_binary(default_spec_file, spec.to_ruby)
   end
 
   ##
diff --git a/lib/rubygems/optparse/.document b/lib/rubygems/optparse/.document
new file mode 100644
index 0000000000..0c43bbd6b3
--- /dev/null
+++ b/lib/rubygems/optparse/.document
@@ -0,0 +1 @@
+# Vendored files do not need to be documented
diff --git a/lib/rubygems/optparse/COPYING b/lib/rubygems/optparse/COPYING
new file mode 100644
index 0000000000..48e5a96de7
--- /dev/null
+++ b/lib/rubygems/optparse/COPYING
@@ -0,0 +1,56 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/optparse/COPYING#L1
+Ruby is copyrighted free software by Yukihiro Matsumoto <matz@n...>.
+You can redistribute it and/or modify it under either the terms of the
+2-clause BSDL (see the file BSDL), or the conditions below:
+
+1. You may make and give away verbatim copies of the source form of the
+   software without restriction, provided that you duplicate all of the
+   or (... truncated)

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

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