summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-19 21:23:04 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-19 21:23:04 +0000
commit64847a9cfe467b808ca5e8148dfa85a059198963 ()
treeb21ca4404f92f1fe269347a8d624cf188e7fbc97
parentdf2762fb1aaa82577b4e3e8df67cc56b7aefdfb8 (diff)
Importing rubygems @ c2d4131: Deal with platforms that have DLEXT2 == nil. Fixes RF#28867
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/rubygems.rb27
-rw-r--r--lib/rubygems/builder.rb3
-rw-r--r--lib/rubygems/commands/sources_command.rb14
-rw-r--r--lib/rubygems/install_update_options.rb14
-rw-r--r--lib/rubygems/installer.rb179
-rw-r--r--lib/rubygems/package.rb1
-rw-r--r--lib/rubygems/package/tar_output.rb2
-rw-r--r--test/rubygems/gemutilities.rb7
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb8
-rw-r--r--test/rubygems/test_gem_installer.rb108
10 files changed, 273 insertions, 90 deletions
@@ -193,6 +193,7 @@ module Gem
@ruby = nil
@sources = []
@post_install_hooks ||= []
@post_uninstall_hooks ||= []
@pre_uninstall_hooks ||= []
@@ -729,6 +730,17 @@ module Gem
end
##
# Adds a post-install hook that will be passed an Gem::Installer instance
# when Gem::Installer#install is called
@@ -747,7 +759,8 @@ module Gem
##
# Adds a pre-install hook that will be passed an Gem::Installer instance
- # when Gem::Installer#install is called
def self.pre_install(&hook)
@pre_install_hooks << hook
@@ -986,7 +999,8 @@ module Gem
'.rb',
*%w(DLEXT DLEXT2).map { |key|
val = RbConfig::CONFIG[key]
- ".#{val}" unless val.empty?
}
].compact.uniq
end
@@ -1097,6 +1111,12 @@ module Gem
attr_reader :loaded_specs
##
# The list of hooks to be run before Gem::Install#install does any work
attr_reader :post_install_hooks
@@ -1219,9 +1239,6 @@ end
##
# Enables the require hook for RubyGems.
-#
-# Ruby 1.9 allows --disable-gems, so we require it when we didn't detect a Gem
-# constant at rubygems.rb load time.
require 'rubygems/custom_require'
@@ -20,7 +20,6 @@ end
Gem.load_yaml
require 'rubygems/package'
-require 'rubygems/security'
##
# The Builder class processes RubyGem specification files
@@ -73,6 +72,8 @@ EOM
signer = nil
if @spec.respond_to?(:signing_key) and @spec.signing_key then
signer = Gem::Security::Signer.new @spec.signing_key, @spec.cert_chain
@spec.signing_key = nil
@spec.cert_chain = signer.cert_chain.map { |cert| cert.to_s }
@@ -57,12 +57,16 @@ class Gem::Commands::SourcesCommand < Gem::Command
path = Gem::SpecFetcher.fetcher.dir
FileUtils.rm_rf path
- if not File.exist?(path) then
say "*** Removed specs cache ***"
- elsif not File.writable?(path) then
- say "*** Unable to remove source cache (write protected) ***"
else
- say "*** Unable to remove source cache ***"
end
end
@@ -78,8 +82,10 @@ class Gem::Commands::SourcesCommand < Gem::Command
say "#{source_uri} added to sources"
rescue URI::Error, ArgumentError
say "#{source_uri} is not a URI"
rescue Gem::RemoteFetcher::FetchError => e
say "Error fetching #{source_uri}:\n\t#{e.message}"
end
end
@@ -11,7 +11,13 @@
#++
require 'rubygems'
-require 'rubygems/security'
##
# Mixin methods for install and update options for Gem::Commands
@@ -23,8 +29,12 @@ module Gem::InstallUpdateOptions
def add_install_update_options
OptionParser.accept Gem::Security::Policy do |value|
value = Gem::Security::Policies[value]
- raise OptionParser::InvalidArgument, value if value.nil?
value
end
@@ -24,7 +24,7 @@ require 'rubygems/require_paths_builder'
# gemspec in the specifications dir, storing the cached gem in the cache dir,
# and installing either wrappers or symlinks for executables.
#
-# The installer fires pre and post install hooks. Hooks can be added either
# through a rubygems_plugin.rb file in an installed gem or via a
# rubygems/defaults/#{RUBY_ENGINE}.rb or rubygems/defaults/operating_system.rb
# file. See Gem.pre_install and Gem.post_install for details.
@@ -61,6 +61,11 @@ class Gem::Installer
attr_reader :spec
@path_warning = false
class << self
@@ -98,49 +103,16 @@ class Gem::Installer
require 'fileutils'
@gem = gem
-
- options = {
- :bin_dir => nil,
- :env_shebang => false,
- :exec_format => false,
- :force => false,
- :install_dir => Gem.dir,
- :source_index => Gem.source_index,
- }.merge options
-
- @env_shebang = options[:env_shebang]
- @force = options[:force]
- gem_home = options[:install_dir]
- @gem_home = File.expand_path(gem_home)
- @ignore_dependencies = options[:ignore_dependencies]
- @format_executable = options[:format_executable]
- @security_policy = options[:security_policy]
- @wrappers = options[:wrappers]
- @bin_dir = options[:bin_dir]
- @development = options[:development]
- @source_index = options[:source_index]
-
- begin
- @format = Gem::Format.from_file_by_path @gem, @security_policy
- rescue Gem::Package::FormatError
- raise Gem::InstallError, "invalid gem format for #{@gem}"
- end
if options[:user_install] and not options[:unpack] then
@gem_home = Gem.user_dir
-
- user_bin_dir = File.join(@gem_home, 'bin')
- unless ENV['PATH'].split(File::PATH_SEPARATOR).include? user_bin_dir then
- unless self.class.path_warning then
- alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run."
- self.class.path_warning = true
- end
- end
end
- FileUtils.mkdir_p @gem_home
- raise Gem::FilePermissionError, @gem_home unless
- options[:unpack] or File.writable? @gem_home
@spec = @format.spec
@@ -160,48 +132,48 @@ class Gem::Installer
def install
# If we're forcing the install then disable security unless the security
- # policy says that we only install singed gems.
@security_policy = nil if @force and @security_policy and
not @security_policy.only_signed
- unless @force then
- if rrv = @spec.required_ruby_version then
- unless rrv.satisfied_by? Gem.ruby_version then
- raise Gem::InstallError, "#{@spec.name} requires Ruby version #{rrv}."
- end
- end
- if rrgv = @spec.required_rubygems_version then
- unless rrgv.satisfied_by? Gem::Version.new(Gem::VERSION) then
- raise Gem::InstallError,
- "#{@spec.name} requires RubyGems version #{rrgv}. " +
- "Try 'gem update --system' to update RubyGems itself."
- end
- end
- unless @ignore_dependencies then
- deps = @spec.runtime_dependencies
- deps |= @spec.development_dependencies if @development
- deps.each do |dep_gem|
- ensure_dependency @spec, dep_gem
- end
end
end
- Gem.pre_install_hooks.each do |hook|
- hook.call self
- end
-
- FileUtils.mkdir_p @gem_home unless File.directory? @gem_home
-
Gem.ensure_gem_subdirectories @gem_home
FileUtils.mkdir_p @gem_dir
extract_files
- generate_bin
build_extensions
write_spec
write_require_paths_file_if_needed if QUICKLOADER_SUCKAGE
@@ -238,7 +210,6 @@ class Gem::Installer
unless installation_satisfies_dependency? dependency then
raise Gem::InstallError, "#{spec.name} requires #{dependency}"
end
-
true
end
@@ -388,6 +359,80 @@ class Gem::Installer
end
end
##
# Return the text for an application file.
@@ -10,7 +10,6 @@
# See LICENSE.txt for additional licensing information.
#++
-require 'rubygems/security'
require 'rubygems/specification'
##
@@ -85,6 +85,7 @@ class Gem::Package::TarOutput
# if we have a signing key, then sign the data
# digest and return the signature
if @signer then
digest = Gem::Security::OPT[:dgst_algo].digest sio.string
@data_signature = @signer.sign digest
inner.write sio.string
@@ -113,6 +114,7 @@ class Gem::Package::TarOutput
# if we have a signing key, then sign the metadata digest and return
# the signature
if @signer then
digest = Gem::Security::OPT[:dgst_algo].digest sio.string
@meta_signature = @signer.sign digest
io.write sio.string
@@ -130,11 +130,17 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
@public_cert = File.expand_path File.join(File.dirname(__FILE__),
'public_cert.pem')
Gem.post_install_hooks.clear
Gem.post_uninstall_hooks.clear
Gem.pre_install_hooks.clear
Gem.pre_uninstall_hooks.clear
Gem.post_install do |installer|
@post_install_hook_arg = installer
end
@@ -145,6 +151,7 @@ class RubyGemTestCase < MiniTest::Unit::TestCase
Gem.pre_install do |installer|
@pre_install_hook_arg = installer
end
Gem.pre_uninstall do |uninstaller|
@@ -90,7 +90,9 @@ class TestGemCommandsSourcesCommand < RubyGemTestCase
util_setup_spec_fetcher
use_ui @ui do
- @cmd.execute
end
expected = <<-EOF
@@ -108,7 +110,9 @@ Error fetching http://beta-gems.example.com:
util_setup_spec_fetcher
use_ui @ui do
- @cmd.execute
end
assert_equal [@gem_repo], Gem.sources
@@ -521,15 +521,27 @@ load Gem.bin_path('a', 'my_exec', version)
def test_install
Dir.mkdir util_inst_bindir
util_setup_gem
cache_file = File.join @gemhome, 'cache', @spec.file_name
Gem.pre_install do |installer|
- refute File.exist?(cache_file), 'cache file should not exist yet'
end
Gem.post_install do |installer|
- assert File.exist?(cache_file), 'cache file should exist'
end
build_rake_in do
@@ -538,25 +550,27 @@ load Gem.bin_path('a', 'my_exec', version)
end
end
- gemdir = File.join @gemhome, 'gems', @spec.full_name
- assert File.exist?(gemdir)
- exe = File.join(gemdir, 'bin', 'executable')
- assert File.exist?(exe)
exe_mode = File.stat(exe).mode & 0111
assert_equal 0111, exe_mode, "0%o" % exe_mode unless win_platform?
assert File.exist?(File.join(gemdir, 'lib', 'code.rb'))
- assert File.exist?(File.join(gemdir, 'ext', 'a', 'Rakefile'))
spec_file = File.join(@gemhome, 'specifications', @spec.spec_name)
assert_equal spec_file, @spec.loaded_from
assert File.exist?(spec_file)
- assert_same @installer, @pre_install_hook_arg
assert_same @installer, @post_install_hook_arg
end
def test_install_bad_gem
@@ -669,6 +683,84 @@ load Gem.bin_path('a', 'my_exec', version)
assert File.exist?(File.join(@gemhome, 'specifications', @spec.spec_name))
end
def test_install_with_message
@spec.post_install_message = 'I am a shiny gem!'