aboutsummaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-09 06:50:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-09 06:50:53 +0000
commit3371bb2bf5bc6d3318ec2bf0c7b1c554385db0a3 (patch)
treee4c24a30f9f2e8c8fd5a04e3fa820d9b83239e60 /tool
parentc744ad9c7cbb0d519c4a57a7aef104e46e46df36 (diff)
downloadruby-3371bb2bf5bc6d3318ec2bf0c7b1c554385db0a3.tar.gz
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
Diffstat (limited to 'tool')
-rwxr-xr-xtool/mkrunnable.rb17
1 files changed, 13 insertions, 4 deletions
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" => ".")