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
|
$NetBSD: patch-ad,v 1.8 2011/03/23 14:35:05 taca Exp $
* Add install_root option for pkgsrc's rubygems support.
* Disable Gem::QUICKLOADER_SUCKAGE while Ruby 1.9.2's rubygems generates
.require_paths file.
--- lib/rubygems/installer.rb.orig 2011-03-04 00:01:24.000000000 +0000
+++ lib/rubygems/installer.rb
@@ -39,7 +39,8 @@ class Gem::Installer
include Gem::UserInteraction
- include Gem::RequirePathsBuilder if Gem::QUICKLOADER_SUCKAGE
+ # For gem based package compatibility, generate .require_paths file.
+ include Gem::RequirePathsBuilder # if Gem::QUICKLOADER_SUCKAGE
##
# The directory a gem's executables will be installed into
@@ -87,6 +88,9 @@ class Gem::Installer
# :force:: Overrides all version checks and security policy checks, except
# for a signed-gems-only policy.
# :ignore_dependencies:: Don't raise if a dependency is missing.
+ # :install_root:: The directory to use as a buildroot for "destdir"-style
+ # installation. All paths during installation are relative
+ # to the buildroot.
# :install_dir:: The directory to install the gem into.
# :format_executable:: Format the executable the same as the ruby executable.
# If your ruby is ruby18, foo_exec will be installed as
@@ -174,7 +178,8 @@ class Gem::Installer
generate_bin
write_spec
- write_require_paths_file_if_needed if Gem::QUICKLOADER_SUCKAGE
+ # For gem based package compatibility, generate .require_paths file.
+ write_require_paths_file_if_needed # if Gem::QUICKLOADER_SUCKAGE
cached_gem = Gem.cache_gem(File.basename(@gem), @gem_home)
unless File.exist? cached_gem then
@@ -263,7 +268,11 @@ class Gem::Installer
# If the user has asked for the gem to be installed in a directory that is
# the system gem directory, then use the system bin directory, else create
# (or use) a new bin dir under the gem_home.
- bindir = @bin_dir ? @bin_dir : Gem.bindir(@gem_home)
+ bindir = @bin_dir ? @bin_dir : (Gem.bindir @gem_home, @install_root)
+
+ unless @install_root.nil? or @install_root == ""
+ bindir = File.join(@install_root, bindir)
+ end
Dir.mkdir bindir unless File.exist? bindir
raise Gem::FilePermissionError.new(bindir) unless File.writable? bindir
@@ -392,6 +401,7 @@ class Gem::Installer
:exec_format => false,
:force => false,
:install_dir => Gem.dir,
+ :install_root => nil,
:source_index => Gem.source_index,
}.merge options
@@ -406,6 +416,11 @@ class Gem::Installer
@bin_dir = options[:bin_dir]
@development = options[:development]
@source_index = options[:source_index]
+ install_root = options[:install_root]
+ unless install_root.nil? or install_root == ""
+ @install_root = File.expand_path install_root
+ @gem_home = File.join(@install_root, @gem_home)
+ end
end
def load_gem_file
|