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

ruby-changes:65256

From: Nobuyoshi <ko1@a...>
Date: Sun, 14 Feb 2021 17:47:45 +0900 (JST)
Subject: [ruby-changes:65256] 0dad341006 (master): Directory mapping for default gems

https://git.ruby-lang.org/ruby.git/commit/?id=0dad341006

From 0dad341006c3d6a1d941451c5ad5f4d72b386595 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 14 Feb 2021 17:41:02 +0900
Subject: Directory mapping for default gems

To uniform directory structures, sometimes files are gathered in
different directory than the upstreams, executable files in
`libexec` for instance.  Re-map these files to consistent with the
upstreams.
---
 tool/rbinstall.rb | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index debf73a..9c3d713 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -746,9 +746,10 @@ module RbInstall https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L746
     attr_accessor :prog_mode
     attr_accessor :data_mode
 
-    def initialize(spec)
+    def initialize(spec, dir_map = nil)
       @spec = spec
       @src_dir = File.dirname(@spec.loaded_from)
+      @dir_map = dir_map
     end
 
     def extract_files(destination_dir, pattern = "*")
@@ -756,14 +757,13 @@ module RbInstall https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L757
       File.chmod(0700, destination_dir) unless $dryrun
       mode = pattern == File.join(spec.bindir, '*') ? prog_mode : data_mode
       destdir = without_destdir(destination_dir)
+      if @dir_map
+        (dir_map = @dir_map.map {|k, v| Regexp.quote(k) unless k == v}).compact!
+        dir_map = %r{\A(?:#{dir_map.join('|')})(?=/)}
+      end
       spec.files.each do |f|
         next unless File.fnmatch(pattern, f)
-        src = File.join(@src_dir, f)
-        # The `src` is fine for bundled gems. However, default gems have their
-        # binaries in `libexec`.
-        unless File.exist?(src)
-          src = File.join(@src_dir, 'libexec', File.basename(f))
-        end
+        src = File.join(@src_dir, dir_map =~ f ? "#{@dir_map[$&]}#{$'}" : f)
         dest = File.join(destdir, f)
         makedirs(dest[/.*(?=\/)/m])
         install src, dest, :mode => mode
@@ -939,7 +939,7 @@ def install_default_gem(dir, srcdir, bindir) https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L939
 
     gemspec.loaded_from = File.join srcdir, gemspec.spec_name
 
-    package = RbInstall::DirPackage.new gemspec
+    package = RbInstall::DirPackage.new gemspec, {gemspec.bindir => 'libexec'}
     ins = RbInstall::UnpackedInstaller.new(package, options)
     puts "#{INDENT}#{gemspec.name} #{gemspec.version}"
     ins.install
-- 
cgit v1.1


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

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