rubygems-update 1.7.2 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.autotest +5 -1
- data/History.txt +101 -4
- data/LICENSE.txt +42 -37
- data/MIT.txt +20 -0
- data/Manifest.txt +5 -4
- data/Rakefile +6 -7
- data/lib/rubygems.rb +175 -278
- data/lib/rubygems/builder.rb +7 -6
- data/lib/rubygems/command_manager.rb +16 -2
- data/lib/rubygems/commands/build_command.rb +13 -11
- data/lib/rubygems/commands/cert_command.rb +1 -1
- data/lib/rubygems/commands/cleanup_command.rb +10 -19
- data/lib/rubygems/commands/contents_command.rb +5 -5
- data/lib/rubygems/commands/dependency_command.rb +17 -40
- data/lib/rubygems/commands/fetch_command.rb +1 -1
- data/lib/rubygems/commands/install_command.rb +2 -1
- data/lib/rubygems/commands/lock_command.rb +4 -4
- data/lib/rubygems/commands/outdated_command.rb +18 -6
- data/lib/rubygems/commands/pristine_command.rb +25 -15
- data/lib/rubygems/commands/query_command.rb +9 -6
- data/lib/rubygems/commands/setup_command.rb +1 -1
- data/lib/rubygems/commands/specification_command.rb +8 -23
- data/lib/rubygems/commands/stale_command.rb +2 -1
- data/lib/rubygems/commands/unpack_command.rb +7 -5
- data/lib/rubygems/commands/update_command.rb +2 -4
- data/lib/rubygems/commands/which_command.rb +5 -9
- data/lib/rubygems/config_file.rb +9 -7
- data/lib/rubygems/custom_require.rb +6 -4
- data/lib/rubygems/defaults.rb +30 -14
- data/lib/rubygems/dependency.rb +44 -1
- data/lib/rubygems/dependency_installer.rb +37 -41
- data/lib/rubygems/dependency_list.rb +20 -9
- data/lib/rubygems/deprecate.rb +3 -3
- data/lib/rubygems/doc_manager.rb +10 -11
- data/lib/rubygems/ext/rake_builder.rb +1 -1
- data/lib/rubygems/gem_path_searcher.rb +19 -4
- data/lib/rubygems/gem_runner.rb +1 -1
- data/lib/rubygems/indexer.rb +117 -123
- data/lib/rubygems/installer.rb +101 -94
- data/lib/rubygems/installer_test_case.rb +28 -30
- data/lib/rubygems/local_remote_options.rb +1 -1
- data/lib/rubygems/mock_gem_ui.rb +10 -3
- data/lib/rubygems/package.rb +0 -26
- data/lib/rubygems/package/tar_input.rb +5 -6
- data/lib/rubygems/package_task.rb +1 -1
- data/lib/rubygems/path_support.rb +72 -0
- data/lib/rubygems/platform.rb +12 -2
- data/lib/rubygems/remote_fetcher.rb +7 -6
- data/lib/rubygems/requirement.rb +3 -0
- data/lib/rubygems/security.rb +1 -1
- data/lib/rubygems/server.rb +67 -67
- data/lib/rubygems/source_index.rb +58 -29
- data/lib/rubygems/spec_fetcher.rb +5 -1
- data/lib/rubygems/specification.rb +1422 -877
- data/lib/rubygems/test_case.rb +114 -64
- data/lib/rubygems/test_utilities.rb +4 -3
- data/lib/rubygems/text.rb +1 -1
- data/lib/rubygems/uninstaller.rb +37 -44
- data/test/rubygems/test_gem.rb +131 -102
- data/test/rubygems/test_gem_builder.rb +18 -1
- data/test/rubygems/test_gem_command_manager.rb +2 -0
- data/test/rubygems/test_gem_commands_build_command.rb +31 -3
- data/test/rubygems/test_gem_commands_cleanup_command.rb +51 -0
- data/test/rubygems/test_gem_commands_dependency_command.rb +1 -10
- data/test/rubygems/test_gem_commands_fetch_command.rb +5 -4
- data/test/rubygems/test_gem_commands_help_command.rb +58 -0
- data/test/rubygems/test_gem_commands_install_command.rb +25 -24
- data/test/rubygems/test_gem_commands_list_command.rb +1 -4
- data/test/rubygems/test_gem_commands_outdated_command.rb +10 -9
- data/test/rubygems/test_gem_commands_pristine_command.rb +63 -22
- data/test/rubygems/test_gem_commands_push_command.rb +1 -1
- data/test/rubygems/test_gem_commands_query_command.rb +15 -82
- data/test/rubygems/test_gem_commands_sources_command.rb +8 -9
- data/test/rubygems/test_gem_commands_specification_command.rb +10 -6
- data/test/rubygems/test_gem_commands_stale_command.rb +4 -4
- data/test/rubygems/test_gem_commands_unpack_command.rb +20 -21
- data/test/rubygems/test_gem_commands_update_command.rb +19 -23
- data/test/rubygems/test_gem_commands_which_command.rb +7 -4
- data/test/rubygems/test_gem_dependency.rb +14 -8
- data/test/rubygems/test_gem_dependency_installer.rb +87 -33
- data/test/rubygems/test_gem_dependency_list.rb +7 -3
- data/test/rubygems/test_gem_doc_manager.rb +3 -3
- data/test/rubygems/test_gem_format.rb +1 -1
- data/test/rubygems/test_gem_gem_path_searcher.rb +45 -29
- data/test/rubygems/test_gem_indexer.rb +48 -47
- data/test/rubygems/test_gem_install_update_options.rb +6 -5
- data/test/rubygems/test_gem_installer.rb +61 -37
- data/test/rubygems/test_gem_path_support.rb +58 -0
- data/test/rubygems/test_gem_platform.rb +5 -5
- data/test/rubygems/test_gem_remote_fetcher.rb +18 -21
- data/test/rubygems/test_gem_server.rb +23 -15
- data/test/rubygems/test_gem_source_index.rb +165 -127
- data/test/rubygems/test_gem_spec_fetcher.rb +42 -49
- data/test/rubygems/test_gem_specification.rb +104 -74
- data/test/rubygems/test_gem_text.rb +15 -0
- data/test/rubygems/test_gem_uninstaller.rb +15 -26
- data/test/rubygems/test_kernel.rb +1 -2
- metadata +64 -14
- metadata.gz.sig +0 -0
- data/GPL.txt +0 -340
- data/pkgs/sources/lib/sources.rb +0 -3
- data/pkgs/sources/sources.gemspec +0 -14
- data/test/rubygems/functional.rb +0 -92
data/lib/rubygems/installer.rb
CHANGED
@@ -41,6 +41,8 @@ class Gem::Installer
|
|
41
41
|
|
42
42
|
include Gem::RequirePathsBuilder if Gem::QUICKLOADER_SUCKAGE
|
43
43
|
|
44
|
+
attr_reader :gem
|
45
|
+
|
44
46
|
##
|
45
47
|
# The directory a gem's executables will be installed into
|
46
48
|
|
@@ -51,11 +53,6 @@ class Gem::Installer
|
|
51
53
|
|
52
54
|
attr_reader :gem_home
|
53
55
|
|
54
|
-
##
|
55
|
-
# The Gem::Specification for the gem being installed
|
56
|
-
|
57
|
-
attr_reader :spec
|
58
|
-
|
59
56
|
##
|
60
57
|
# The options passed when the Gem::Installer was instantiated.
|
61
58
|
|
@@ -100,18 +97,36 @@ class Gem::Installer
|
|
100
97
|
@gem = gem
|
101
98
|
@options = options
|
102
99
|
process_options
|
103
|
-
load_gem_file
|
104
100
|
|
105
101
|
if options[:user_install] and not options[:unpack] then
|
106
102
|
@gem_home = Gem.user_dir
|
107
103
|
check_that_user_bin_dir_is_in_path
|
108
104
|
end
|
105
|
+
end
|
109
106
|
|
110
|
-
|
107
|
+
##
|
108
|
+
# Lazy accessor for the spec's gem directory.
|
109
|
+
|
110
|
+
def gem_dir
|
111
|
+
@gem_dir ||= spec.gem_dir.dup.untaint
|
112
|
+
end
|
111
113
|
|
112
|
-
|
114
|
+
##
|
115
|
+
# Lazy accessor for the installer's Gem::Format instance.
|
113
116
|
|
114
|
-
|
117
|
+
def format
|
118
|
+
begin
|
119
|
+
@format ||= Gem::Format.from_file_by_path gem, @security_policy
|
120
|
+
rescue Gem::Package::FormatError
|
121
|
+
raise Gem::InstallError, "invalid gem format for #{gem}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
##
|
126
|
+
# Lazy accessor for the installer's spec.
|
127
|
+
|
128
|
+
def spec
|
129
|
+
@spec ||= format.spec
|
115
130
|
end
|
116
131
|
|
117
132
|
##
|
@@ -126,6 +141,9 @@ class Gem::Installer
|
|
126
141
|
# specifications/<gem-version>.gemspec #=> the Gem::Specification
|
127
142
|
|
128
143
|
def install
|
144
|
+
verify_gem_home(options[:unpack])
|
145
|
+
Gem.use_paths gem_home, Gem.paths.path # HACK: shouldn't need Gem.paths.path
|
146
|
+
|
129
147
|
# If we're forcing the install then disable security unless the security
|
130
148
|
# policy says that we only install signed gems.
|
131
149
|
@security_policy = nil if @force and @security_policy and
|
@@ -143,17 +161,17 @@ class Gem::Installer
|
|
143
161
|
if result == false then
|
144
162
|
location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
|
145
163
|
|
146
|
-
message = "pre-install hook#{location} failed for #{
|
164
|
+
message = "pre-install hook#{location} failed for #{spec.full_name}"
|
147
165
|
raise Gem::InstallError, message
|
148
166
|
end
|
149
167
|
end
|
150
168
|
|
151
|
-
Gem.ensure_gem_subdirectories
|
169
|
+
Gem.ensure_gem_subdirectories gem_home
|
152
170
|
|
153
171
|
# Completely remove any previous gem files
|
154
|
-
FileUtils.rm_rf(
|
172
|
+
FileUtils.rm_rf(gem_dir) if File.exist? gem_dir
|
155
173
|
|
156
|
-
FileUtils.mkdir_p
|
174
|
+
FileUtils.mkdir_p gem_dir
|
157
175
|
|
158
176
|
extract_files
|
159
177
|
build_extensions
|
@@ -162,11 +180,11 @@ class Gem::Installer
|
|
162
180
|
result = hook.call self
|
163
181
|
|
164
182
|
if result == false then
|
165
|
-
FileUtils.rm_rf
|
183
|
+
FileUtils.rm_rf gem_dir
|
166
184
|
|
167
185
|
location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
|
168
186
|
|
169
|
-
message = "post-build hook#{location} failed for #{
|
187
|
+
message = "post-build hook#{location} failed for #{spec.full_name}"
|
170
188
|
raise Gem::InstallError, message
|
171
189
|
end
|
172
190
|
end
|
@@ -176,24 +194,22 @@ class Gem::Installer
|
|
176
194
|
|
177
195
|
write_require_paths_file_if_needed if Gem::QUICKLOADER_SUCKAGE
|
178
196
|
|
179
|
-
|
180
|
-
unless File.exist?
|
181
|
-
FileUtils.cp @gem, Gem.cache_dir(@gem_home)
|
182
|
-
end
|
197
|
+
cache_file = spec.cache_file
|
198
|
+
FileUtils.cp gem, cache_file unless File.exist? cache_file
|
183
199
|
|
184
|
-
say
|
200
|
+
say spec.post_install_message unless spec.post_install_message.nil?
|
185
201
|
|
186
|
-
|
202
|
+
spec.loaded_from = spec.spec_file
|
187
203
|
|
188
|
-
|
204
|
+
Gem::Specification.add_spec spec unless Gem::Specification.include? spec
|
189
205
|
|
190
206
|
Gem.post_install_hooks.each do |hook|
|
191
207
|
hook.call self
|
192
208
|
end
|
193
209
|
|
194
|
-
return
|
210
|
+
return spec
|
195
211
|
rescue Zlib::GzipFile::Error
|
196
|
-
raise Gem::InstallError, "gzip error installing #{
|
212
|
+
raise Gem::InstallError, "gzip error installing #{gem}"
|
197
213
|
end
|
198
214
|
|
199
215
|
##
|
@@ -214,7 +230,7 @@ class Gem::Installer
|
|
214
230
|
# True if the gems in the source_index satisfy +dependency+.
|
215
231
|
|
216
232
|
def installation_satisfies_dependency?(dependency)
|
217
|
-
|
233
|
+
not dependency.matching_specs.empty?
|
218
234
|
end
|
219
235
|
|
220
236
|
##
|
@@ -222,7 +238,7 @@ class Gem::Installer
|
|
222
238
|
|
223
239
|
def unpack(directory)
|
224
240
|
@gem_dir = directory
|
225
|
-
@format = Gem::Format.from_file_by_path
|
241
|
+
@format = Gem::Format.from_file_by_path gem, @security_policy
|
226
242
|
extract_files
|
227
243
|
end
|
228
244
|
|
@@ -231,14 +247,10 @@ class Gem::Installer
|
|
231
247
|
# specifications directory.
|
232
248
|
|
233
249
|
def write_spec
|
234
|
-
|
235
|
-
|
236
|
-
file_name = File.join @gem_home, 'specifications', @spec.spec_name
|
237
|
-
|
238
|
-
file_name.untaint
|
250
|
+
file_name = spec.spec_file.untaint
|
239
251
|
|
240
252
|
File.open(file_name, "w") do |file|
|
241
|
-
file.puts
|
253
|
+
file.puts spec.to_ruby_for_cache
|
242
254
|
end
|
243
255
|
end
|
244
256
|
|
@@ -258,22 +270,22 @@ class Gem::Installer
|
|
258
270
|
end
|
259
271
|
|
260
272
|
def generate_bin
|
261
|
-
return if
|
273
|
+
return if spec.executables.nil? or spec.executables.empty?
|
262
274
|
|
263
275
|
# If the user has asked for the gem to be installed in a directory that is
|
264
276
|
# the system gem directory, then use the system bin directory, else create
|
265
277
|
# (or use) a new bin dir under the gem_home.
|
266
|
-
bindir = @bin_dir
|
278
|
+
bindir = @bin_dir || Gem.bindir(gem_home)
|
267
279
|
|
268
280
|
Dir.mkdir bindir unless File.exist? bindir
|
269
281
|
raise Gem::FilePermissionError.new(bindir) unless File.writable? bindir
|
270
282
|
|
271
|
-
|
283
|
+
spec.executables.each do |filename|
|
272
284
|
filename.untaint
|
273
|
-
bin_path = File.expand_path
|
274
|
-
if File.exist?
|
285
|
+
bin_path = File.expand_path File.join(gem_dir, spec.bindir, filename)
|
286
|
+
if File.exist? bin_path
|
275
287
|
mode = File.stat(bin_path).mode | 0111
|
276
|
-
|
288
|
+
FileUtils.chmod mode, bin_path
|
277
289
|
end
|
278
290
|
|
279
291
|
if @wrappers then
|
@@ -316,14 +328,14 @@ class Gem::Installer
|
|
316
328
|
return
|
317
329
|
end
|
318
330
|
|
319
|
-
src = File.join
|
331
|
+
src = File.join gem_dir, spec.bindir, filename
|
320
332
|
dst = File.join bindir, formatted_program_filename(filename)
|
321
333
|
|
322
334
|
if File.exist? dst then
|
323
335
|
if File.symlink? dst then
|
324
336
|
link = File.readlink(dst).split File::SEPARATOR
|
325
337
|
cur_version = Gem::Version.create(link[-3].sub(/^.*-/, ''))
|
326
|
-
return if
|
338
|
+
return if spec.version < cur_version
|
327
339
|
end
|
328
340
|
File.unlink dst
|
329
341
|
end
|
@@ -337,7 +349,7 @@ class Gem::Installer
|
|
337
349
|
|
338
350
|
def shebang(bin_file_name)
|
339
351
|
ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang
|
340
|
-
path =
|
352
|
+
path = spec.bin_file bin_file_name
|
341
353
|
first_line = File.open(path, "rb") {|file| file.gets}
|
342
354
|
|
343
355
|
if /\A#!/ =~ first_line then
|
@@ -359,29 +371,29 @@ class Gem::Installer
|
|
359
371
|
end
|
360
372
|
|
361
373
|
def ensure_required_ruby_version_met
|
362
|
-
if rrv =
|
374
|
+
if rrv = spec.required_ruby_version then
|
363
375
|
unless rrv.satisfied_by? Gem.ruby_version then
|
364
|
-
raise Gem::InstallError, "#{
|
376
|
+
raise Gem::InstallError, "#{spec.name} requires Ruby version #{rrv}."
|
365
377
|
end
|
366
378
|
end
|
367
379
|
end
|
368
380
|
|
369
381
|
def ensure_required_rubygems_version_met
|
370
|
-
if rrgv =
|
382
|
+
if rrgv = spec.required_rubygems_version then
|
371
383
|
unless rrgv.satisfied_by? Gem::Version.new(Gem::VERSION) then
|
372
384
|
raise Gem::InstallError,
|
373
|
-
"#{
|
385
|
+
"#{spec.name} requires RubyGems version #{rrgv}. " +
|
374
386
|
"Try 'gem update --system' to update RubyGems itself."
|
375
387
|
end
|
376
388
|
end
|
377
389
|
end
|
378
390
|
|
379
391
|
def ensure_dependencies_met
|
380
|
-
deps =
|
381
|
-
deps |=
|
392
|
+
deps = spec.runtime_dependencies
|
393
|
+
deps |= spec.development_dependencies if @development
|
382
394
|
|
383
395
|
deps.each do |dep_gem|
|
384
|
-
ensure_dependency
|
396
|
+
ensure_dependency spec, dep_gem
|
385
397
|
end
|
386
398
|
end
|
387
399
|
|
@@ -392,32 +404,24 @@ class Gem::Installer
|
|
392
404
|
:exec_format => false,
|
393
405
|
:force => false,
|
394
406
|
:install_dir => Gem.dir,
|
395
|
-
:source_index => Gem.source_index,
|
396
407
|
}.merge options
|
397
408
|
|
398
409
|
@env_shebang = options[:env_shebang]
|
399
410
|
@force = options[:force]
|
400
|
-
gem_home
|
401
|
-
@gem_home = File.expand_path(gem_home)
|
411
|
+
@gem_home = options[:install_dir]
|
402
412
|
@ignore_dependencies = options[:ignore_dependencies]
|
403
413
|
@format_executable = options[:format_executable]
|
404
414
|
@security_policy = options[:security_policy]
|
405
415
|
@wrappers = options[:wrappers]
|
406
416
|
@bin_dir = options[:bin_dir]
|
407
417
|
@development = options[:development]
|
408
|
-
@source_index = options[:source_index]
|
409
|
-
end
|
410
418
|
|
411
|
-
|
412
|
-
|
413
|
-
@format = Gem::Format.from_file_by_path @gem, @security_policy
|
414
|
-
rescue Gem::Package::FormatError
|
415
|
-
raise Gem::InstallError, "invalid gem format for #{@gem}"
|
416
|
-
end
|
419
|
+
raise "NOTE: Installer option :source_index is dead" if
|
420
|
+
options[:source_index]
|
417
421
|
end
|
418
422
|
|
419
423
|
def check_that_user_bin_dir_is_in_path
|
420
|
-
user_bin_dir = File.join
|
424
|
+
user_bin_dir = File.join gem_home, "bin"
|
421
425
|
unless ENV['PATH'].split(File::PATH_SEPARATOR).include? user_bin_dir then
|
422
426
|
unless self.class.path_warning then
|
423
427
|
alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run."
|
@@ -427,21 +431,21 @@ class Gem::Installer
|
|
427
431
|
end
|
428
432
|
|
429
433
|
def verify_gem_home(unpack = false)
|
430
|
-
FileUtils.mkdir_p
|
431
|
-
raise Gem::FilePermissionError,
|
432
|
-
unpack or File.writable?
|
434
|
+
FileUtils.mkdir_p gem_home
|
435
|
+
raise Gem::FilePermissionError, gem_home unless
|
436
|
+
unpack or File.writable?(gem_home)
|
433
437
|
end
|
434
438
|
|
435
439
|
##
|
436
440
|
# Return the text for an application file.
|
437
441
|
|
438
442
|
def app_script_text(bin_file_name)
|
439
|
-
<<-TEXT
|
443
|
+
return <<-TEXT
|
440
444
|
#{shebang bin_file_name}
|
441
445
|
#
|
442
446
|
# This file was generated by RubyGems.
|
443
447
|
#
|
444
|
-
# The application '#{
|
448
|
+
# The application '#{spec.name}' is installed as part of a gem, and
|
445
449
|
# this file is here to facilitate running it.
|
446
450
|
#
|
447
451
|
|
@@ -454,8 +458,8 @@ if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
|
|
454
458
|
ARGV.shift
|
455
459
|
end
|
456
460
|
|
457
|
-
gem '#{
|
458
|
-
load Gem.bin_path('#{
|
461
|
+
gem '#{spec.name}', version
|
462
|
+
load Gem.bin_path('#{spec.name}', '#{bin_file_name}', version)
|
459
463
|
TEXT
|
460
464
|
end
|
461
465
|
|
@@ -463,14 +467,16 @@ TEXT
|
|
463
467
|
# return the stub script text used to launch the true ruby script
|
464
468
|
|
465
469
|
def windows_stub_script(bindir, bin_file_name)
|
466
|
-
|
470
|
+
ruby = File.basename(Gem.ruby).chomp('"')
|
471
|
+
return <<-TEXT
|
467
472
|
@ECHO OFF
|
468
473
|
IF NOT "%~f0" == "~f0" GOTO :WinNT
|
469
|
-
@"#{
|
474
|
+
@"#{ruby}" "#{File.join(bindir, bin_file_name)}" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
470
475
|
GOTO :EOF
|
471
476
|
:WinNT
|
472
|
-
@"#{
|
477
|
+
@"#{ruby}" "%~dpn0" %*
|
473
478
|
TEXT
|
479
|
+
|
474
480
|
end
|
475
481
|
|
476
482
|
##
|
@@ -478,12 +484,12 @@ TEXT
|
|
478
484
|
# configure scripts and rakefiles or mkrf_conf files.
|
479
485
|
|
480
486
|
def build_extensions
|
481
|
-
return if
|
487
|
+
return if spec.extensions.empty?
|
482
488
|
say "Building native extensions. This could take a while..."
|
483
|
-
dest_path = File.join
|
489
|
+
dest_path = File.join gem_dir, spec.require_paths.first
|
484
490
|
ran_rake = false # only run rake once
|
485
491
|
|
486
|
-
|
492
|
+
spec.extensions.each do |extension|
|
487
493
|
break if ran_rake
|
488
494
|
results = []
|
489
495
|
|
@@ -502,15 +508,15 @@ TEXT
|
|
502
508
|
|
503
509
|
|
504
510
|
extension_dir = begin
|
505
|
-
File.join
|
511
|
+
File.join gem_dir, File.dirname(extension)
|
506
512
|
rescue TypeError # extension == nil
|
507
|
-
|
513
|
+
gem_dir
|
508
514
|
end
|
509
515
|
|
510
516
|
|
511
517
|
begin
|
512
518
|
Dir.chdir extension_dir do
|
513
|
-
results = builder.build(extension,
|
519
|
+
results = builder.build(extension, gem_dir, dest_path, results)
|
514
520
|
|
515
521
|
say results.join("\n") if Gem.configuration.really_verbose
|
516
522
|
end
|
@@ -526,7 +532,7 @@ ERROR: Failed to build gem native extension.
|
|
526
532
|
|
527
533
|
#{results}
|
528
534
|
|
529
|
-
Gem files will remain installed in #{
|
535
|
+
Gem files will remain installed in #{gem_dir} for inspection.
|
530
536
|
Results logged to #{gem_make_out}
|
531
537
|
EOF
|
532
538
|
|
@@ -541,35 +547,27 @@ EOF
|
|
541
547
|
# Ensures that files can't be installed outside the gem directory.
|
542
548
|
|
543
549
|
def extract_files
|
544
|
-
@gem_dir = File.expand_path @gem_dir
|
545
|
-
|
546
550
|
raise ArgumentError, "format required to extract from" if @format.nil?
|
547
551
|
|
548
|
-
dirs = []
|
549
|
-
|
550
552
|
@format.file_entries.each do |entry, file_data|
|
551
553
|
path = entry['path'].untaint
|
552
554
|
|
553
|
-
if path
|
554
|
-
raise Gem::InstallError,
|
555
|
-
"attempt to install file into #{entry['path'].inspect}"
|
555
|
+
if path.start_with? "/" then # for extra sanity
|
556
|
+
raise Gem::InstallError, "attempt to install file into #{entry['path']}"
|
556
557
|
end
|
557
558
|
|
558
|
-
path = File.expand_path File.join(
|
559
|
+
path = File.expand_path File.join(gem_dir, path)
|
559
560
|
|
560
|
-
|
561
|
-
msg = "attempt to install file into %p under %
|
562
|
-
[entry['path'],
|
561
|
+
unless path.start_with? gem_dir then
|
562
|
+
msg = "attempt to install file into %p under %s" %
|
563
|
+
[entry['path'], gem_dir]
|
563
564
|
raise Gem::InstallError, msg
|
564
565
|
end
|
565
566
|
|
566
|
-
FileUtils.rm_rf(path) if File.
|
567
|
+
FileUtils.rm_rf(path) if File.exist? path
|
567
568
|
|
568
|
-
dir = File.dirname
|
569
|
-
|
570
|
-
dirs << dir
|
571
|
-
FileUtils.mkdir_p dir
|
572
|
-
end
|
569
|
+
dir = File.dirname path
|
570
|
+
FileUtils.mkdir_p dir unless File.exist? dir
|
573
571
|
|
574
572
|
File.open(path, "wb") do |out|
|
575
573
|
out.write file_data
|
@@ -592,5 +590,14 @@ EOF
|
|
592
590
|
end
|
593
591
|
end
|
594
592
|
|
593
|
+
##
|
594
|
+
#
|
595
|
+
# Return the target directory where the gem is to be installed. This
|
596
|
+
# directory is not guaranteed to be populated.
|
597
|
+
#
|
598
|
+
|
599
|
+
def dir
|
600
|
+
gem_dir.to_s
|
601
|
+
end
|
595
602
|
end
|
596
603
|
|