* lib/rubygems: Update to RubyGems 2.0.13. [ruby-core:58031]

[Backport #9052]
  the patch is provided by drbrain (Eric Hodel).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2013-10-26 17:44:33 +00:00
parent b385f19c92
commit d39041bab5
12 changed files with 169 additions and 20 deletions

View file

@ -1,3 +1,9 @@
Sun Oct 27 01:04:28 2013 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
* 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@ruby-lang.org> Sat Oct 26 16:04:36 2013 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
* gc.c (gc_prof_set_heap_info): fix compile error when * gc.c (gc_prof_set_heap_info): fix compile error when

4
NEWS
View file

@ -461,9 +461,9 @@ with all sufficient information, see the ChangeLog file.
XML declaration is used for XML document encoding. XML declaration is used for XML document encoding.
* RubyGems * 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. for release notes.
* Updated to 2.0.10. This fixes CVE_2013-4363: * Updated to 2.0.10. This fixes CVE_2013-4363:

View file

@ -8,7 +8,7 @@
require 'rbconfig' require 'rbconfig'
module Gem module Gem
VERSION = '2.0.12' VERSION = '2.0.13'
end end
# Must be first since it unloads the prelude from 1.9.2 # Must be first since it unloads the prelude from 1.9.2

View file

@ -445,7 +445,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
@spec_dirs = @gem_dirs.map { |gem_dir| File.join gem_dir, 'specifications' } @spec_dirs = @gem_dirs.map { |gem_dir| File.join gem_dir, 'specifications' }
@spec_dirs.reject! { |spec_dir| !File.directory? spec_dir } @spec_dirs.reject! { |spec_dir| !File.directory? spec_dir }
Gem::Specification.dirs = @gem_dirs reset_gems
@have_rdoc_4_plus = nil @have_rdoc_4_plus = nil
end end
@ -470,7 +470,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
end end
def latest_specs(req, res) def latest_specs(req, res)
Gem::Specification.reset reset_gems
res['content-type'] = 'application/x-gzip' res['content-type'] = 'application/x-gzip'
@ -531,7 +531,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
end end
def quick(req, res) def quick(req, res)
Gem::Specification.reset reset_gems
res['content-type'] = 'text/plain' res['content-type'] = 'text/plain'
add_date res add_date res
@ -567,7 +567,8 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
end end
def root(req, res) def root(req, res)
Gem::Specification.reset reset_gems
add_date res add_date res
raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found." unless raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found." unless
@ -697,6 +698,13 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
res.body = template.result binding res.body = template.result binding
end 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 # Returns true and prepares http response, if rdoc for the requested gem
# name pattern was found. # name pattern was found.
@ -787,7 +795,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
end end
def specs(req, res) def specs(req, res)
Gem::Specification.reset reset_gems
add_date res add_date res

View file

@ -63,7 +63,12 @@ class Gem::Source
end end
def update_cache? 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 end
def fetch_spec(name) def fetch_spec(name)

View file

@ -39,7 +39,12 @@ class Gem::SpecFetcher
def initialize def initialize
@dir = File.join Gem.user_home, '.gem', 'specs' @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 = {} @specs = {}
@latest_specs = {} @latest_specs = {}

View file

@ -174,7 +174,7 @@ class Gem::Version
# REFACTOR: There's no real reason this should be separate from #initialize. # REFACTOR: There's no real reason this should be separate from #initialize.
def self.create input def self.create input
if input.respond_to? :version then if self === input then # check yourself before you wreck yourself
input input
elsif input.nil? then elsif input.nil? then
nil nil

View file

@ -85,6 +85,30 @@ class TestGemServer < Gem::TestCase
Marshal.load(@res.body) Marshal.load(@res.body)
end 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 def test_latest_specs_gz
data = StringIO.new "GET /latest_specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n" data = StringIO.new "GET /latest_specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n"
@req.parse data @req.parse data
@ -120,8 +144,41 @@ class TestGemServer < Gem::TestCase
assert_equal 2, @server.server.listeners.length assert_equal 2, @server.server.listeners.length
end 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 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 @req.parse data
@server.quick @req, @res @server.quick @req, @res
@ -188,6 +245,29 @@ class TestGemServer < Gem::TestCase
assert_equal 'text/html', @res['content-type'] assert_equal 'text/html', @res['content-type']
end 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 def test_specs
data = StringIO.new "GET /specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n" data = StringIO.new "GET /specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
@req.parse data @req.parse data
@ -203,6 +283,30 @@ class TestGemServer < Gem::TestCase
Marshal.load(@res.body) Marshal.load(@res.body)
end 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 def test_specs_gz
data = StringIO.new "GET /specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n" data = StringIO.new "GET /specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n"
@req.parse data @req.parse data

View file

@ -184,5 +184,15 @@ class TestGemSource < Gem::TestCase
end end
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 end

View file

@ -52,6 +52,18 @@ class TestGemSpecFetcher < Gem::TestCase
['x', Gem::Version.new(1), 'ruby']] ['x', Gem::Version.new(1), 'ruby']]
end 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 def test_spec_for_dependency_all
d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}" d = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}"
@fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1)) @fetcher.data["#{d}#{@a1.spec_name}.rz"] = util_zip(Marshal.dump(@a1))

View file

@ -23,14 +23,13 @@ class TestGemVersion < Gem::TestCase
assert_bumped_version_equal "6", "5" assert_bumped_version_equal "6", "5"
end end
# FIX: For "legacy reasons," any object that responds to +version+ # A Gem::Version is already a Gem::Version and therefore not transformed by
# is returned unchanged. I'm not certain why. # Gem::Version.create
def test_class_create def test_class_create
fake = Object.new real = Gem::Version.new(1.0)
def fake.version; "1.0" end
assert_same fake, Gem::Version.create(fake) assert_same real, Gem::Version.create(real)
assert_nil Gem::Version.create(nil) assert_nil Gem::Version.create(nil)
assert_equal v("5.1"), Gem::Version.create("5.1") assert_equal v("5.1"), Gem::Version.create("5.1")

View file

@ -1,10 +1,10 @@
#define RUBY_VERSION "2.0.0" #define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-10-26" #define RUBY_RELEASE_DATE "2013-10-27"
#define RUBY_PATCHLEVEL 341 #define RUBY_PATCHLEVEL 342
#define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 10 #define RUBY_RELEASE_MONTH 10
#define RUBY_RELEASE_DAY 26 #define RUBY_RELEASE_DAY 27
#include "ruby/version.h" #include "ruby/version.h"