mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
extlibs.rb: links in extracted directory
Allow to create symbolic links (if available) to share same or updated files.
This commit is contained in:
parent
d1748484e8
commit
3150b97d32
Notes:
git
2020-05-12 15:58:18 +09:00
1 changed files with 36 additions and 0 deletions
|
@ -94,6 +94,36 @@ class ExtLibs
|
|||
$?.success? or raise "failed to patch #{patch}"
|
||||
end
|
||||
|
||||
def do_link(file, src, dest)
|
||||
file = File.join(dest, file)
|
||||
if (target = src).start_with?("/")
|
||||
target = File.join([".."] * file.count("/"), src)
|
||||
end
|
||||
File.unlink(file) rescue nil
|
||||
begin
|
||||
File.symlink(target, file)
|
||||
rescue
|
||||
else
|
||||
if $VERBOSE
|
||||
$stdout.puts "linked #{target} to #{file}"
|
||||
$stdout.flush
|
||||
end
|
||||
return
|
||||
end
|
||||
begin
|
||||
src = src.sub(/\A\//, '')
|
||||
File.copy_stream(src, file)
|
||||
rescue
|
||||
if $VERBOSE
|
||||
$stdout.puts "failed to link #{src} to #{file}: #{$!.message}"
|
||||
end
|
||||
else
|
||||
if $VERBOSE
|
||||
$stdout.puts "copied #{src} to #{file}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def do_command(mode, dest, url, cache_dir, chksums)
|
||||
extracted = false
|
||||
base = /.*(?=\.tar(?:\.\w+)?\z)/
|
||||
|
@ -175,6 +205,12 @@ class ExtLibs
|
|||
do_patch(dest, patch, args)
|
||||
end
|
||||
next
|
||||
elsif /->/ =~ line
|
||||
if extracted and (mode == :all or mode == :patch)
|
||||
link, file = $`.strip, $'.strip
|
||||
do_link(vars.expand(link), vars.expand(file), dest)
|
||||
end
|
||||
next
|
||||
else
|
||||
url, *chksums = line.split(' ')
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue