1 From 8e85d27f9ccfe152fc1b891c19f125915a907493 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
3 Date: Tue, 1 Oct 2019 12:03:33 +0200
4 Subject: [PATCH] Use `Gem::Package` like object instead of monkey patching.
6 1. This is similar to what RubyGems does and it is less magic [[1]].
7 2. It avoids deprecated code paths in RubyGems [[2]].
9 [1]: https://github.com/rubygems/rubygems/blob/92892bbc3adba86a90756c385433835f6761b8da/lib/rubygems/installer.rb#L151
10 [2]: https://github.com/rubygems/rubygems/blob/92892bbc3adba86a90756c385433835f6761b8da/lib/rubygems/installer.rb#L187
12 (cherry picked from commit e960ef6f18a25c637c54f00c75bb6c24f8ab55d0)
14 tool/rbinstall.rb | 47 +++++++++++++++++++++++++++--------------------
15 1 file changed, 27 insertions(+), 20 deletions(-)
17 diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
18 index 060390626f..28ae8c409a 100755
19 --- a/tool/rbinstall.rb
20 +++ b/tool/rbinstall.rb
21 @@ -710,28 +710,34 @@ def remove_prefix(prefix, string)
25 - class UnpackedInstaller < Gem::Installer
27 - def extract_files(destination_dir, pattern = "*")
28 - path = File.dirname(@gem.path)
29 - return if path == destination_dir
30 - File.chmod(0700, destination_dir)
31 - mode = pattern == "bin/*" ? $script_mode : $data_mode
32 - spec.files.each do |f|
33 - src = File.join(path, f)
34 - dest = File.join(without_destdir(destination_dir), f)
35 - makedirs(dest[/.*(?=\/)/m])
36 - install src, dest, :mode => mode
38 - File.chmod($dir_mode, destination_dir)
42 + attr_accessor :dir_mode
43 + attr_accessor :prog_mode
44 + attr_accessor :data_mode
46 + def initialize(spec)
48 + @src_dir = File.dirname(@spec.loaded_from)
51 + def extract_files(destination_dir, pattern = "*")
53 + return if path == destination_dir
54 + File.chmod(0700, destination_dir)
55 + mode = pattern == "bin/*" ? $script_mode : $data_mode
56 + spec.files.each do |f|
57 + src = File.join(path, f)
58 + dest = File.join(without_destdir(destination_dir), f)
59 + makedirs(dest[/.*(?=\/)/m])
60 + install src, dest, :mode => mode
62 + File.chmod($dir_mode, destination_dir)
66 - def initialize(spec, *options)
67 - super(spec.loaded_from, *options)
68 - @package.extend(DirPackage).spec = spec
71 + class UnpackedInstaller < Gem::Installer
75 @@ -890,7 +896,8 @@ def install_default_gem(dir, srcdir)
76 if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}")
77 spec.extensions[0] ||= "-"
79 - ins = RbInstall::UnpackedInstaller.new(spec, options)
80 + package = RbInstall::DirPackage.new spec
81 + ins = RbInstall::UnpackedInstaller.new(package, options)
82 puts "#{INDENT}#{spec.name} #{spec.version}"
84 File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec"))