1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

rbinstall.rb: get rid of making directories when dryrun

This commit is contained in:
Nobuyoshi Nakada 2021-07-01 06:42:00 +09:00
parent 8ee24840c8
commit 9c9531950c
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -682,6 +682,28 @@ install?(:dbg, :nodefault) do
end end
module RbInstall 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 module Specs
class FileCollector class FileCollector
def initialize(gemspec) def initialize(gemspec)
@ -849,25 +871,7 @@ module RbInstall
class GemInstaller class GemInstaller
def install def install
spec.post_install_message = nil spec.post_install_message = nil
u = File.umask(0022) RbInstall.no_write(options) {super}
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)
end end
def generate_bin_script(filename, bindir) def generate_bin_script(filename, bindir)
@ -930,7 +934,9 @@ def install_default_gem(dir, srcdir, bindir)
gem_dir = Gem.default_dir gem_dir = Gem.default_dir
install_dir = with_destdir(gem_dir) install_dir = with_destdir(gem_dir)
prepare "default gems from #{dir}", 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 = { options = {
:install_dir => with_destdir(gem_dir), :install_dir => with_destdir(gem_dir),
@ -974,7 +980,10 @@ install?(:ext, :comm, :gem, :'bundled-gems') do
gem_dir = Gem.default_dir gem_dir = Gem.default_dir
install_dir = with_destdir(gem_dir) install_dir = with_destdir(gem_dir)
prepare "bundled gems", 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 = {} installed_gems = {}
options = { options = {
:install_dir => install_dir, :install_dir => install_dir,