ruby-changes:27679
From: drbrain <ko1@a...>
Date: Tue, 12 Mar 2013 06:30:37 +0900 (JST)
Subject: [ruby-changes:27679] drbrain:r39731 (trunk): * lib/rubygems/commands/setup_command.rb: Don't delete non-rubygems
drbrain 2013-03-12 06:29:32 +0900 (Tue, 12 Mar 2013) New Revision: 39731 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39731 Log: * 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 files: trunk/ChangeLog trunk/lib/rubygems/commands/setup_command.rb trunk/lib/rubygems/ext/ext_conf_builder.rb trunk/lib/rubygems/package.rb trunk/lib/rubygems/source.rb trunk/lib/rubygems/spec_fetcher.rb trunk/test/rubygems/test_gem_commands_setup_command.rb trunk/test/rubygems/test_gem_package.rb trunk/test/rubygems/test_gem_package_old.rb trunk/test/rubygems/test_gem_remote_fetcher.rb trunk/test/rubygems/test_gem_source.rb trunk/test/rubygems/test_gem_spec_fetcher.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 39730) +++ ChangeLog (revision 39731) @@ -1,3 +1,23 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Mar 12 06:27:59 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. + Tue Mar 12 02:25:19 2013 Eric Hodel <drbrain@s...> * lib/net/smtp.rb: Added Net::SMTP#rset method to implement the SMTP Index: lib/rubygems/spec_fetcher.rb =================================================================== --- lib/rubygems/spec_fetcher.rb (revision 39730) +++ lib/rubygems/spec_fetcher.rb (revision 39731) @@ -188,8 +188,6 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/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/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: lib/rubygems/ext/ext_conf_builder.rb =================================================================== --- lib/rubygems/ext/ext_conf_builder.rb (revision 39730) +++ lib/rubygems/ext/ext_conf_builder.rb (revision 39731) @@ -25,11 +25,13 @@ class Gem::Ext::ExtConfBuilder < Gem::Ex https://github.com/ruby/ruby/blob/trunk/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: lib/rubygems/source.rb =================================================================== --- lib/rubygems/source.rb (revision 39730) +++ lib/rubygems/source.rb (revision 39731) @@ -141,14 +141,4 @@ class Gem::Source https://github.com/ruby/ruby/blob/trunk/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: lib/rubygems/package.rb =================================================================== --- lib/rubygems/package.rb (revision 39730) +++ lib/rubygems/package.rb (revision 39731) @@ -368,6 +368,9 @@ EOM https://github.com/ruby/ruby/blob/trunk/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: lib/rubygems/commands/setup_command.rb =================================================================== --- lib/rubygems/commands/setup_command.rb (revision 39730) +++ lib/rubygems/commands/setup_command.rb (revision 39731) @@ -437,13 +437,18 @@ abort "#{deprecation_message}" https://github.com/ruby/ruby/blob/trunk/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: test/rubygems/test_gem_spec_fetcher.rb =================================================================== --- test/rubygems/test_gem_spec_fetcher.rb (revision 39730) +++ test/rubygems/test_gem_spec_fetcher.rb (revision 39731) @@ -32,14 +32,13 @@ class TestGemSpecFetcher < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/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/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/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: test/rubygems/test_gem_package.rb =================================================================== --- test/rubygems/test_gem_package.rb (revision 39730) +++ test/rubygems/test_gem_package.rb (revision 39731) @@ -18,6 +18,8 @@ class TestGemPackage < Gem::Package::Tar https://github.com/ruby/ruby/blob/trunk/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/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: test/rubygems/test_gem_remote_fetcher.rb =================================================================== --- test/rubygems/test_gem_remote_fetcher.rb (revision 39730) +++ test/rubygems/test_gem_remote_fetcher.rb (revision 39731) @@ -399,9 +399,6 @@ gems: https://github.com/ruby/ruby/blob/trunk/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: test/rubygems/test_gem_package_old.rb =================================================================== --- test/rubygems/test_gem_package_old.rb (revision 39730) +++ test/rubygems/test_gem_package_old.rb (revision 39731) @@ -12,6 +12,8 @@ class TestGemPackageOld < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/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: test/rubygems/test_gem_commands_setup_command.rb =================================================================== --- test/rubygems/test_gem_commands_setup_command.rb (revision 39730) +++ test/rubygems/test_gem_commands_setup_command.rb (revision 39731) @@ -41,21 +41,36 @@ class TestGemCommandsSetupCommand < Gem: https://github.com/ruby/ruby/blob/trunk/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: test/rubygems/test_gem_source.rb =================================================================== --- test/rubygems/test_gem_source.rb (revision 39730) +++ test/rubygems/test_gem_source.rb (revision 39731) @@ -184,16 +184,5 @@ class TestGemSource < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/