mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rubygems: Update to RubyGems master ddac51f. Changes:
* Allow override for the shared gem installation directory for rubygems packagers. * Lock gem cache files for read and write to improve thread safety. * Use io/console when available. * Minor cleanup. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c2dcb947aa
commit
8fadbe5f3e
12 changed files with 115 additions and 67 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
Fri Dec 13 09:50:49 2013 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
|
* lib/rubygems: Update to RubyGems master ddac51f. Changes:
|
||||||
|
|
||||||
|
* Allow override for the shared gem installation directory for
|
||||||
|
rubygems packagers.
|
||||||
|
|
||||||
|
* Lock gem cache files for read and write to improve thread safety.
|
||||||
|
|
||||||
|
* Use io/console when available.
|
||||||
|
|
||||||
|
* Minor cleanup.
|
||||||
|
|
||||||
|
* test/rubygems: ditto.
|
||||||
|
|
||||||
Fri Dec 13 08:15:31 2013 Aman Gupta <ruby@tmm1.net>
|
Fri Dec 13 08:15:31 2013 Aman Gupta <ruby@tmm1.net>
|
||||||
|
|
||||||
* class.c (include_modules_at): use RCLASS_M_TBL_WRAPPER for
|
* class.c (include_modules_at): use RCLASS_M_TBL_WRAPPER for
|
||||||
|
|
|
@ -764,7 +764,10 @@ module Gem
|
||||||
# Safely read a file in binary mode on all platforms.
|
# Safely read a file in binary mode on all platforms.
|
||||||
|
|
||||||
def self.read_binary(path)
|
def self.read_binary(path)
|
||||||
File.open path, binary_mode do |f| f.read end
|
File.open path, binary_mode do |f|
|
||||||
|
f.flock(File::LOCK_EX)
|
||||||
|
f.read
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -1163,17 +1166,18 @@ module Gem
|
||||||
autoload :ConfigFile, 'rubygems/config_file'
|
autoload :ConfigFile, 'rubygems/config_file'
|
||||||
autoload :Dependency, 'rubygems/dependency'
|
autoload :Dependency, 'rubygems/dependency'
|
||||||
autoload :DependencyList, 'rubygems/dependency_list'
|
autoload :DependencyList, 'rubygems/dependency_list'
|
||||||
autoload :Resolver, 'rubygems/resolver'
|
|
||||||
autoload :DependencyResolver, 'rubygems/resolver'
|
autoload :DependencyResolver, 'rubygems/resolver'
|
||||||
|
autoload :Installer, 'rubygems/installer'
|
||||||
autoload :PathSupport, 'rubygems/path_support'
|
autoload :PathSupport, 'rubygems/path_support'
|
||||||
autoload :Platform, 'rubygems/platform'
|
autoload :Platform, 'rubygems/platform'
|
||||||
autoload :RequestSet, 'rubygems/request_set'
|
autoload :RequestSet, 'rubygems/request_set'
|
||||||
autoload :Requirement, 'rubygems/requirement'
|
autoload :Requirement, 'rubygems/requirement'
|
||||||
|
autoload :Resolver, 'rubygems/resolver'
|
||||||
|
autoload :Source, 'rubygems/source'
|
||||||
autoload :SourceList, 'rubygems/source_list'
|
autoload :SourceList, 'rubygems/source_list'
|
||||||
autoload :SpecFetcher, 'rubygems/spec_fetcher'
|
autoload :SpecFetcher, 'rubygems/spec_fetcher'
|
||||||
autoload :Specification, 'rubygems/specification'
|
autoload :Specification, 'rubygems/specification'
|
||||||
autoload :Version, 'rubygems/version'
|
autoload :Version, 'rubygems/version'
|
||||||
autoload :Source, 'rubygems/source'
|
|
||||||
|
|
||||||
require "rubygems/specification"
|
require "rubygems/specification"
|
||||||
end
|
end
|
||||||
|
|
|
@ -72,9 +72,16 @@ class Gem::BasicSpecification
|
||||||
# Returns full path to the directory where gem's extensions are installed.
|
# Returns full path to the directory where gem's extensions are installed.
|
||||||
|
|
||||||
def extension_dir
|
def extension_dir
|
||||||
@extension_dir ||=
|
@extension_dir ||= File.expand_path File.join(extensions_dir, full_name)
|
||||||
File.join base_dir, 'extensions', Gem::Platform.local.to_s,
|
end
|
||||||
Gem.extension_api_version, full_name
|
|
||||||
|
##
|
||||||
|
# Returns path to the extensions directory.
|
||||||
|
|
||||||
|
def extensions_dir
|
||||||
|
@extensions_dir ||= Gem.default_ext_dir_for(base_dir) ||
|
||||||
|
File.join(base_dir, 'extensions', Gem::Platform.local.to_s,
|
||||||
|
Gem.extension_api_version)
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_full_gem_path # :nodoc:
|
def find_full_gem_path # :nodoc:
|
||||||
|
@ -147,7 +154,9 @@ class Gem::BasicSpecification
|
||||||
@loaded_from = path && path.to_s
|
@loaded_from = path && path.to_s
|
||||||
|
|
||||||
@extension_dir = nil
|
@extension_dir = nil
|
||||||
|
@extensions_dir = nil
|
||||||
@full_gem_path = nil
|
@full_gem_path = nil
|
||||||
|
@gem_dir = nil
|
||||||
@gems_dir = nil
|
@gems_dir = nil
|
||||||
@base_dir = nil
|
@base_dir = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,6 +51,17 @@ module Gem
|
||||||
@default_dir ||= File.join(*path)
|
@default_dir ||= File.join(*path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns binary extensions dir for specified RubyGems base dir or nil
|
||||||
|
# if such directory cannot be determined.
|
||||||
|
#
|
||||||
|
# By default, the binary extensions are located side by side with their
|
||||||
|
# Ruby counterparts, therefore nil is returned
|
||||||
|
|
||||||
|
def self.default_ext_dir_for base_dir
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Paths where RubyGems' .rb files and bin files are installed
|
# Paths where RubyGems' .rb files and bin files are installed
|
||||||
|
|
||||||
|
|
|
@ -292,6 +292,7 @@ class Gem::RemoteFetcher
|
||||||
|
|
||||||
if update and path then
|
if update and path then
|
||||||
open(path, 'wb') do |io|
|
open(path, 'wb') do |io|
|
||||||
|
io.flock(File::LOCK_EX)
|
||||||
io.write data
|
io.write data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'rubygems/dependency'
|
|
||||||
require 'rubygems/dependency_list'
|
|
||||||
require 'rubygems/installer'
|
|
||||||
require 'rubygems/resolver'
|
|
||||||
require 'tsort'
|
require 'tsort'
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -9,9 +9,7 @@ require 'rubygems/util'
|
||||||
# source =
|
# source =
|
||||||
# Gem::Source::Git.new 'rake', 'git@example:rake.git', 'rake-10.1.0', false
|
# Gem::Source::Git.new 'rake', 'git@example:rake.git', 'rake-10.1.0', false
|
||||||
#
|
#
|
||||||
# spec = source.load_spec 'rake'
|
# source.specs
|
||||||
#
|
|
||||||
# source.checkout
|
|
||||||
|
|
||||||
class Gem::Source::Git < Gem::Source
|
class Gem::Source::Git < Gem::Source
|
||||||
|
|
||||||
|
@ -187,15 +185,13 @@ class Gem::Source::Git < Gem::Source
|
||||||
Dir.chdir directory do
|
Dir.chdir directory do
|
||||||
spec = Gem::Specification.load file
|
spec = Gem::Specification.load file
|
||||||
if spec then
|
if spec then
|
||||||
loaded_from = File.expand_path file
|
|
||||||
spec.loaded_from = loaded_from
|
|
||||||
spec.base_dir = base_dir
|
spec.base_dir = base_dir
|
||||||
|
|
||||||
spec.extension_dir =
|
spec.extension_dir =
|
||||||
File.join base_dir, 'extensions', Gem::Platform.local.to_s,
|
File.join base_dir, 'extensions', Gem::Platform.local.to_s,
|
||||||
Gem.extension_api_version, "#{name}-#{dir_shortref}"
|
Gem.extension_api_version, "#{name}-#{dir_shortref}"
|
||||||
|
|
||||||
spec.full_gem_path = File.dirname loaded_from if spec
|
spec.full_gem_path = File.dirname spec.loaded_from if spec
|
||||||
end
|
end
|
||||||
spec
|
spec
|
||||||
end
|
end
|
||||||
|
|
|
@ -1916,7 +1916,6 @@ class Gem::Specification < Gem::BasicSpecification
|
||||||
@cache_dir = nil
|
@cache_dir = nil
|
||||||
@cache_file = nil
|
@cache_file = nil
|
||||||
@doc_dir = nil
|
@doc_dir = nil
|
||||||
@gem_dir = nil
|
|
||||||
@ri_dir = nil
|
@ri_dir = nil
|
||||||
@spec_dir = nil
|
@spec_dir = nil
|
||||||
@spec_file = nil
|
@spec_file = nil
|
||||||
|
|
|
@ -24,16 +24,19 @@ unless Gem::Dependency.new('rdoc', '>= 3.10').matching_specs.empty?
|
||||||
gem 'json'
|
gem 'json'
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'rubygems/deprecate'
|
|
||||||
require 'minitest/autorun'
|
require 'minitest/autorun'
|
||||||
|
|
||||||
|
require 'rubygems/deprecate'
|
||||||
|
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
require 'pathname'
|
||||||
|
require 'pp'
|
||||||
|
require 'rubygems/package'
|
||||||
|
require 'shellwords'
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'rubygems/package'
|
|
||||||
require 'pp'
|
|
||||||
require 'zlib'
|
require 'zlib'
|
||||||
require 'pathname'
|
|
||||||
require 'shellwords'
|
|
||||||
Gem.load_yaml
|
Gem.load_yaml
|
||||||
|
|
||||||
require 'rubygems/mock_gem_ui'
|
require 'rubygems/mock_gem_ui'
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
|
begin
|
||||||
|
require 'io/console'
|
||||||
|
rescue LoadError
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Module that defines the default UserInteraction. Any class including this
|
# Module that defines the default UserInteraction. Any class including this
|
||||||
# module will have access to the +ui+ method that returns the default UI.
|
# module will have access to the +ui+ method that returns the default UI.
|
||||||
|
@ -283,41 +288,27 @@ class Gem::StreamUI
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
if RUBY_VERSION > '1.9.2' then
|
##
|
||||||
##
|
# Ask for a password. Does not echo response to terminal.
|
||||||
# Ask for a password. Does not echo response to terminal.
|
|
||||||
|
|
||||||
def ask_for_password(question)
|
def ask_for_password(question)
|
||||||
return nil if not tty?
|
return nil if not tty?
|
||||||
|
|
||||||
require 'io/console'
|
@outs.print(question, " ")
|
||||||
|
@outs.flush
|
||||||
|
|
||||||
@outs.print(question + " ")
|
password = _gets_noecho
|
||||||
@outs.flush
|
@outs.puts
|
||||||
|
password.chomp! if password
|
||||||
|
password
|
||||||
|
end
|
||||||
|
|
||||||
password = @ins.noecho {@ins.gets}
|
if IO.method_defined?(:noecho) then
|
||||||
password.chomp! if password
|
def _gets_noecho
|
||||||
password
|
@ins.noecho {@ins.gets}
|
||||||
end
|
end
|
||||||
else
|
elsif Gem.win_platform?
|
||||||
##
|
def _gets_noecho
|
||||||
# Ask for a password. Does not echo response to terminal.
|
|
||||||
|
|
||||||
def ask_for_password(question)
|
|
||||||
return nil if not tty?
|
|
||||||
|
|
||||||
@outs.print(question + " ")
|
|
||||||
@outs.flush
|
|
||||||
|
|
||||||
Gem.win_platform? ? ask_for_password_on_windows : ask_for_password_on_unix
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
|
||||||
# Asks for a password that works on windows. Ripped from the Heroku gem.
|
|
||||||
|
|
||||||
def ask_for_password_on_windows
|
|
||||||
return nil if not tty?
|
|
||||||
|
|
||||||
require "Win32API"
|
require "Win32API"
|
||||||
char = nil
|
char = nil
|
||||||
password = ''
|
password = ''
|
||||||
|
@ -330,22 +321,16 @@ class Gem::StreamUI
|
||||||
password << char.chr
|
password << char.chr
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts
|
|
||||||
password
|
password
|
||||||
end
|
end
|
||||||
|
else
|
||||||
##
|
def _gets_noecho
|
||||||
# Asks for a password that works on unix
|
|
||||||
|
|
||||||
def ask_for_password_on_unix
|
|
||||||
return nil if not tty?
|
|
||||||
|
|
||||||
system "stty -echo"
|
system "stty -echo"
|
||||||
password = @ins.gets
|
begin
|
||||||
password.chomp! if password
|
@ins.gets
|
||||||
system "stty echo"
|
ensure
|
||||||
password
|
system "stty echo"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ Added '/CN=alternate/DC=example'
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
||||||
output = @build_ui.output.split "\n"
|
output = @build_ui.output.squeeze("\n").split "\n"
|
||||||
|
|
||||||
assert_equal "Passphrase for your Private Key: ",
|
assert_equal "Passphrase for your Private Key: ",
|
||||||
output.shift
|
output.shift
|
||||||
|
@ -142,7 +142,7 @@ Added '/CN=alternate/DC=example'
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
||||||
output = @build_ui.output.split "\n"
|
output = @build_ui.output.squeeze("\n").split "\n"
|
||||||
|
|
||||||
assert_equal "Passphrase for your Private Key: ",
|
assert_equal "Passphrase for your Private Key: ",
|
||||||
output.shift
|
output.shift
|
||||||
|
|
|
@ -1461,6 +1461,35 @@ dependencies: []
|
||||||
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
|
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_extension_dir_override
|
||||||
|
enable_shared, RbConfig::CONFIG['ENABLE_SHARED'] =
|
||||||
|
RbConfig::CONFIG['ENABLE_SHARED'], 'no'
|
||||||
|
|
||||||
|
class << Gem
|
||||||
|
alias orig_default_ext_dir_for default_ext_dir_for
|
||||||
|
|
||||||
|
def Gem.default_ext_dir_for(base_dir)
|
||||||
|
'elsewhere'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ext_spec
|
||||||
|
|
||||||
|
refute_empty @ext.extensions
|
||||||
|
|
||||||
|
expected = File.join @tempdir, 'elsewhere', @ext.full_name
|
||||||
|
|
||||||
|
assert_equal expected, @ext.extension_dir
|
||||||
|
ensure
|
||||||
|
RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared
|
||||||
|
|
||||||
|
class << Gem
|
||||||
|
remove_method :default_ext_dir_for
|
||||||
|
|
||||||
|
alias default_ext_dir_for orig_default_ext_dir_for
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_files
|
def test_files
|
||||||
@a1.files = %w(files bin/common)
|
@a1.files = %w(files bin/common)
|
||||||
@a1.test_files = %w(test_files bin/common)
|
@a1.test_files = %w(test_files bin/common)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue