summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-09 06:50:53 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-09 06:50:53 (GMT)
commit94a9a314e69dd0ceb9f7dd02134de2008a949b65 (patch)
treee4c24a30f9f2e8c8fd5a04e3fa820d9b83239e60 /tool
parent4859eba88ffa120e87ea20cbc5b00eb777380780 (diff)
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 60d0889..cbc4db7 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" => ".")