From 94a9a314e69dd0ceb9f7dd02134de2008a949b65 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 9 Feb 2016 06:50:53 +0000 Subject: 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/mkrunnable.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'tool/mkrunnable.rb') diff --git a/tool/mkrunnable.rb b/tool/mkrunnable.rb index 60d0889eb4..cbc4db7669 100755 --- a/tool/mkrunnable.rb +++ b/tool/mkrunnable.rb @@ -29,9 +29,18 @@ module Mswin 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) 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" => ".") -- cgit v1.2.1