8000 * lib/rubygems: Import RubyGems 1.8.7: · voxik/ruby@06d8902 · GitHub
[go: up one dir, main page]

Skip to content

Commit 06d8902

Browse files
committed
* lib/rubygems: Import RubyGems 1.8.7:
Added missing require for `gem uninstall --format-executable`. The correct name of the executable being uninstalled is now displayed with --format-executable. Fixed `gem unpack uninstalled_gem` default version picker. RubyGems no longer claims a nonexistent gem can be uninstalled. `gem which` no longer claims directories are requirable files. `gem cleanup` continues cleaning up gems if one can't be uninstalled due to permissions. Issue ruby#82. Gem repository directories are no longer created world-writable. Patch by Sakuro OZAWA. [Ruby 1.9 - Bug ruby#4930] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent ca55a13 commit 06d8902

13 files changed

+143
-14
lines changed

ChangeLog

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
Fri Aug 05 09:48:22 2011 Eric Hodel <drbrain@segment7.net>
2+
3+
* lib/rubygems: Import RubyGems 1.8.7:
4+
Added missing require for `gem uninstall --format-executable`.
5+
6+
The correct name of the executable being uninstalled is now displayed
7+
with --format-executable.
8+
9+
Fixed `gem unpack uninstalled_gem` default version picker.
10+
11+
RubyGems no longer claims a nonexistent gem can be uninstalled.
12+
13+
`gem which` no longer claims directories are requirable files.
14+
15+
`gem cleanup` continues cleaning up gems if one can't be uninstalled
16+
due to permissions. Issue #82.
17+
18+
Gem repository directories are no longer created world-writable.
19+
Patch by Sakuro OZAWA. [Ruby 1.9 - Bug #4930]
20+
21+
122
Fri Aug 5 09:48:00 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
223

324

lib/rubygems.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class << Gem
118118
# -The RubyGems Team
119119

120120
module Gem
121-
VERSION = '1.8.6.1'
121+
VERSION = '1.8.7'
122122

123123
##
124124
# Raised when RubyGems is unable to load or activate a gem. Contains the
@@ -444,11 +444,16 @@ def self.each_load_path(partials)
444444
def self.ensure_gem_subdirectories dir = Gem.dir
445445
require 'fileutils'
446446

447+
old_umask = File.umask
448+
File.umask old_umask | 022
449+
447450
%w[cache doc gems specifications].each do |name|
448451
subdir = File.join dir, name
449452
next if File.exist? subdir
450453
FileUtils.mkdir_p subdir rescue nil # in case of perms issues -- lame
451454
end
455+
ensure
456+
File.umask old_umask
452457
end
453458

454459
##
@@ -1206,7 +1211,7 @@ def gem(gem_name, *requirements) # :doc:
12061211
# Otherwise return a path to the share area as define by
12071212
# "#{ConfigMap[:datadir]}/#{package_name}".
12081213

1209-
def RbConfig.datadir(package_name)
1214+
def RbConfig.datadir(package_name) # :nodoc:
12101215
warn "#{Gem.location_of_caller.join ':'}:Warning: " \
12111216
"RbConfig.datadir is deprecated and will be removed on or after " \
12121217
"August 2011. " \

lib/rubygems/commands/cleanup_command.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def execute
6161

6262
deps = deplist.strongly_connected_components.flatten.reverse
6363

64+
original_path = Gem.path
65+
6466
deps.each do |spec|
6567
if options[:dryrun] then
6668
say "Dry Run Mode: Would uninstall #{spec.full_name}"
@@ -74,20 +76,21 @@ def execute
7476
:version => "= #{spec.version}",
7577
}
7678

77-
if Gem.user_dir == spec.base_dir then
78-
uninstall_options[:install_dir] = spec.base_dir
79-
end
79+
uninstall_options[:user_install] = Gem.user_dir == spec.base_dir
8080

8181
uninstaller = Gem::Uninstaller.new spec.name, uninstall_options
8282

8383
begin
8484
uninstaller.uninstall
8585
rescue Gem::DependencyRemovalException, Gem::InstallError,
86-
Gem::GemNotInHomeException => e
86+
Gem::GemNotInHomeException, Gem::FilePermissionError => e
8787
say "Unable to uninstall #{spec.full_name}:"
8888
say "\t#{e.class}: #{e.message}"
8989
end
9090
end
91+
92+
# Restore path Gem::Uninstaller may have change
93+
Gem.use_paths(*original_path)
9194
end
9295

9396
say "Clean Up Complete"

lib/rubygems/commands/setup_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def execute
124124
open release_notes do |io|
125125
text = io.gets '==='
126126
text << io.gets('===')
127-
text[0...-3]
127+
text[0...-3].sub(/^# coding:.*?^=/m, '')
128128
end
129129
else
130130
"Oh-no! Unable to find release notes!"

lib/rubygems/gem_openssl.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def ensure_ssl_available
3636
end
3737
end
3838

39+
# :stopdoc:
40+
3941
begin
4042
require 'openssl'
4143

@@ -44,7 +46,7 @@ def ensure_ssl_available
4446

4547
Gem.ssl_available = !!OpenSSL::Digest::SHA1
4648

47-
class OpenSSL::X509::Certificate # :nodoc:
49+
class OpenSSL::X509::Certificate
4850
# Check the validity of this certificate.
4951
def check_validity(issuer_cert = nil, time = Time.now)
5052
ret = if @not_before && @not_before > time
@@ -66,8 +68,6 @@ def check_validity(issuer_cert = nil, time = Time.now)
6668
Gem.ssl_available = false
6769
end
6870

69-
# :stopdoc:
70-
7171
module Gem::SSL
7272

7373
# We make our own versions of the constants here. This allows us
@@ -88,5 +88,3 @@ module Gem::SSL
8888

8989
end
9090

91-
# :startdoc:
92-

lib/rubygems/remote_fetcher.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def download_to_cache dependency
8585

8686
return if found.empty?
8787

88-
spec, source_uri = found.first
88+
spec, source_uri = found.sort_by { |(s,_)| s.version }.last
8989

9090
download spec, source_uri
9191
end

lib/rubygems/requirement.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
require "rubygems/version"
22

3+
# :stopdoc:
4+
35
# Hack to handle syck's DefaultKey bug with psych
46
#
57
# Quick note! If/when psych loads in 1.9, it will redefine
@@ -19,6 +21,8 @@ class DefaultKey
1921
end
2022
end
2123

24+
# :startdoc:
25+
2226
##
2327
# A Requirement is a set of one or more version restrictions. It supports a
2428
# few (<tt>=, !=, >, <, >=, <=, ~></tt>) different restriction operators.

lib/rubygems/test_case.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,25 @@ def install_gem spec
257257
Gem::Installer.new(gem, :wrappers => true).install
258258
end
259259

260+
##
261+
# Builds and installs the Gem::Specification +spec+ into the user dir
262+
263+
def install_gem_user spec
264+
require 'rubygems/installer'
265+
266+
use_ui Gem::MockGemUi.new do
267+
Dir.chdir @tempdir do
268+
Gem::Builder.new(spec).build
269+
end
270+
end
271+
272+
gem = File.join(@tempdir, File.basename(spec.cache_file)).untaint
273+
274+
i = Gem::Installer.new(gem, :wrappers => true, :user_install => true)
275+
i.install
276+
i.spec
277+
end
278+
260279
##
261280
# Uninstalls the Gem::Specification +spec+
262281
def uninstall_gem spec
@@ -678,12 +697,13 @@ def util_setup_spec_fetcher(*specs)
678697
end
679698

680699
v = Gem.marshal_version
700+
681701
Gem::Specification.each do |spec|
682702
path = "#{@gem_repo}quick/Marshal.#{v}/#{spec.original_name}.gemspec.rz"
683703
data = Marshal.dump spec
684704
data_deflate = Zlib::Deflate.deflate data
685705
@fetcher.data[path] = data_deflate
686-
end
706+
end unless Gem::RemoteFetcher === @fetcher # HACK for test_download_to_cache
687707

688708
nil # force errors
689709
end

lib/rubygems/test_utilities.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ def self.fetcher=(fetcher)
139139
##
140140
# A StringIO duck-typed class that uses Tempfile instead of String as the
141141
# backing store.
142+
#
143+
# This is available when rubygems/test_utilities is required.
142144
#--
143145
# This class was added to flush out problems in Rubinius' IO implementation.
144146

test/rubygems/test_gem.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,20 @@ def test_self_ensure_gem_directories
598598
assert File.directory? File.join(@gemhome, "cache")
599599
end
600600

601+
def test_self_ensure_gem_directories_safe_permissions
602+
FileUtils.rm_r @gemhome
603+
Gem.use_paths @gemhome
604+
605+
old_umask = File.umask
606+
File.umask 0
607+
Gem.ensure_gem_subdirectories @gemhome
608+
609+
assert_equal 0, File::Stat.new(@gemhome).mode & 022
610+
assert_equal 0, File::Stat.new(File.join(@gemhome, "cache")).mode & 022
611+
ensure
612+
File.umask old_umask
613+
end unless win_platform?
614+
601615
def test_self_ensure_gem_directories_missing_parents
602616
gemdir = File.join @tempdir, 'a/b/c/gemdir'
603617
FileUtils.rm_rf File.join(@tempdir, 'a') rescue nil

0 commit comments

Comments
 (0)
0