1 |
From 5a37a3489491a33f2e7011043fbbcd9a765e1777 Mon Sep 17 00:00:00 2001 |
2 |
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com> |
3 |
Date: Thu, 3 Nov 2011 16:43:05 +0100 |
4 |
Subject: [PATCH 1/6] Add dedicate extensions folder into $LOAD_PATH. |
5 |
|
6 |
--- |
7 |
lib/rubygems/specification.rb | 37 ++++++++++++++++++++++++++++++------- |
8 |
1 files changed, 30 insertions(+), 7 deletions(-) |
9 |
|
10 |
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb |
11 |
index 97db19e..263e7d3 100644 |
12 |
--- a/lib/rubygems/specification.rb |
13 |
+++ b/lib/rubygems/specification.rb |
14 |
@@ -843,6 +843,12 @@ class Gem::Specification |
15 |
File.join full_gem_path, path |
16 |
end |
17 |
|
18 |
+ unless extensions.empty? |
19 |
+ paths += require_paths.map do |path| |
20 |
+ File.join ext_dir, path |
21 |
+ end |
22 |
+ end |
23 |
+ |
24 |
# gem directories must come after -I and ENV['RUBYLIB'] |
25 |
insert_index = Gem.load_path_insert_index |
26 |
|
27 |
@@ -954,16 +960,16 @@ class Gem::Specification |
28 |
|
29 |
def contains_requirable_file? file |
30 |
root = full_gem_path |
31 |
+ ext = ext_dir |
32 |
+ |
33 |
+ require_paths.any? do |lib| |
34 |
+ base = ["#{root}/#{lib}/#{file}"] |
35 |
+ base << "#{ext}/#{lib}/#{file}" unless extensions.empty? |
36 |
|
37 |
- require_paths.each do |lib| |
38 |
- base = "#{root}/#{lib}/#{file}" |
39 |
- Gem.suffixes.each do |suf| |
40 |
- path = "#{base}#{suf}" |
41 |
- return true if File.file? path |
42 |
+ base.any? do |path| |
43 |
+ Gem.suffixes.any? { |suf| File.file? "#{path}#{suf}" } |
44 |
end |
45 |
end |
46 |
- |
47 |
- return false |
48 |
end |
49 |
|
50 |
## |
51 |
@@ -1273,6 +1279,23 @@ class Gem::Specification |
52 |
end |
53 |
|
54 |
## |
55 |
+ # Returns the full path to this spec's ext directory. |
56 |
+ # eg: /usr/local/lib/ruby/1.8/exts/mygem-1.0 |
57 |
+ |
58 |
+ def ext_dir |
59 |
+ @gem_dir ||= File.expand_path File.join(exts_dir, full_name) |
60 |
+ end |
61 |
+ |
62 |
+ ## |
63 |
+ # Returns the full path to the exts directory containing this spec's |
64 |
+ # gem directory. eg: /usr/local/lib/ruby/1.8/exts |
65 |
+ |
66 |
+ def exts_dir |
67 |
+ # TODO: this logic seems terribly broken, but tests fail if just base_dir |
68 |
+ @exts_dir ||= File.join(loaded_from && base_dir || Gem.dir, "exts") |
69 |
+ end |
70 |
+ |
71 |
+ ## |
72 |
# Deprecated and ignored, defaults to true. |
73 |
# |
74 |
# Formerly used to indicate this gem was RDoc-capable. |
75 |
-- |
76 |
1.7.7.3 |
77 |
|
78 |
|
79 |
From 671e4285bf9db948bc5f054d7d3d931cdd7a17f8 Mon Sep 17 00:00:00 2001 |
80 |
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com> |
81 |
Date: Wed, 16 Nov 2011 13:26:48 +0100 |
82 |
Subject: [PATCH 2/6] Use spec's ext dir for extension installation. |
83 |
|
84 |
--- |
85 |
lib/rubygems/installer.rb | 2 +- |
86 |
lib/rubygems/specification.rb | 7 +++---- |
87 |
2 files changed, 4 insertions(+), 5 deletions(-) |
88 |
|
89 |
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb |
90 |
index 74d803d..0063c7f 100644 |
91 |
--- a/lib/rubygems/installer.rb |
92 |
+++ b/lib/rubygems/installer.rb |
93 |
@@ -499,7 +499,7 @@ TEXT |
94 |
def build_extensions |
95 |
return if spec.extensions.empty? |
96 |
say "Building native extensions. This could take a while..." |
97 |
- dest_path = File.join gem_dir, spec.require_paths.first |
98 |
+ dest_path = spec.ext_dir |
99 |
ran_rake = false # only run rake once |
100 |
|
101 |
spec.extensions.each do |extension| |
102 |
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb |
103 |
index 263e7d3..d31b93b 100644 |
104 |
--- a/lib/rubygems/specification.rb |
105 |
+++ b/lib/rubygems/specification.rb |
106 |
@@ -1283,16 +1283,15 @@ class Gem::Specification |
107 |
# eg: /usr/local/lib/ruby/1.8/exts/mygem-1.0 |
108 |
|
109 |
def ext_dir |
110 |
- @gem_dir ||= File.expand_path File.join(exts_dir, full_name) |
111 |
+ @ext_dir ||= File.join exts_dir, full_name, require_paths.first |
112 |
end |
113 |
|
114 |
## |
115 |
# Returns the full path to the exts directory containing this spec's |
116 |
- # gem directory. eg: /usr/local/lib/ruby/1.8/exts |
117 |
+ # gem directory. eg: /usr/local/lib/ruby/1.8/gems |
118 |
|
119 |
def exts_dir |
120 |
- # TODO: this logic seems terribly broken, but tests fail if just base_dir |
121 |
- @exts_dir ||= File.join(loaded_from && base_dir || Gem.dir, "exts") |
122 |
+ @exts_dir ||= gems_dir |
123 |
end |
124 |
|
125 |
## |
126 |
-- |
127 |
1.7.7.3 |
128 |
|
129 |
|
130 |
From 11b4a0cbadd8b1d3320f838881aa60feb6f848e7 Mon Sep 17 00:00:00 2001 |
131 |
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com> |
132 |
Date: Wed, 16 Nov 2011 14:52:16 +0100 |
133 |
Subject: [PATCH 3/6] Simplify the extending of $LOAD_PATH for binary gems. |
134 |
|
135 |
--- |
136 |
lib/rubygems/specification.rb | 11 +++++------ |
137 |
1 files changed, 5 insertions(+), 6 deletions(-) |
138 |
|
139 |
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb |
140 |
index d31b93b..e65ea2d 100644 |
141 |
--- a/lib/rubygems/specification.rb |
142 |
+++ b/lib/rubygems/specification.rb |
143 |
@@ -843,11 +843,7 @@ class Gem::Specification |
144 |
File.join full_gem_path, path |
145 |
end |
146 |
|
147 |
- unless extensions.empty? |
148 |
- paths += require_paths.map do |path| |
149 |
- File.join ext_dir, path |
150 |
- end |
151 |
- end |
152 |
+ paths << ext_dir unless extensions.empty? || paths.include?(ext_dir) |
153 |
|
154 |
# gem directories must come after -I and ENV['RUBYLIB'] |
155 |
insert_index = Gem.load_path_insert_index |
156 |
@@ -1291,7 +1287,10 @@ class Gem::Specification |
157 |
# gem directory. eg: /usr/local/lib/ruby/1.8/gems |
158 |
|
159 |
def exts_dir |
160 |
- @exts_dir ||= gems_dir |
161 |
+ @exts_dir ||= begin |
162 |
+ dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir} |
163 |
+ dirs ? File.join(dirs.last[:ext_dir], 'exts') : gems_dir |
164 |
+ end |
165 |
end |
166 |
|
167 |
## |
168 |
-- |
169 |
1.7.7.3 |
170 |
|
171 |
|
172 |
From 5d46cd2b1ac9517a9cbcfa430261e62bb3a376b8 Mon Sep 17 00:00:00 2001 |
173 |
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com> |
174 |
Date: Fri, 9 Dec 2011 16:31:04 +0100 |
175 |
Subject: [PATCH 4/6] Fix the binary extension search path construction. |
176 |
|
177 |
--- |
178 |
lib/rubygems/installer.rb | 2 +- |
179 |
lib/rubygems/specification.rb | 4 ++-- |
180 |
2 files changed, 3 insertions(+), 3 deletions(-) |
181 |
|
182 |
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb |
183 |
index 0063c7f..83b8fd5 100644 |
184 |
--- a/lib/rubygems/installer.rb |
185 |
+++ b/lib/rubygems/installer.rb |
186 |
@@ -499,7 +499,7 @@ TEXT |
187 |
def build_extensions |
188 |
return if spec.extensions.empty? |
189 |
say "Building native extensions. This could take a while..." |
190 |
- dest_path = spec.ext_dir |
191 |
+ dest_path = File.join spec.ext_dir, spec.require_paths.first |
192 |
ran_rake = false # only run rake once |
193 |
|
194 |
spec.extensions.each do |extension| |
195 |
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb |
196 |
index e65ea2d..8be2ade 100644 |
197 |
--- a/lib/rubygems/specification.rb |
198 |
+++ b/lib/rubygems/specification.rb |
199 |
@@ -843,7 +843,7 @@ class Gem::Specification |
200 |
File.join full_gem_path, path |
201 |
end |
202 |
|
203 |
- paths << ext_dir unless extensions.empty? || paths.include?(ext_dir) |
204 |
+ paths << File.join(ext_dir, require_paths.first) unless extensions.empty? || (ext_dir == full_gem_path) |
205 |
|
206 |
# gem directories must come after -I and ENV['RUBYLIB'] |
207 |
insert_index = Gem.load_path_insert_index |
208 |
@@ -1279,7 +1279,7 @@ class Gem::Specification |
209 |
# eg: /usr/local/lib/ruby/1.8/exts/mygem-1.0 |
210 |
|
211 |
def ext_dir |
212 |
- @ext_dir ||= File.join exts_dir, full_name, require_paths.first |
213 |
+ @ext_dir ||= File.join exts_dir, full_name |
214 |
end |
215 |
|
216 |
## |
217 |
-- |
218 |
1.7.7.3 |
219 |
|
220 |
|
221 |
From 6229583633802b45e5a3e5689ab9077347cd9ef7 Mon Sep 17 00:00:00 2001 |
222 |
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com> |
223 |
Date: Tue, 13 Dec 2011 12:14:54 +0100 |
224 |
Subject: [PATCH 5/6] Remove binary extensions during uninstall. |
225 |
|
226 |
--- |
227 |
lib/rubygems/uninstaller.rb | 1 + |
228 |
1 files changed, 1 insertions(+), 0 deletions(-) |
229 |
|
230 |
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb |
231 |
index cc32ea4..94d78e0 100644 |
232 |
--- a/lib/rubygems/uninstaller.rb |
233 |
+++ b/lib/rubygems/uninstaller.rb |
234 |
@@ -213,6 +213,7 @@ class Gem::Uninstaller |
235 |
File.writable?(spec.base_dir) |
236 |
|
237 |
FileUtils.rm_rf spec.full_gem_path |
238 |
+ FileUtils.rm_rf spec.ext_dir |
239 |
|
240 |
# TODO: should this be moved to spec?... I vote eww (also exists in docmgr) |
241 |
old_platform_name = [spec.name, |
242 |
-- |
243 |
1.7.7.3 |
244 |
|
245 |
|
246 |
From bc40e1b9f60a9a04456e3504ffe6ee600b6da269 Mon Sep 17 00:00:00 2001 |
247 |
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com> |
248 |
Date: Tue, 13 Dec 2011 14:27:14 +0100 |
249 |
Subject: [PATCH 6/6] Avoid dependency on customized operating_system.rb. |
250 |
|
251 |
--- |
252 |
lib/rubygems/defaults.rb | 11 +++++++++++ |
253 |
lib/rubygems/specification.rb | 5 +---- |
254 |
2 files changed, 12 insertions(+), 4 deletions(-) |
255 |
|
256 |
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb |
257 |
index 20b4198..6d8711f 100644 |
258 |
--- a/lib/rubygems/defaults.rb |
259 |
+++ b/lib/rubygems/defaults.rb |
260 |
@@ -87,6 +87,17 @@ module Gem |
261 |
end |
262 |
|
263 |
## |
264 |
+ # Returns binary extensions dir for specified RubyGems base dir or nil |
265 |
+ # if such directory cannot be determined. |
266 |
+ # |
267 |
+ # By default, the binary extensions are located side by side with their |
268 |
+ # Ruby counterparts, therefore nil is returned |
269 |
+ |
270 |
+ def self.default_ext_dir_for base_dir |
271 |
+ nil |
272 |
+ end |
273 |
+ |
274 |
+ ## |
275 |
# The default system-wide source info cache directory |
276 |
|
277 |
def self.default_system_source_cache_dir |
278 |
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb |
279 |
index 8be2ade..f54210a 100644 |
280 |
--- a/lib/rubygems/specification.rb |
281 |
+++ b/lib/rubygems/specification.rb |
282 |
@@ -1287,10 +1287,7 @@ class Gem::Specification |
283 |
# gem directory. eg: /usr/local/lib/ruby/1.8/gems |
284 |
|
285 |
def exts_dir |
286 |
- @exts_dir ||= begin |
287 |
- dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir} |
288 |
- dirs ? File.join(dirs.last[:ext_dir], 'exts') : gems_dir |
289 |
- end |
290 |
+ @exts_dir ||= Gem.default_ext_dir_for(base_dir) || gems_dir |
291 |
end |
292 |
|
293 |
## |
294 |
-- |
295 |
1.7.7.3 |
296 |
|