ruby-changes:31356
From: nagachika <ko1@a...>
Date: Sun, 27 Oct 2013 02:44:43 +0900 (JST)
Subject: [ruby-changes:31356] nagachika:r43435 (ruby_2_0_0): * lib/rubygems: Update to RubyGems 2.0.13.
nagachika 2013-10-27 02:44:33 +0900 (Sun, 27 Oct 2013) New Revision: 43435 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43435 Log: * lib/rubygems: Update to RubyGems 2.0.13. [ruby-core:58031] [Backport #9052] the patch is provided by drbrain (Eric Hodel). Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/NEWS branches/ruby_2_0_0/lib/rubygems/server.rb branches/ruby_2_0_0/lib/rubygems/source.rb branches/ruby_2_0_0/lib/rubygems/spec_fetcher.rb branches/ruby_2_0_0/lib/rubygems/version.rb branches/ruby_2_0_0/lib/rubygems.rb branches/ruby_2_0_0/test/rubygems/test_gem_server.rb branches/ruby_2_0_0/test/rubygems/test_gem_source.rb branches/ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb branches/ruby_2_0_0/test/rubygems/test_gem_version.rb branches/ruby_2_0_0/version.h Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 43434) +++ ruby_2_0_0/ChangeLog (revision 43435) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Sun Oct 27 01:04:28 2013 CHIKANAGA Tomoyuki <nagachika@r...> + + * lib/rubygems: Update to RubyGems 2.0.13. [ruby-core:58031] + [Backport #9052] + the patch is provided by drbrain (Eric Hodel). + Sat Oct 26 16:04:36 2013 CHIKANAGA Tomoyuki <nagachika@r...> * gc.c (gc_prof_set_heap_info): fix compile error when Index: ruby_2_0_0/lib/rubygems/spec_fetcher.rb =================================================================== --- ruby_2_0_0/lib/rubygems/spec_fetcher.rb (revision 43434) +++ ruby_2_0_0/lib/rubygems/spec_fetcher.rb (revision 43435) @@ -39,7 +39,12 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/spec_fetcher.rb#L39 def initialize @dir = File.join Gem.user_home, '.gem', 'specs' - @update_cache = File.stat(Gem.user_home).uid == Process.uid + @update_cache = + begin + File.stat(Gem.user_home).uid == Process.uid + rescue Errno::EACCES, Errno::ENOENT + false + end @specs = {} @latest_specs = {} Index: ruby_2_0_0/lib/rubygems/source.rb =================================================================== --- ruby_2_0_0/lib/rubygems/source.rb (revision 43434) +++ ruby_2_0_0/lib/rubygems/source.rb (revision 43435) @@ -63,7 +63,12 @@ class Gem::Source https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/source.rb#L63 end def update_cache? - @update_cache ||= File.stat(Gem.user_home).uid == Process.uid + @update_cache ||= + begin + File.stat(Gem.user_home).uid == Process.uid + rescue Errno::ENOENT + false + end end def fetch_spec(name) Index: ruby_2_0_0/lib/rubygems/version.rb =================================================================== --- ruby_2_0_0/lib/rubygems/version.rb (revision 43434) +++ ruby_2_0_0/lib/rubygems/version.rb (revision 43435) @@ -174,7 +174,7 @@ class Gem::Version https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/version.rb#L174 # REFACTOR: There's no real reason this should be separate from #initialize. def self.create input - if input.respond_to? :version then + if self === input then # check yourself before you wreck yourself input elsif input.nil? then nil Index: ruby_2_0_0/lib/rubygems/server.rb =================================================================== --- ruby_2_0_0/lib/rubygems/server.rb (revision 43434) +++ ruby_2_0_0/lib/rubygems/server.rb (revision 43435) @@ -445,7 +445,7 @@ div.method-source-code pre { color: #ffd https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/server.rb#L445 @spec_dirs = @gem_dirs.map { |gem_dir| File.join gem_dir, 'specifications' } @spec_dirs.reject! { |spec_dir| !File.directory? spec_dir } - Gem::Specification.dirs = @gem_dirs + reset_gems @have_rdoc_4_plus = nil end @@ -470,7 +470,7 @@ div.method-source-code pre { color: #ffd https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/server.rb#L470 end def latest_specs(req, res) - Gem::Specification.reset + reset_gems res['content-type'] = 'application/x-gzip' @@ -531,7 +531,7 @@ div.method-source-code pre { color: #ffd https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/server.rb#L531 end def quick(req, res) - Gem::Specification.reset + reset_gems res['content-type'] = 'text/plain' add_date res @@ -567,7 +567,8 @@ div.method-source-code pre { color: #ffd https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/server.rb#L567 end def root(req, res) - Gem::Specification.reset + reset_gems + add_date res raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found." unless @@ -698,6 +699,13 @@ div.method-source-code pre { color: #ffd https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/server.rb#L699 end ## + # Updates the server to use the latest installed gems. + + def reset_gems # :nodoc: + Gem::Specification.dirs = @gem_dirs + end + + ## # Returns true and prepares http response, if rdoc for the requested gem # name pattern was found. # @@ -787,7 +795,7 @@ div.method-source-code pre { color: #ffd https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/server.rb#L795 end def specs(req, res) - Gem::Specification.reset + reset_gems add_date res Index: ruby_2_0_0/lib/rubygems.rb =================================================================== --- ruby_2_0_0/lib/rubygems.rb (revision 43434) +++ ruby_2_0_0/lib/rubygems.rb (revision 43435) @@ -8,7 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems.rb#L8 require 'rbconfig' module Gem - VERSION = '2.0.12' + VERSION = '2.0.13' end # Must be first since it unloads the prelude from 1.9.2 Index: ruby_2_0_0/NEWS =================================================================== --- ruby_2_0_0/NEWS (revision 43434) +++ ruby_2_0_0/NEWS (revision 43435) @@ -461,9 +461,9 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/NEWS#L461 XML declaration is used for XML document encoding. * RubyGems - * Updated to 2.0.12. + * Updated to 2.0.13. - See http://rubygems.rubyforge.org/rubygems-update/History_txt.html#label-2.0.12+%2F+2013-10-14 + See http://rubygems.rubyforge.org/rubygems-update/History_txt.html#label-2.0.13+%2F+2013-10-24 for release notes. * Updated to 2.0.10. This fixes CVE_2013-4363: Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 43434) +++ ruby_2_0_0/version.h (revision 43435) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" -#define RUBY_RELEASE_DATE "2013-10-26" -#define RUBY_PATCHLEVEL 341 +#define RUBY_RELEASE_DATE "2013-10-27" +#define RUBY_PATCHLEVEL 342 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 26 +#define RUBY_RELEASE_DAY 27 #include "ruby/version.h" Index: ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb =================================================================== --- ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb (revision 43434) +++ ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb (revision 43435) @@ -52,6 +52,18 @@ class TestGemSpecFetcher < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb#L52 ['x', Gem::Version.new(1), 'ruby']] end + def test_initialize_unwritable_home_dir + skip 'chmod not supported' if Gem.win_platform? + + FileUtils.chmod 0000, Gem.user_home + + begin + assert Gem::SpecFetcher.new + ensure + FileUtils.chmod 0755, Gem.user_home + end + end + def test_spec_for_dependency_all d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}" @fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1)) Index: ruby_2_0_0/test/rubygems/test_gem_version.rb =================================================================== --- ruby_2_0_0/test/rubygems/test_gem_version.rb (revision 43434) +++ ruby_2_0_0/test/rubygems/test_gem_version.rb (revision 43435) @@ -23,14 +23,13 @@ class TestGemVersion < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_version.rb#L23 assert_bumped_version_equal "6", "5" end - # FIX: For "legacy reasons," any object that responds to +version+ - # is returned unchanged. I'm not certain why. + # A Gem::Version is already a Gem::Version and therefore not transformed by + # Gem::Version.create def test_class_create - fake = Object.new - def fake.version; "1.0" end + real = Gem::Version.new(1.0) - assert_same fake, Gem::Version.create(fake) + assert_same real, Gem::Version.create(real) assert_nil Gem::Version.create(nil) assert_equal v("5.1"), Gem::Version.create("5.1") Index: ruby_2_0_0/test/rubygems/test_gem_source.rb =================================================================== --- ruby_2_0_0/test/rubygems/test_gem_source.rb (revision 43434) +++ ruby_2_0_0/test/rubygems/test_gem_source.rb (revision 43435) @@ -184,5 +184,15 @@ class TestGemSource < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_source.rb#L184 end end + def test_update_cache_eh + assert @source.update_cache? + end + + def test_update_cache_eh_home_nonexistent + FileUtils.rmdir Gem.user_home + + refute @source.update_cache? + end + end Index: ruby_2_0_0/test/rubygems/test_gem_server.rb =================================================================== --- ruby_2_0_0/test/rubygems/test_gem_server.rb (revision 43434) +++ ruby_2_0_0/test/rubygems/test_gem_server.rb (revision 43435) @@ -85,6 +85,30 @@ class TestGemServer < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_server.rb#L85 Marshal.load(@res.body) end + def test_latest_specs_gemdirs + data = StringIO.new "GET /latest_specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n" + dir = "#{@gemhome}2" + + spec = quick_spec 'z', 9 + + specs_dir = File.join dir, 'specifications' + FileUtils.mkdir_p specs_dir + + open File.join(specs_dir, spec.spec_name), 'w' do |io| + io.write spec.to_ruby + end + + server = Gem::Server.new dir, process_based_port, false + + @req.parse data + + server.latest_specs @req, @res + + assert_equal 200, @res.status + + assert_equal [['z', v(9), Gem::Platform::RUBY]], Marshal.load(@res.body) + end + def test_latest_specs_gz data = StringIO.new "GET /latest_specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n" @req.parse data @@ -120,8 +144,41 @@ class TestGemServer < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_server.rb#L144 assert_equal 2, @server.server.listeners.length end + def test_quick_gemdirs + data = StringIO.new "GET /quick/Marshal.4.8/z-9.gemspec.rz HTTP/1.0\r\n\r\n" + dir = "#{@gemhome}2" + + server = Gem::Server.new dir, process_based_port, false + + @req.parse data + + server.quick @req, @res + + assert_equal 404, @res.status + + spec = quick_spec 'z', 9 + + specs_dir = File.join dir, 'specifications' + + FileUtils.mkdir_p specs_dir + + open File.join(specs_dir, spec.spec_name), 'w' do |io| + io.write spec.to_ruby + end + + data.rewind + + req = WEBrick::HTTPRequest.new :Logger => nil + res = WEBrick::HTTPResponse.new :HTTPVersion => '1.0' + req.parse data + + server.quick req, res + + assert_equal 200, res.status + end + def test_quick_missing - data = StringIO.new "GET /quick/z-9.gemspec.rz HTTP/1.0\r\n\r\n" + data = StringIO.new "GET /quick/Marshal.4.8/z-9.gemspec.rz HTTP/1.0\r\n\r\n" @req.parse data @server.quick @req, @res @@ -188,6 +245,29 @@ class TestGemServer < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_server.rb#L245 assert_equal 'text/html', @res['content-type'] end + def test_root_gemdirs + data = StringIO.new "GET / HTTP/1.0\r\n\r\n" + dir = "#{@gemhome}2" + + spec = quick_spec 'z', 9 + + specs_dir = File.join dir, 'specifications' + FileUtils.mkdir_p specs_dir + + open File.join(specs_dir, spec.spec_name), 'w' do |io| + io.write spec.to_ruby + end + + server = Gem::Server.new dir, process_based_port, false + + @req.parse data + + server.root @req, @res + + assert_equal 200, @res.status + assert_match 'z 9', @res.body + end + def test_specs data = StringIO.new "GET /specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n" @req.parse data @@ -203,6 +283,30 @@ class TestGemServer < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_server.rb#L283 Marshal.load(@res.body) end + def test_specs_gemdirs + data = StringIO.new "GET /specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n" + dir = "#{@gemhome}2" + + spec = quick_spec 'z', 9 + + specs_dir = File.join dir, 'specifications' + FileUtils.mkdir_p specs_dir + + open File.join(specs_dir, spec.spec_name), 'w' do |io| + io.write spec.to_ruby + end + + server = Gem::Server.new dir, process_based_port, false + + @req.parse data + + server.specs @req, @res + + assert_equal 200, @res.status + + assert_equal [['z', v(9), Gem::Platform::RUBY]], Marshal.load(@res.body) + end + def test_specs_gz data = StringIO.new "GET /specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n" @req.parse data -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/