[前][次][番号順一覧][スレッド一覧]

ruby-changes:61209

From: Nobuyoshi <ko1@a...>
Date: Tue, 12 May 2020 15:58:13 +0900 (JST)
Subject: [ruby-changes:61209] 3150b97d32 (master): extlibs.rb: links in extracted directory

https://git.ruby-lang.org/ruby.git/commit/?id=3150b97d32

From 3150b97d3261025955561e40ec781723ddc716fb Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 10 May 2020 15:00:36 +0900
Subject: extlibs.rb: links in extracted directory

Allow to create symbolic links (if available) to share same or
updated files.

diff --git a/tool/extlibs.rb b/tool/extlibs.rb
index e7184b8..e2605f5 100755
--- a/tool/extlibs.rb
+++ b/tool/extlibs.rb
@@ -94,6 +94,36 @@ class ExtLibs https://github.com/ruby/ruby/blob/trunk/tool/extlibs.rb#L94
     $?.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 https://github.com/ruby/ruby/blob/trunk/tool/extlibs.rb#L205
               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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]