about summary refs log tree commit diff
path: root/pkgs/development/interpreters/ruby/rbinstall-new-rubygems-compat.patch
blob: 54ce8a357a86ad6ea852c5796a7f909c462a46cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From 8e85d27f9ccfe152fc1b891c19f125915a907493 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Tue, 1 Oct 2019 12:03:33 +0200
Subject: [PATCH] Use `Gem::Package` like object instead of monkey patching.

1. This is similar to what RubyGems does and it is less magic [[1]].
2. It avoids deprecated code paths in RubyGems [[2]].

[1]: https://github.com/rubygems/rubygems/blob/92892bbc3adba86a90756c385433835f6761b8da/lib/rubygems/installer.rb#L151
[2]: https://github.com/rubygems/rubygems/blob/92892bbc3adba86a90756c385433835f6761b8da/lib/rubygems/installer.rb#L187

(cherry picked from commit e960ef6f18a25c637c54f00c75bb6c24f8ab55d0)
---
 tool/rbinstall.rb | 47 +++++++++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 060390626f..28ae8c409a 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -710,28 +710,34 @@ def remove_prefix(prefix, string)
     end
   end
 
-  class UnpackedInstaller < Gem::Installer
-    module DirPackage
-      def extract_files(destination_dir, pattern = "*")
-        path = File.dirname(@gem.path)
-        return if path == destination_dir
-        File.chmod(0700, destination_dir)
-        mode = pattern == "bin/*" ? $script_mode : $data_mode
-        spec.files.each do |f|
-          src = File.join(path, f)
-          dest = File.join(without_destdir(destination_dir), f)
-          makedirs(dest[/.*(?=\/)/m])
-          install src, dest, :mode => mode
-        end
-        File.chmod($dir_mode, destination_dir)
+  class DirPackage
+    attr_reader :spec
+
+    attr_accessor :dir_mode
+    attr_accessor :prog_mode
+    attr_accessor :data_mode
+
+    def initialize(spec)
+      @spec = spec
+      @src_dir = File.dirname(@spec.loaded_from)
+    end
+
+    def extract_files(destination_dir, pattern = "*")
+      path = @src_dir
+      return if path == destination_dir
+      File.chmod(0700, destination_dir)
+      mode = pattern == "bin/*" ? $script_mode : $data_mode
+      spec.files.each do |f|
+        src = File.join(path, f)
+        dest = File.join(without_destdir(destination_dir), f)
+        makedirs(dest[/.*(?=\/)/m])
+        install src, dest, :mode => mode
       end
+      File.chmod($dir_mode, destination_dir)
     end
+  end
 
-    def initialize(spec, *options)
-      super(spec.loaded_from, *options)
-      @package.extend(DirPackage).spec = spec
-    end
-
+  class UnpackedInstaller < Gem::Installer
     def write_cache_file
     end
 
@@ -890,7 +896,8 @@ def install_default_gem(dir, srcdir)
     if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}")
       spec.extensions[0] ||= "-"
     end
-    ins = RbInstall::UnpackedInstaller.new(spec, options)
+    package = RbInstall::DirPackage.new spec
+    ins = RbInstall::UnpackedInstaller.new(package, options)
     puts "#{INDENT}#{spec.name} #{spec.version}"
     ins.install
     File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec"))
-- 
2.35.1