mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
21c1e2da06
commit
10c5d6ee25
12 changed files with 82 additions and 152 deletions
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
|||
Tue Mar 12 06:27:59 2013 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* 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@segment7.net>
|
||||
|
||||
* lib/net/smtp.rb: Added Net::SMTP#rset method to implement the SMTP
|
||||
|
|
|
@ -437,13 +437,18 @@ abort "#{deprecation_message}"
|
|||
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
|
||||
|
||||
|
|
|
@ -25,11 +25,13 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
|
|||
|
||||
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
|
||||
|
|
|
@ -368,6 +368,9 @@ EOM
|
|||
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
|
||||
|
||||
|
|
|
@ -141,14 +141,4 @@ class Gem::Source
|
|||
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
|
||||
|
|
|
@ -188,8 +188,6 @@ class Gem::SpecFetcher
|
|||
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
|
|||
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
|
||||
|
||||
|
|
|
@ -41,21 +41,36 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||
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
|
||||
|
|
|
@ -18,6 +18,8 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|||
@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::TarTestCase
|
|||
"#{@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
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ class TestGemPackageOld < Gem::TestCase
|
|||
|
||||
@package = Gem::Package::Old.new 'old_format.gem'
|
||||
@destination = File.join @tempdir, 'extract'
|
||||
|
||||
FileUtils.mkdir_p @destination
|
||||
end
|
||||
|
||||
def test_contents
|
||||
|
|
|
@ -399,9 +399,6 @@ gems:
|
|||
@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
|
||||
|
|
|
@ -184,16 +184,5 @@ class TestGemSource < Gem::TestCase
|
|||
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
|
||||
|
||||
|
|
|
@ -32,14 +32,13 @@ class TestGemSpecFetcher < Gem::TestCase
|
|||
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
|
|||
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
|
|||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue