ruby-changes:32078
From: drbrain <ko1@a...>
Date: Fri, 13 Dec 2013 09:51:14 +0900 (JST)
Subject: [ruby-changes:32078] drbrain:r44157 (trunk): * lib/rubygems: Update to RubyGems master ddac51f. Changes:
drbrain 2013-12-13 09:51:04 +0900 (Fri, 13 Dec 2013) New Revision: 44157 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44157 Log: * 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. Modified files: trunk/ChangeLog trunk/lib/rubygems/basic_specification.rb trunk/lib/rubygems/defaults.rb trunk/lib/rubygems/remote_fetcher.rb trunk/lib/rubygems/request_set.rb trunk/lib/rubygems/source/git.rb trunk/lib/rubygems/specification.rb trunk/lib/rubygems/test_case.rb trunk/lib/rubygems/user_interaction.rb trunk/lib/rubygems.rb trunk/test/rubygems/test_gem_commands_cert_command.rb trunk/test/rubygems/test_gem_specification.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 44156) +++ ChangeLog (revision 44157) @@ -1,3 +1,18 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Dec 13 09:50:49 2013 Eric Hodel <drbrain@s...> + + * 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@t...> * class.c (include_modules_at): use RCLASS_M_TBL_WRAPPER for Index: lib/rubygems/basic_specification.rb =================================================================== --- lib/rubygems/basic_specification.rb (revision 44156) +++ lib/rubygems/basic_specification.rb (revision 44157) @@ -72,9 +72,16 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L72 # Returns full path to the directory where gem's extensions are installed. def extension_dir - @extension_dir ||= - File.join base_dir, 'extensions', Gem::Platform.local.to_s, - Gem.extension_api_version, full_name + @extension_dir ||= File.expand_path File.join(extensions_dir, full_name) + end + + ## + # 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 def find_full_gem_path # :nodoc: @@ -147,7 +154,9 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L154 @loaded_from = path && path.to_s @extension_dir = nil + @extensions_dir = nil @full_gem_path = nil + @gem_dir = nil @gems_dir = nil @base_dir = nil end Index: lib/rubygems/request_set.rb =================================================================== --- lib/rubygems/request_set.rb (revision 44156) +++ lib/rubygems/request_set.rb (revision 44157) @@ -1,8 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L1 require 'rubygems' -require 'rubygems/dependency' -require 'rubygems/dependency_list' -require 'rubygems/installer' -require 'rubygems/resolver' require 'tsort' ## Index: lib/rubygems/specification.rb =================================================================== --- lib/rubygems/specification.rb (revision 44156) +++ lib/rubygems/specification.rb (revision 44157) @@ -1916,7 +1916,6 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1916 @cache_dir = nil @cache_file = nil @doc_dir = nil - @gem_dir = nil @ri_dir = nil @spec_dir = nil @spec_file = nil Index: lib/rubygems/source/git.rb =================================================================== --- lib/rubygems/source/git.rb (revision 44156) +++ lib/rubygems/source/git.rb (revision 44157) @@ -9,9 +9,7 @@ require 'rubygems/util' https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/git.rb#L9 # source = # Gem::Source::Git.new 'rake', 'git@example:rake.git', 'rake-10.1.0', false # -# spec = source.load_spec 'rake' -# -# source.checkout +# source.specs class Gem::Source::Git < Gem::Source @@ -187,15 +185,13 @@ class Gem::Source::Git < Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/git.rb#L185 Dir.chdir directory do spec = Gem::Specification.load file if spec then - loaded_from = File.expand_path file - spec.loaded_from = loaded_from spec.base_dir = base_dir spec.extension_dir = File.join base_dir, 'extensions', Gem::Platform.local.to_s, 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 spec end Index: lib/rubygems/user_interaction.rb =================================================================== --- lib/rubygems/user_interaction.rb (revision 44156) +++ lib/rubygems/user_interaction.rb (revision 44157) @@ -4,6 +4,11 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/user_interaction.rb#L4 # See LICENSE.txt for permissions. #++ +begin + require 'io/console' +rescue LoadError +end + ## # Module that defines the default UserInteraction. Any class including this # module will have access to the +ui+ method that returns the default UI. @@ -283,41 +288,27 @@ class Gem::StreamUI https://github.com/ruby/ruby/blob/trunk/lib/rubygems/user_interaction.rb#L288 result end - if RUBY_VERSION > '1.9.2' then - ## - # Ask for a password. Does not echo response to terminal. - - def ask_for_password(question) - return nil if not tty? - - require 'io/console' - - @outs.print(question + " ") - @outs.flush + ## + # Ask for a password. Does not echo response to terminal. - password = @ins.noecho {@ins.gets} - password.chomp! if password - password - end - else - ## - # Ask for a password. Does not echo response to terminal. + def ask_for_password(question) + return nil if not tty? - def ask_for_password(question) - return nil if not tty? + @outs.print(question, " ") + @outs.flush - @outs.print(question + " ") - @outs.flush + password = _gets_noecho + @outs.puts + password.chomp! if password + password + end - Gem.win_platform? ? ask_for_password_on_windows : ask_for_password_on_unix + if IO.method_defined?(:noecho) then + def _gets_noecho + @ins.noecho {@ins.gets} 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? - + elsif Gem.win_platform? + def _gets_noecho require "Win32API" char = nil password = '' @@ -330,22 +321,16 @@ class Gem::StreamUI https://github.com/ruby/ruby/blob/trunk/lib/rubygems/user_interaction.rb#L321 password << char.chr end end - - puts password end - - ## - # Asks for a password that works on unix - - def ask_for_password_on_unix - return nil if not tty? - + else + def _gets_noecho system "stty -echo" - password = @ins.gets - password.chomp! if password - system "stty echo" - password + begin + @ins.gets + ensure + system "stty echo" + end end end Index: lib/rubygems/remote_fetcher.rb =================================================================== --- lib/rubygems/remote_fetcher.rb (revision 44156) +++ lib/rubygems/remote_fetcher.rb (revision 44157) @@ -292,6 +292,7 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L292 if update and path then open(path, 'wb') do |io| + io.flock(File::LOCK_EX) io.write data end end Index: lib/rubygems/defaults.rb =================================================================== --- lib/rubygems/defaults.rb (revision 44156) +++ lib/rubygems/defaults.rb (revision 44157) @@ -52,6 +52,17 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems/defaults.rb#L52 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 def self.default_rubygems_dirs Index: lib/rubygems/test_case.rb =================================================================== --- lib/rubygems/test_case.rb (revision 44156) +++ lib/rubygems/test_case.rb (revision 44157) @@ -24,16 +24,19 @@ unless Gem::Dependency.new('rdoc', '>= 3 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L24 gem 'json' end -require 'rubygems/deprecate' require 'minitest/autorun' + +require 'rubygems/deprecate' + require 'fileutils' +require 'pathname' +require 'pp' +require 'rubygems/package' +require 'shellwords' require 'tmpdir' require 'uri' -require 'rubygems/package' -require 'pp' require 'zlib' -require 'pathname' -require 'shellwords' + Gem.load_yaml require 'rubygems/mock_gem_ui' Index: lib/rubygems.rb =================================================================== --- lib/rubygems.rb (revision 44156) +++ lib/rubygems.rb (revision 44157) @@ -764,7 +764,10 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L764 # Safely read a file in binary mode on all platforms. 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 ## @@ -1163,17 +1166,18 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L1166 autoload :ConfigFile, 'rubygems/config_file' autoload :Dependency, 'rubygems/dependency' autoload :DependencyList, 'rubygems/dependency_list' - autoload :Resolver, 'rubygems/resolver' autoload :DependencyResolver, 'rubygems/resolver' + autoload :Installer, 'rubygems/installer' autoload :PathSupport, 'rubygems/path_support' autoload :Platform, 'rubygems/platform' autoload :RequestSet, 'rubygems/request_set' autoload :Requirement, 'rubygems/requirement' + autoload :Resolver, 'rubygems/resolver' + autoload :Source, 'rubygems/source' autoload :SourceList, 'rubygems/source_list' autoload :SpecFetcher, 'rubygems/spec_fetcher' autoload :Specification, 'rubygems/specification' autoload :Version, 'rubygems/version' - autoload :Source, 'rubygems/source' require "rubygems/specification" end Index: test/rubygems/test_gem_commands_cert_command.rb =================================================================== --- test/rubygems/test_gem_commands_cert_command.rb (revision 44156) +++ test/rubygems/test_gem_commands_cert_command.rb (revision 44157) @@ -108,7 +108,7 @@ Added '/CN=alternate/DC=example' https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_cert_command.rb#L108 @cmd.execute end - output = @build_ui.output.split "\n" + output = @build_ui.output.squeeze("\n").split "\n" assert_equal "Passphrase for your Private Key: ", output.shift @@ -142,7 +142,7 @@ Added '/CN=alternate/DC=example' https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_cert_command.rb#L142 @cmd.execute end - output = @build_ui.output.split "\n" + output = @build_ui.output.squeeze("\n").split "\n" assert_equal "Passphrase for your Private Key: ", output.shift Index: test/rubygems/test_gem_specification.rb =================================================================== --- test/rubygems/test_gem_specification.rb (revision 44156) +++ test/rubygems/test_gem_specification.rb (revision 44157) @@ -1461,6 +1461,35 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1461 RbConfig::CONFIG['ENABLE_SHARED'] = enable_shared 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 @a1.files = %w(files bin/common) @a1.test_files = %w(test_files bin/common) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/