ruby-changes:27750
From: nagachika <ko1@a...>
Date: Mon, 18 Mar 2013 00:13:19 +0900 (JST)
Subject: [ruby-changes:27750] nagachika:r39802 (ruby_2_0_0): merge revision(s) 39731: [Backport #7991]
nagachika 2013-03-18 00:13:08 +0900 (Mon, 18 Mar 2013) New Revision: 39802 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39802 Log: merge revision(s) 39731: [Backport #7991] * lib/rubygems/commands/setup_command.rb: Don't delete non-rubygems files when installing RubyGems. * test/rubygems/test_gem_commands_setup_command.rb: Test for the above. * lib/rubygems/ext/ext_conf_builder.rb: Use full path to siteconf.rb in case the extconf.rb changes directories (like memcached does). * lib/rubygems/package.rb: Remove double slash from path. * test/rubygems/test_gem_package.rb: Test for the above. * test/rubygems/test_gem_package_old.rb: ditto. * lib/rubygems/source.rb: Revert automatic HTTPS upgrade * lib/rubygems/spec_fetcher.rb: ditto. * test/rubygems/test_gem_remote_fetcher.rb: ditto. * test/rubygems/test_gem_source.rb: ditto. * test/rubygems/test_gem_spec_fetcher.rb: ditto. Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/lib/rubygems/commands/setup_command.rb branches/ruby_2_0_0/lib/rubygems/ext/ext_conf_builder.rb branches/ruby_2_0_0/lib/rubygems/package.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/test/rubygems/test_gem_commands_setup_command.rb branches/ruby_2_0_0/test/rubygems/test_gem_package.rb branches/ruby_2_0_0/test/rubygems/test_gem_package_old.rb branches/ruby_2_0_0/test/rubygems/test_gem_remote_fetcher.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/version.h Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 39801) +++ ruby_2_0_0/ChangeLog (revision 39802) @@ -1,3 +1,23 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Mon Mar 18 00:12:28 2013 Eric Hodel <drbrain@s...> + + * lib/rubygems/commands/setup_command.rb: Don't delete non-rubygems + files when installing RubyGems. + * test/rubygems/test_gem_commands_setup_command.rb: Test for the + above. + + * lib/rubygems/ext/ext_conf_builder.rb: Use full path to siteconf.rb + in case the extconf.rb changes directories (like memcached does). + + * lib/rubygems/package.rb: Remove double slash from path. + * test/rubygems/test_gem_package.rb: Test for the above. + * test/rubygems/test_gem_package_old.rb: ditto. + + * lib/rubygems/source.rb: Revert automatic HTTPS upgrade + * lib/rubygems/spec_fetcher.rb: ditto. + * test/rubygems/test_gem_remote_fetcher.rb: ditto. + * test/rubygems/test_gem_source.rb: ditto. + * test/rubygems/test_gem_spec_fetcher.rb: ditto. + Mon Mar 18 00:11:33 2013 Nobuyoshi Nakada <nobu@r...> * lib/rubygems/ext/ext_conf_builder.rb (Gem::Ext::ExtConfBuilder.build): Index: ruby_2_0_0/lib/rubygems/spec_fetcher.rb =================================================================== --- ruby_2_0_0/lib/rubygems/spec_fetcher.rb (revision 39801) +++ ruby_2_0_0/lib/rubygems/spec_fetcher.rb (revision 39802) @@ -188,8 +188,6 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/spec_fetcher.rb#L188 list = {} Gem.sources.each_source do |source| - source = upgrade_http_source source - begin names = case type when :latest @@ -228,40 +226,5 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/spec_fetcher.rb#L226 end end - ## - # Attempts to upgrade +source+ to HTTPS if it is for http://rubygems.org - - def upgrade_http_source source - uri = source.uri - - return source unless uri.scheme.downcase == 'http' && - uri.host.downcase == 'rubygems.org' - - https_uri = uri.dup - https_uri.scheme = 'https' - https_uri += '/' - - https_uri = URI https_uri.to_s # cast to URI::HTTPS - - begin - Gem::RemoteFetcher.fetcher.fetch_path https_uri, nil, true - rescue Gem::RemoteFetcher::FetchError => e - raise unless e.message =~ / Not Allowed 405 / - end - - say "Upgraded #{uri} to HTTPS" - - https_uri += uri.request_uri - - source.uri = URI https_uri.to_s # cast to URI::HTTPS - - source - rescue Gem::RemoteFetcher::FetchError - say "Upgrading #{uri} to HTTPS failed, continuing" if - Gem.configuration.really_verbose - - source - end - end Index: ruby_2_0_0/lib/rubygems/ext/ext_conf_builder.rb =================================================================== --- ruby_2_0_0/lib/rubygems/ext/ext_conf_builder.rb (revision 39801) +++ ruby_2_0_0/lib/rubygems/ext/ext_conf_builder.rb (revision 39802) @@ -25,11 +25,13 @@ class Gem::Ext::ExtConfBuilder < Gem::Ex https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/ext/ext_conf_builder.rb#L25 siteconf.flush + siteconf_path = File.expand_path siteconf.path + rubyopt = ENV["RUBYOPT"] destdir = ENV["DESTDIR"] begin - ENV["RUBYOPT"] = ["-r#{siteconf.path}", rubyopt].compact.join(' ') + ENV["RUBYOPT"] = ["-r#{siteconf_path}", rubyopt].compact.join(' ') cmd = [Gem.ruby, File.basename(extension), *args].join ' ' run cmd, results Index: ruby_2_0_0/lib/rubygems/source.rb =================================================================== --- ruby_2_0_0/lib/rubygems/source.rb (revision 39801) +++ ruby_2_0_0/lib/rubygems/source.rb (revision 39802) @@ -141,14 +141,4 @@ class Gem::Source https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/source.rb#L141 fetcher = Gem::RemoteFetcher.fetcher fetcher.download spec, @uri.to_s, dir end - - ## - # Replaces the URI for this source with +uri+. Used for upgrading this - # source to HTTPS - - def uri= uri # :nodoc: - @api_uri = nil - @uri = uri - end - end Index: ruby_2_0_0/lib/rubygems/package.rb =================================================================== --- ruby_2_0_0/lib/rubygems/package.rb (revision 39801) +++ ruby_2_0_0/lib/rubygems/package.rb (revision 39802) @@ -368,6 +368,9 @@ EOM https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/package.rb#L368 raise Gem::Package::PathError.new(filename, destination_dir) if filename.start_with? '/' + destination_dir = File.realpath destination_dir if + File.respond_to? :realpath + destination = File.join destination_dir, filename destination = File.expand_path destination Index: ruby_2_0_0/lib/rubygems/commands/setup_command.rb =================================================================== --- ruby_2_0_0/lib/rubygems/commands/setup_command.rb (revision 39801) +++ ruby_2_0_0/lib/rubygems/commands/setup_command.rb (revision 39802) @@ -437,13 +437,18 @@ abort "#{deprecation_message}" https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/commands/setup_command.rb#L437 end def remove_old_lib_files lib_dir - lib_files = rb_files_in 'lib' + rubygems_dir = File.join lib_dir, 'rubygems' + lib_files = rb_files_in 'lib/rubygems' - old_lib_files = rb_files_in lib_dir + old_lib_files = rb_files_in rubygems_dir to_remove = old_lib_files - lib_files - Dir.chdir lib_dir do + to_remove.delete_if do |file| + file.start_with? 'defaults' + end + + Dir.chdir rubygems_dir do to_remove.each do |file| FileUtils.rm_f file Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 39801) +++ ruby_2_0_0/version.h (revision 39802) @@ -1,6 +1,6 @@ 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-03-18" -#define RUBY_PATCHLEVEL 71 +#define RUBY_PATCHLEVEL 72 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb =================================================================== --- ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb (revision 39801) +++ ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb (revision 39802) @@ -32,14 +32,13 @@ class TestGemSpecFetcher < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb#L32 Gem::NameTuple.new(spec.name, spec.version, spec.original_platform) } - @v = Gem.marshal_version - @s_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@specs))) - @l_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@latest_specs))) - @p_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@prerelease_specs))) - - @fetcher.data["#{@gem_repo}specs.#{@v}.gz"] = @s_zip - @fetcher.data["#{@gem_repo}latest_specs.#{@v}.gz"] = @l_zip - @fetcher.data["#{@gem_repo}prerelease_specs.#{@v}.gz"] = @p_zip + v = Gem.marshal_version + s_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@specs))) + l_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@latest_specs))) + p_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@prerelease_specs))) + @fetcher.data["#{@gem_repo}specs.#{v}.gz"] = s_zip + @fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"] = l_zip + @fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip @sf = Gem::SpecFetcher.new @@ -201,6 +200,7 @@ class TestGemSpecFetcher < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb#L200 assert_equal comp.sort, specs[@source].sort end + def test_available_specs_cache specs, _ = @sf.available_specs(:latest) @@ -240,77 +240,5 @@ class TestGemSpecFetcher < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb#L240 assert_kind_of Gem::SourceFetchProblem, errors.first end - def test_upgrade_http_source - Gem.configuration.verbose = :really - - source = Gem::Source.new URI 'http://example' - same_source = nil - - use_ui @ui do - same_source = @sf.upgrade_http_source source - end - - assert_equal URI('http://example'), same_source.uri - - assert_empty @ui.output - assert_empty @ui.error - end - - def test_upgrade_http_source_rubygems - Gem.configuration.verbose = :really - - source = Gem::Source.new URI 'http://rubygems.org' - same_source = nil - https_source = nil - - use_ui @ui do - same_source = @sf.upgrade_http_source source - end - - assert_equal URI('http://rubygems.org'), same_source.uri - - @fetcher.data['https://rubygems.org/'] = 'hello' - - use_ui @ui do - https_source = @sf.upgrade_http_source source - end - - assert_equal URI('https://rubygems.org'), https_source.uri - - assert_empty @ui.error - - expected = <<-EXPECTED -Upgrading http://rubygems.org to HTTPS failed, continuing -Upgraded http://rubygems.org to HTTPS - EXPECTED - - assert_equal expected, @ui.output - end - - def test_upgrade_http_source_rubygems_405 - Gem.configuration.verbose = :really - - source = Gem::Source.new URI 'http://rubygems.org' - https_source = nil - - @fetcher.data['https://rubygems.org/'] = proc do - raise Gem::RemoteFetcher::FetchError.new ' Not Allowed 405 ', nil - end - - use_ui @ui do - https_source = @sf.upgrade_http_source source - end - - assert_equal URI('https://rubygems.org'), https_source.uri - - assert_empty @ui.error - - expected = <<-EXPECTED -Upgraded http://rubygems.org to HTTPS - EXPECTED - - assert_equal expected, @ui.output - end - end Index: ruby_2_0_0/test/rubygems/test_gem_package.rb =================================================================== --- ruby_2_0_0/test/rubygems/test_gem_package.rb (revision 39801) +++ ruby_2_0_0/test/rubygems/test_gem_package.rb (revision 39802) @@ -18,6 +18,8 @@ class TestGemPackage < Gem::Package::Tar https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_package.rb#L18 @gem = @spec.cache_file @destination = File.join @tempdir, 'extract' + + FileUtils.mkdir_p @destination end def test_class_new_old_format @@ -330,6 +332,20 @@ class TestGemPackage < Gem::Package::Tar https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_package.rb#L332 "#{@destination} is not allowed", e.message) end + def test_install_location_extra_slash + package = Gem::Package.new @gem + + file = 'foo//file.rb' + file.taint + + destination = @destination.sub '/', '//' + + destination = package.install_location file, destination + + assert_equal File.join(@destination, 'foo', 'file.rb'), destination + refute destination.tainted? + end + def test_install_location_relative package = Gem::Package.new @gem Index: ruby_2_0_0/test/rubygems/test_gem_remote_fetcher.rb =================================================================== --- ruby_2_0_0/test/rubygems/test_gem_remote_fetcher.rb (revision 39801) +++ ruby_2_0_0/test/rubygems/test_gem_remote_fetcher.rb (revision 39802) @@ -399,9 +399,6 @@ gems: https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_remote_fetcher.rb#L399 @fetcher.instance_variable_set :@a1, @a1 @fetcher.instance_variable_set :@a2, @a2 def @fetcher.fetch_path uri, mtime = nil, head = false - raise Gem::RemoteFetcher::FetchError.new 'no http upgrade', uri if - uri.scheme != 'http' - case uri.request_uri when /#{@a1.spec_name}/ then Gem.deflate Marshal.dump @a1 Index: ruby_2_0_0/test/rubygems/test_gem_package_old.rb =================================================================== --- ruby_2_0_0/test/rubygems/test_gem_package_old.rb (revision 39801) +++ ruby_2_0_0/test/rubygems/test_gem_package_old.rb (revision 39802) @@ -12,6 +12,8 @@ class TestGemPackageOld < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_package_old.rb#L12 @package = Gem::Package::Old.new 'old_format.gem' @destination = File.join @tempdir, 'extract' + + FileUtils.mkdir_p @destination end def test_contents Index: ruby_2_0_0/test/rubygems/test_gem_commands_setup_command.rb =================================================================== --- ruby_2_0_0/test/rubygems/test_gem_commands_setup_command.rb (revision 39801) +++ ruby_2_0_0/test/rubygems/test_gem_commands_setup_command.rb (revision 39802) @@ -41,21 +41,36 @@ class TestGemCommandsSetupCommand < Gem: https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_commands_setup_command.rb#L41 end def test_remove_old_lib_files - lib = File.join @install_dir, 'lib' - lib_rubygems = File.join lib, 'rubygems' + lib = File.join @install_dir, 'lib' + lib_rubygems = File.join lib, 'rubygems' + lib_rubygems_defaults = File.join lib_rubygems, 'defaults' - old_builder_rb = File.join lib_rubygems, 'builder.rb' - old_format_rb = File.join lib_rubygems, 'format.rb' + securerandom_rb = File.join lib, 'securerandom.rb' - FileUtils.mkdir_p lib_rubygems + engine_defaults_rb = File.join lib_rubygems_defaults, 'jruby.rb' + os_defaults_rb = File.join lib_rubygems_defaults, 'operating_system.rb' - open old_builder_rb, 'w' do |io| io.puts '# builder.rb' end - open old_format_rb, 'w' do |io| io.puts '# format.rb' end + old_builder_rb = File.join lib_rubygems, 'builder.rb' + old_format_rb = File.join lib_rubygems, 'format.rb' + + FileUtils.mkdir_p lib_rubygems_defaults + + open securerandom_rb, 'w' do |io| io.puts '# securerandom.rb' end + + open old_builder_rb, 'w' do |io| io.puts '# builder.rb' end + open old_format_rb, 'w' do |io| io.puts '# format.rb' end + + open engine_defaults_rb, 'w' do |io| io.puts '# jruby.rb' end + open os_defaults_rb, 'w' do |io| io.puts '# operating_system.rb' end @cmd.remove_old_lib_files lib refute_path_exists old_builder_rb refute_path_exists old_format_rb + + assert_path_exists securerandom_rb + assert_path_exists engine_defaults_rb + assert_path_exists os_defaults_rb end end Index: ruby_2_0_0/test/rubygems/test_gem_source.rb =================================================================== --- ruby_2_0_0/test/rubygems/test_gem_source.rb (revision 39801) +++ ruby_2_0_0/test/rubygems/test_gem_source.rb (revision 39802) @@ -184,16 +184,5 @@ 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_uri_equals - @source.api_uri # cached - - refute_equal URI('https://secure.example'), @source.api_uri - - @source.uri = URI 'https://secure.example' - - assert_equal URI('https://secure.example'), @source.uri - assert_equal URI('https://secure.example'), @source.api_uri - end - end Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r39731 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/