ruby-changes:66654
From: Nobuyoshi <ko1@a...>
Date: Thu, 1 Jul 2021 06:42:48 +0900 (JST)
Subject: [ruby-changes:66654] 9c9531950c (master): rbinstall.rb: get rid of making directories when dryrun
https://git.ruby-lang.org/ruby.git/commit/?id=9c9531950c From 9c9531950c007872d7726f050a1dc0cb6f8f0490 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 1 Jul 2021 06:42:00 +0900 Subject: rbinstall.rb: get rid of making directories when dryrun --- tool/rbinstall.rb | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb index b7370a8..7f522e5 100755 --- a/tool/rbinstall.rb +++ b/tool/rbinstall.rb @@ -682,6 +682,28 @@ install?(:dbg, :nodefault) do https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L682 end module RbInstall + def self.no_write(options = nil) + u = File.umask(0022) + if $dryrun + fu = ::Object.class_eval do + fu = remove_const(:FileUtils) + const_set(:FileUtils, fu::NoWrite) + fu + end + dir_mode = options.delete(:dir_mode) if options + end + yield + ensure + options[:dir_mode] = dir_mode if dir_mode + if fu + ::Object.class_eval do + remove_const(:FileUtils) + const_set(:FileUtils, fu) + end + end + File.umask(u) + end + module Specs class FileCollector def initialize(gemspec) @@ -849,25 +871,7 @@ module RbInstall https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L871 class GemInstaller def install spec.post_install_message = nil - u = File.umask(0022) - if $dryrun - fu = ::Object.class_eval do - fu = remove_const(:FileUtils) - const_set(:FileUtils, fu::NoWrite) - fu - end - dir_mode = options.delete(:dir_mode) - end - super - ensure - options[:dir_mode] = dir_mode if dir_mode - if fu - ::Object.class_eval do - remove_const(:FileUtils) - const_set(:FileUtils, fu) - end - end - File.umask(u) + RbInstall.no_write(options) {super} end def generate_bin_script(filename, bindir) @@ -930,7 +934,9 @@ def install_default_gem(dir, srcdir, bindir) https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L934 gem_dir = Gem.default_dir install_dir = with_destdir(gem_dir) prepare "default gems from #{dir}", gem_dir - makedirs(Gem.ensure_default_gem_subdirectories(install_dir, $dir_mode).map {|d| File.join(gem_dir, d)}) + RbInstall.no_write do + makedirs(Gem.ensure_default_gem_subdirectories(install_dir, $dir_mode).map {|d| File.join(gem_dir, d)}) + end options = { :install_dir => with_destdir(gem_dir), @@ -974,7 +980,10 @@ install?(:ext, :comm, :gem, :'bundled-gems') do https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L980 gem_dir = Gem.default_dir install_dir = with_destdir(gem_dir) prepare "bundled gems", gem_dir - makedirs(Gem.ensure_gem_subdirectories(install_dir, $dir_mode).map {|d| File.join(gem_dir, d)}) + RbInstall.no_write do + makedirs(Gem.ensure_gem_subdirectories(install_dir, $dir_mode).map {|d| File.join(gem_dir, d)}) + end + installed_gems = {} options = { :install_dir => install_dir, -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/