ruby-changes:74165
From: nagachika <ko1@a...>
Date: Fri, 21 Oct 2022 15:02:29 +0900 (JST)
Subject: [ruby-changes:74165] 5822577a9b (ruby_3_1): merge revision(s) c093e7d64545640c8f2e7bb3eb24e3f9e24fb1c5:
https://git.ruby-lang.org/ruby.git/commit/?id=5822577a9b From 5822577a9b5e41b6c9187bce630b092d1cd591dc Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Fri, 21 Oct 2022 14:55:30 +0900 Subject: merge revision(s) c093e7d64545640c8f2e7bb3eb24e3f9e24fb1c5: Avoid to symlink under symlink --- ext/extmk.rb | 2 +- tool/ln_sr.rb | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) --- ext/extmk.rb | 2 +- tool/ln_sr.rb | 21 ++++++++++++++------- version.h | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ext/extmk.rb b/ext/extmk.rb index 57c874fa6f..5e13fc893e 100755 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -601,7 +601,7 @@ CP_R = #{config_string('CP')} -r https://github.com/ruby/ruby/blob/trunk/ext/extmk.rb#L601 gemlib = $(TARGET_TOPDIR)/gems/$(gem)/lib gemlib:#{%{ $(gemlib)\n$(gemlib): $(gem_srcdir)/lib} if $nmake} - $(Q) $(RUBY) $(top_srcdir)/tool/ln_sr.rb -f $(gem_srcdir)/lib $(gemlib) + $(Q) #{@inplace ? '$(NULLCMD) ' : ''}$(RUBY) $(top_srcdir)/tool/ln_sr.rb -f -T $(gem_srcdir)/lib $(gemlib) clean-gemlib: $(Q) $(#{@inplace ? 'NULLCMD' : 'RM_RF'}) $(gemlib) diff --git a/tool/ln_sr.rb b/tool/ln_sr.rb index 1199263e85..307daa3202 100644 --- a/tool/ln_sr.rb +++ b/tool/ln_sr.rb @@ -1,11 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/tool/ln_sr.rb#L1 #!/usr/bin/ruby +target_directory = true +noop = false +force = false + until ARGV.empty? case ARGV[0] when '-n' noop = true when '-f' force = true + when '-T' + target_directory = false else break end @@ -21,10 +27,11 @@ require 'fileutils' https://github.com/ruby/ruby/blob/trunk/tool/ln_sr.rb#L27 include FileUtils unless respond_to?(:ln_sr) - def ln_sr(src, dest, force: nil, noop: nil, verbose: nil) + def ln_sr(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil) + options = "#{force ? 'f' : ''}#{target_directory ? '' : 'T'}" dest = File.path(dest) srcs = Array.try_convert(src) || [src] - link = proc do |s, target_directory = true| + link = proc do |s, target_dir_p = true| s = File.path(s) if fu_starting_path?(s) srcdirs = fu_split_path((File.realdirpath(s) rescue File.expand_path(s))) @@ -32,15 +39,15 @@ unless respond_to?(:ln_sr) https://github.com/ruby/ruby/blob/trunk/tool/ln_sr.rb#L39 srcdirs = fu_clean_components(*fu_split_path(s)) end destdirs = fu_split_path(File.realdirpath(dest)) - destdirs.pop unless target_directory + destdirs.pop unless target_dir_p base = fu_relative_components_from(fu_split_path(Dir.pwd), destdirs) while srcdirs.first&. == ".." and base.last and !fu_starting_path?(base.last) srcdirs.shift base.pop end s = File.join(*base, *srcdirs) - d = target_directory ? File.join(dest, File.basename(s)) : dest - fu_output_message "ln -s#{force ? 'f' : ''} #{s} #{d}" if verbose + d = target_dir_p ? File.join(dest, File.basename(s)) : dest + fu_output_message "ln -s#{options} #{s} #{d}" if verbose next if noop remove_file d, true if force File.symlink s, d @@ -48,7 +55,7 @@ unless respond_to?(:ln_sr) https://github.com/ruby/ruby/blob/trunk/tool/ln_sr.rb#L55 case srcs.size when 0 when 1 - link[srcs[0], File.directory?(dest)] + link[srcs[0], target_directory && File.directory?(dest)] else srcs.each(&link) end @@ -103,7 +110,7 @@ end https://github.com/ruby/ruby/blob/trunk/tool/ln_sr.rb#L110 if File.respond_to?(:symlink) begin - ln_sr(src, dest, verbose: true, force: force, noop: noop) + ln_sr(src, dest, verbose: true, target_directory: target_directory, force: force, noop: noop) rescue NotImplementedError, Errno::EPERM else exit diff --git a/version.h b/version.h index 854ce51883..dceb8f6f7d 100644 --- a/version.h +++ b/version.h @@ -11,7 +11,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L11 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 3 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 136 +#define RUBY_PATCHLEVEL 137 #define RUBY_RELEASE_YEAR 2022 #define RUBY_RELEASE_MONTH 10 -- cgit v1.2.3 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/