ruby-changes:41713
From: nobu <ko1@a...>
Date: Tue, 9 Feb 2016 15:50:44 +0900 (JST)
Subject: [ruby-changes:41713] nobu:r53787 (trunk): mkrunnable.rb: clean link before symlink [ci skip]
nobu 2016-02-09 15:50:53 +0900 (Tue, 09 Feb 2016) New Revision: 53787 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53787 Log: mkrunnable.rb: clean link before symlink [ci skip] * tool/mkrunnable.rb (clean_link): clean link before symlink not to make a symlink in the linked directory. Modified files: trunk/tool/mkrunnable.rb Index: tool/mkrunnable.rb =================================================================== --- tool/mkrunnable.rb (revision 53786) +++ tool/mkrunnable.rb (revision 53787) @@ -29,9 +29,18 @@ module Mswin https://github.com/ruby/ruby/blob/trunk/tool/mkrunnable.rb#L29 end end +def clean_link(src, dest) + begin + link = File.readlink(dest) + rescue + else + return if link == src + File.unlink(dest) + end + yield src, dest +end + def ln_safe(src, dest) - link = File.readlink(dest) rescue nil - return if link == src ln_sf(src, dest) end @@ -68,14 +77,14 @@ def ln_relative(src, dest) https://github.com/ruby/ruby/blob/trunk/tool/mkrunnable.rb#L77 return if File.identical?(src, dest) parent = File.dirname(dest) File.directory?(parent) or mkdir_p(parent) - ln_safe(relative_path_from(src, parent), dest) + clean_link(relative_path_from(src, parent), dest) {|s, d| ln_safe(s, d)} end def ln_dir_relative(src, dest) return if File.identical?(src, dest) parent = File.dirname(dest) File.directory?(parent) or mkdir_p(parent) - ln_dir_safe(relative_path_from(src, parent), dest) + clean_link(relative_path_from(src, parent), dest) {|s, d| ln_dir_safe(s, d)} end config = RbConfig::MAKEFILE_CONFIG.merge("prefix" => ".", "exec_prefix" => ".") -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/