]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/ruby/0001-rubygems-2612-ruby24.patch
package/imagemagick: security bump to version 7.0.7-10
[coffee/buildroot.git] / package / ruby / 0001-rubygems-2612-ruby24.patch
1 [PATCH] bump rubygems to 2.6.12
2
3 Downloaded from upstream:
4 https://bugs.ruby-lang.org/attachments/download/6692/rubygems-2612-ruby24.patch
5
6 And converted to patch-p1.
7
8 Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
9 diff --git a/lib/rubygems.rb b/lib/rubygems.rb
10 index 5cd1a4c47a..bc5bf9b4c2 100644
11 --- a/lib/rubygems.rb
12 +++ b/lib/rubygems.rb
13 @@ -10,7 +10,7 @@
14  require 'thread'
15  
16  module Gem
17 -  VERSION = "2.6.11"
18 +  VERSION = "2.6.12"
19  end
20  
21  # Must be first since it unloads the prelude from 1.9.2
22 @@ -234,6 +234,7 @@ def self.needs
23  
24    def self.finish_resolve(request_set=Gem::RequestSet.new)
25      request_set.import Gem::Specification.unresolved_deps.values
26 +    request_set.import Gem.loaded_specs.values.map {|s| Gem::Dependency.new(s.name, s.version) }
27  
28      request_set.resolve_current.each do |s|
29        s.full_spec.activate
30 diff --git a/lib/rubygems/commands/open_command.rb b/lib/rubygems/commands/open_command.rb
31 index a89b7421e3..059635e835 100644
32 --- a/lib/rubygems/commands/open_command.rb
33 +++ b/lib/rubygems/commands/open_command.rb
34 @@ -72,7 +72,7 @@ def open_editor path
35    end
36  
37    def spec_for name
38 -    spec = Gem::Specification.find_all_by_name(name, @version).last
39 +    spec = Gem::Specification.find_all_by_name(name, @version).first
40  
41      return spec if spec
42  
43 diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb
44 index f25d120b88..70f8127292 100644
45 --- a/lib/rubygems/commands/query_command.rb
46 +++ b/lib/rubygems/commands/query_command.rb
47 @@ -86,7 +86,7 @@ def execute
48        name = Array(options[:name])
49      else
50        args = options[:args].to_a
51 -      name = options[:exact] ? args : args.map{|arg| /#{arg}/i }
52 +      name = options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i }
53      end
54  
55      prerelease = options[:prerelease]
56 diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
57 index 9832afd214..7e46963a4c 100644
58 --- a/lib/rubygems/commands/sources_command.rb
59 +++ b/lib/rubygems/commands/sources_command.rb
60 @@ -44,7 +44,7 @@ def add_source source_uri # :nodoc:
61      source = Gem::Source.new source_uri
62  
63      begin
64 -      if Gem.sources.include? source_uri then
65 +      if Gem.sources.include? source then
66          say "source #{source_uri} already present in the cache"
67        else
68          source.load_specs :released
69 diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb
70 index 35fe7c4c1a..d8314eaf60 100644
71 --- a/lib/rubygems/dependency_list.rb
72 +++ b/lib/rubygems/dependency_list.rb
73 @@ -104,7 +104,7 @@ def find_name(full_name)
74    end
75  
76    def inspect # :nodoc:
77 -    "#<%s:0x%x %p>" % [self.class, object_id, map { |s| s.full_name }]
78 +    "%s %p>" % [super[0..-2], map { |s| s.full_name }]
79    end
80  
81    ##
82 diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
83 index f4d3e728de..967543c2d1 100644
84 --- a/lib/rubygems/installer.rb
85 +++ b/lib/rubygems/installer.rb
86 @@ -214,7 +214,7 @@ def check_executable_overwrite filename # :nodoc:
87  
88        ruby_executable = true
89        existing = io.read.slice(%r{
90 -          ^(
91 +          ^\s*(
92              gem \s |
93              load \s Gem\.bin_path\( |
94              load \s Gem\.activate_bin_path\(
95 @@ -701,6 +701,8 @@ def verify_gem_home(unpack = false) # :nodoc:
96    # Return the text for an application file.
97  
98    def app_script_text(bin_file_name)
99 +    # note that the `load` lines cannot be indented, as old RG versions match
100 +    # against the beginning of the line
101      return <<-TEXT
102  #{shebang bin_file_name}
103  #
104 @@ -723,7 +725,12 @@ def app_script_text(bin_file_name)
105    end
106  end
107  
108 +if Gem.respond_to?(:activate_bin_path)
109  load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version)
110 +else
111 +gem #{spec.name.dump}, version
112 +load Gem.bin_path(#{spec.name.dump}, #{bin_file_name.dump}, version)
113 +end
114  TEXT
115    end
116  
117 diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
118 index d22d91ae54..2dd9ed5782 100644
119 --- a/lib/rubygems/platform.rb
120 +++ b/lib/rubygems/platform.rb
121 @@ -112,7 +112,7 @@ def initialize(arch)
122    end
123  
124    def inspect
125 -    "#<%s:0x%x @cpu=%p, @os=%p, @version=%p>" % [self.class, object_id, *to_a]
126 +    "%s @cpu=%p, @os=%p, @version=%p>" % [super[0..-2], *to_a]
127    end
128  
129    def to_a
130 diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
131 index 119d6d56f7..6963ca156f 100644
132 --- a/lib/rubygems/security.rb
133 +++ b/lib/rubygems/security.rb
134 @@ -455,7 +455,7 @@ def self.create_cert_self_signed subject, key, age = ONE_YEAR,
135  
136    ##
137    # Creates a new key pair of the specified +length+ and +algorithm+.  The
138 -  # default is a 2048 bit RSA key.
139 +  # default is a 3072 bit RSA key.
140  
141    def self.create_key length = KEY_LENGTH, algorithm = KEY_ALGORITHM
142      algorithm.new length
143 diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb
144 index 81df0e608e..df4eb566d3 100644
145 --- a/lib/rubygems/server.rb
146 +++ b/lib/rubygems/server.rb
147 @@ -657,7 +657,7 @@ def root(req, res)
148        "only_one_executable" => true,
149        "full_name" => "rubygems-#{Gem::VERSION}",
150        "has_deps" => false,
151 -      "homepage" => "http://docs.rubygems.org/",
152 +      "homepage" => "http://guides.rubygems.org/",
153        "name" => 'rubygems',
154        "ri_installed" => true,
155        "summary" => "RubyGems itself",
156 diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
157 index a2f289d162..500f0af768 100644
158 --- a/lib/rubygems/specification.rb
159 +++ b/lib/rubygems/specification.rb
160 @@ -2105,7 +2105,7 @@ def inspect # :nodoc:
161      if $DEBUG
162        super
163      else
164 -      "#<#{self.class}:0x#{__id__.to_s(16)} #{full_name}>"
165 +      "#{super[0..-2]} #{full_name}>"
166      end
167    end
168  
169 diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
170 index 86b68e1efb..4e48f1eb4c 100644
171 --- a/lib/rubygems/test_case.rb
172 +++ b/lib/rubygems/test_case.rb
173 @@ -484,7 +484,7 @@ def git_gem name = 'a', version = 1
174  
175        system @git, 'add', gemspec
176        system @git, 'commit', '-a', '-m', 'a non-empty commit message', '--quiet'
177 -      head = Gem::Util.popen('git', 'rev-parse', 'master').strip
178 +      head = Gem::Util.popen(@git, 'rev-parse', 'master').strip
179      end
180  
181      return name, git_spec.version, directory, head
182 @@ -1498,6 +1498,8 @@ def self.key_path key_name
183  begin
184    gem 'rdoc'
185    require 'rdoc'
186 +
187 +  require 'rubygems/rdoc'
188  rescue LoadError, Gem::LoadError
189  end
190  
191 @@ -1514,3 +1516,4 @@ def self.key_path key_name
192  pid = $$
193  END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid}
194  Gem.clear_paths
195 +Gem.loaded_specs.clear
196 diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
197 index a605f9cdfe..62b36dfd41 100644
198 --- a/test/rubygems/test_gem.rb
199 +++ b/test/rubygems/test_gem.rb
200 @@ -75,6 +75,29 @@ def test_self_finish_resolve_wtf
201      end
202    end
203  
204 +  def test_self_finish_resolve_respects_loaded_specs
205 +    save_loaded_features do
206 +      a1 = new_spec "a", "1", "b" => "> 0"
207 +      b1 = new_spec "b", "1", "c" => ">= 1"
208 +      b2 = new_spec "b", "2", "c" => ">= 2"
209 +      c1 = new_spec "c", "1"
210 +      c2 = new_spec "c", "2"
211 +
212 +      install_specs c1, c2, b1, b2, a1
213 +
214 +      a1.activate
215 +      c1.activate
216 +
217 +      assert_equal %w(a-1 c-1), loaded_spec_names
218 +      assert_equal ["b (> 0)"], unresolved_names
219 +
220 +      Gem.finish_resolve
221 +
222 +      assert_equal %w(a-1 b-1 c-1), loaded_spec_names
223 +      assert_equal [], unresolved_names
224 +    end
225 +  end
226 +
227    def test_self_install
228      spec_fetcher do |f|
229        f.gem  'a', 1
230 @@ -492,7 +515,7 @@ def test_self_find_files_with_gemfile
231      skip if RUBY_VERSION <= "1.8.7"
232  
233      cwd = File.expand_path("test/rubygems", @@project_dir)
234 -    $LOAD_PATH.unshift cwd
235 +    actual_load_path = $LOAD_PATH.unshift(cwd).dup
236  
237      discover_path = File.join 'lib', 'sff', 'discover.rb'
238  
239 @@ -518,12 +541,12 @@ def test_self_find_files_with_gemfile
240      expected = [
241        File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
242        File.join(foo1.full_gem_path, discover_path)
243 -    ]
244 +    ].sort
245  
246 -    assert_equal expected, Gem.find_files('sff/discover')
247 -    assert_equal expected, Gem.find_files('sff/**.rb'), '[ruby-core:31730]'
248 +    assert_equal expected, Gem.find_files('sff/discover').sort
249 +    assert_equal expected, Gem.find_files('sff/**.rb').sort, '[ruby-core:31730]'
250    ensure
251 -    assert_equal cwd, $LOAD_PATH.shift unless RUBY_VERSION <= "1.8.7"
252 +    assert_equal cwd, actual_load_path.shift unless RUBY_VERSION <= "1.8.7"
253    end
254  
255    def test_self_find_latest_files
256 diff --git a/test/rubygems/test_gem_commands_open_command.rb b/test/rubygems/test_gem_commands_open_command.rb
257 index 3ec38972e6..a96fa6ea23 100644
258 --- a/test/rubygems/test_gem_commands_open_command.rb
259 +++ b/test/rubygems/test_gem_commands_open_command.rb
260 @@ -24,7 +24,8 @@ def test_execute
261      @cmd.options[:args] = %w[foo]
262      @cmd.options[:editor] = "#{Gem.ruby} -e0 --"
263  
264 -    spec = gem 'foo'
265 +    gem 'foo', '1.0.0'
266 +    spec = gem 'foo', '1.0.1'
267      mock = MiniTest::Mock.new
268      mock.expect(:call, true, [spec.full_gem_path])
269  
270 diff --git a/test/rubygems/test_gem_commands_query_command.rb b/test/rubygems/test_gem_commands_query_command.rb
271 index 223f205b2d..d8d682b136 100644
272 --- a/test/rubygems/test_gem_commands_query_command.rb
273 +++ b/test/rubygems/test_gem_commands_query_command.rb
274 @@ -642,7 +642,7 @@ def test_execute_local_details
275      assert_equal expected, @ui.output
276    end
277  
278 -  def test_execute_exact
279 +  def test_execute_exact_remote
280      spec_fetcher do |fetcher|
281        fetcher.spec 'coolgem-omg', 3
282        fetcher.spec 'coolgem', '4.2.1'
283 @@ -665,6 +665,60 @@ def test_execute_exact
284      assert_equal expected, @ui.output
285    end
286  
287 +  def test_execute_exact_local
288 +    spec_fetcher do |fetcher|
289 +      fetcher.spec 'coolgem-omg', 3
290 +      fetcher.spec 'coolgem', '4.2.1'
291 +      fetcher.spec 'wow_coolgem', 1
292 +    end
293 +
294 +    @cmd.handle_options %w[--exact coolgem]
295 +
296 +    use_ui @ui do
297 +      @cmd.execute
298 +    end
299 +
300 +    expected = <<-EOF
301 +
302 +*** LOCAL GEMS ***
303 +
304 +coolgem (4.2.1)
305 +    EOF
306 +
307 +    assert_equal expected, @ui.output
308 +  end
309 +
310 +  def test_execute_exact_multiple
311 +    spec_fetcher do |fetcher|
312 +      fetcher.spec 'coolgem-omg', 3
313 +      fetcher.spec 'coolgem', '4.2.1'
314 +      fetcher.spec 'wow_coolgem', 1
315 +
316 +      fetcher.spec 'othergem-omg', 3
317 +      fetcher.spec 'othergem', '1.2.3'
318 +      fetcher.spec 'wow_othergem', 1
319 +    end
320 +
321 +    @cmd.handle_options %w[--exact coolgem othergem]
322 +
323 +    use_ui @ui do
324 +      @cmd.execute
325 +    end
326 +
327 +    expected = <<-EOF
328 +
329 +*** LOCAL GEMS ***
330 +
331 +coolgem (4.2.1)
332 +
333 +*** LOCAL GEMS ***
334 +
335 +othergem (1.2.3)
336 +    EOF
337 +
338 +    assert_equal expected, @ui.output
339 +  end
340 +
341    private
342  
343    def add_gems_to_fetcher
344 diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb
345 index 014b4b4c12..d5b6d99419 100644
346 --- a/test/rubygems/test_gem_commands_sources_command.rb
347 +++ b/test/rubygems/test_gem_commands_sources_command.rb
348 @@ -108,6 +108,58 @@ def test_execute_add_redundant_source
349      assert_equal '', @ui.error
350    end
351  
352 +  def test_execute_add_redundant_source_trailing_slash
353 +    # Remove pre-existing gem source (w/ slash)
354 +    repo_with_slash = "http://gems.example.com/"
355 +    @cmd.handle_options %W[--remove #{repo_with_slash}]
356 +    use_ui @ui do
357 +      @cmd.execute
358 +    end
359 +    source = Gem::Source.new repo_with_slash
360 +    assert_equal false, Gem.sources.include?(source)
361 +
362 +    expected = <<-EOF
363 +#{repo_with_slash} removed from sources
364 +    EOF
365 +
366 +    assert_equal expected, @ui.output
367 +    assert_equal '', @ui.error
368 +
369 +    # Re-add pre-existing gem source (w/o slash)
370 +    repo_without_slash = "http://gems.example.com"
371 +    @cmd.handle_options %W[--add #{repo_without_slash}]
372 +    use_ui @ui do
373 +      @cmd.execute
374 +    end
375 +    source = Gem::Source.new repo_without_slash
376 +    assert_equal true, Gem.sources.include?(source)
377 +
378 +    expected = <<-EOF
379 +http://gems.example.com/ removed from sources
380 +http://gems.example.com added to sources
381 +    EOF
382 +
383 +    assert_equal expected, @ui.output
384 +    assert_equal '', @ui.error
385 +
386 +    # Re-add original gem source (w/ slash)
387 +    @cmd.handle_options %W[--add #{repo_with_slash}]
388 +    use_ui @ui do
389 +      @cmd.execute
390 +    end
391 +    source = Gem::Source.new repo_with_slash
392 +    assert_equal true, Gem.sources.include?(source)
393 +
394 +    expected = <<-EOF
395 +http://gems.example.com/ removed from sources
396 +http://gems.example.com added to sources
397 +source http://gems.example.com/ already present in the cache
398 +    EOF
399 +
400 +    assert_equal expected, @ui.output
401 +    assert_equal '', @ui.error 
402 +  end
403 +
404    def test_execute_add_http_rubygems_org
405      http_rubygems_org = 'http://rubygems.org'
406  
407 diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
408 index 6ceb2c6dfc..882981d344 100644
409 --- a/test/rubygems/test_gem_installer.rb
410 +++ b/test/rubygems/test_gem_installer.rb
411 @@ -62,7 +62,12 @@ def test_app_script_text
412    end
413  end
414  
415 +if Gem.respond_to?(:activate_bin_path)
416  load Gem.activate_bin_path('a', 'executable', version)
417 +else
418 +gem "a", version
419 +load Gem.bin_path("a", "executable", version)
420 +end
421      EOF
422  
423      wrapper = @installer.app_script_text 'executable'
424 diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
425 index dd606e44d4..936f78fb2a 100644
426 --- a/test/rubygems/test_require.rb
427 +++ b/test/rubygems/test_require.rb
428 @@ -301,6 +301,17 @@ def test_default_gem_only
429      assert_equal %w(default-2.0.0.0), loaded_spec_names
430    end
431  
432 +  def test_realworld_default_gem
433 +    skip "no default gems on ruby < 2.0" unless RUBY_VERSION >= "2"
434 +    cmd = <<-RUBY
435 +      $stderr = $stdout
436 +      require "json"
437 +      puts Gem.loaded_specs["json"].default_gem?
438 +    RUBY
439 +    output = Gem::Util.popen(Gem.ruby, "-e", cmd).strip
440 +    assert_equal "true", output
441 +  end
442 +
443    def test_default_gem_and_normal_gem
444      default_gem_spec = new_default_spec("default", "2.0.0.0",
445                                          nil, "default/gem.rb")