rubygems-update 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/ChangeLog +248 -0
- data/README +2 -0
- data/Rakefile +47 -23
- data/bin/gem +9 -4
- data/bin/update_rubygems +15 -1
- data/examples/application/bin/myapp +0 -0
- data/lib/rubygems.rb +506 -373
- data/lib/rubygems/builder.rb +14 -7
- data/lib/rubygems/command.rb +9 -9
- data/lib/rubygems/command_manager.rb +1 -0
- data/lib/rubygems/commands/cleanup_command.rb +67 -69
- data/lib/rubygems/commands/environment_command.rb +16 -10
- data/lib/rubygems/commands/fetch_command.rb +7 -9
- data/lib/rubygems/commands/install_command.rb +9 -3
- data/lib/rubygems/commands/list_command.rb +2 -4
- data/lib/rubygems/commands/mirror_command.rb +1 -1
- data/lib/rubygems/commands/query_command.rb +52 -5
- data/lib/rubygems/commands/sources_command.rb +19 -10
- data/lib/rubygems/commands/specification_command.rb +10 -6
- data/lib/rubygems/commands/uninstall_command.rb +23 -6
- data/lib/rubygems/commands/unpack_command.rb +15 -3
- data/lib/rubygems/commands/update_command.rb +27 -25
- data/lib/rubygems/custom_require.rb +1 -1
- data/lib/rubygems/defaults.rb +8 -1
- data/lib/rubygems/dependency_installer.rb +72 -104
- data/lib/rubygems/digest/digest_adapter.rb +0 -0
- data/lib/rubygems/digest/md5.rb +0 -0
- data/lib/rubygems/digest/sha1.rb +0 -0
- data/lib/rubygems/digest/sha2.rb +0 -0
- data/lib/rubygems/exceptions.rb +22 -1
- data/lib/rubygems/format.rb +16 -10
- data/lib/rubygems/indexer.rb +46 -33
- data/lib/rubygems/indexer/abstract_index_builder.rb +10 -2
- data/lib/rubygems/indexer/latest_index_builder.rb +35 -0
- data/lib/rubygems/indexer/master_index_builder.rb +9 -8
- data/lib/rubygems/indexer/quick_index_builder.rb +5 -3
- data/lib/rubygems/install_update_options.rb +7 -1
- data/lib/rubygems/installer.rb +8 -5
- data/lib/rubygems/package.rb +17 -774
- data/lib/rubygems/package/f_sync_dir.rb +24 -0
- data/lib/rubygems/package/tar_header.rb +245 -0
- data/lib/rubygems/package/tar_input.rb +219 -0
- data/lib/rubygems/package/tar_output.rb +143 -0
- data/lib/rubygems/package/tar_reader.rb +86 -0
- data/lib/rubygems/package/tar_reader/entry.rb +99 -0
- data/lib/rubygems/package/tar_writer.rb +180 -0
- data/lib/rubygems/remote_fetcher.rb +131 -16
- data/lib/rubygems/requirement.rb +2 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +1 -0
- data/lib/rubygems/server.rb +85 -104
- data/lib/rubygems/source_index.rb +412 -329
- data/lib/rubygems/source_info_cache.rb +232 -99
- data/lib/rubygems/source_info_cache_entry.rb +14 -4
- data/lib/rubygems/specification.rb +9 -10
- data/lib/rubygems/timer.rb +0 -0
- data/lib/rubygems/uninstaller.rb +56 -32
- data/lib/rubygems/user_interaction.rb +4 -10
- data/lib/rubygems/validator.rb +0 -0
- data/scripts/gemdoc.rb +0 -0
- data/scripts/specdoc.rb +0 -0
- data/setup.rb +56 -19
- data/test/gem_installer_test_case.rb +86 -0
- data/test/gem_installer_test_case.rbc +0 -0
- data/test/gem_package_tar_test_case.rb +146 -0
- data/test/gem_package_tar_test_case.rbc +0 -0
- data/test/gemutilities.rb +123 -38
- data/test/gemutilities.rbc +0 -0
- data/test/mockgemui.rb +5 -13
- data/test/mockgemui.rbc +0 -0
- data/test/private_key.pem +27 -0
- data/test/public_cert.pem +20 -0
- data/test/simple_gem.rbc +0 -0
- data/test/test_config.rbc +0 -0
- data/test/test_gem.rb +46 -4
- data/test/test_gem.rbc +0 -0
- data/test/test_gem_builder.rbc +0 -0
- data/test/test_gem_command.rbc +0 -0
- data/test/test_gem_command_manager.rb +4 -2
- data/test/test_gem_command_manager.rbc +0 -0
- data/test/test_gem_commands_build_command.rbc +0 -0
- data/test/test_gem_commands_cert_command.rb +5 -1
- data/test/test_gem_commands_cert_command.rbc +0 -0
- data/test/test_gem_commands_check_command.rbc +0 -0
- data/test/test_gem_commands_contents_command.rbc +0 -0
- data/test/test_gem_commands_dependency_command.rbc +0 -0
- data/test/test_gem_commands_environment_command.rb +17 -1
- data/test/test_gem_commands_environment_command.rbc +0 -0
- data/test/test_gem_commands_fetch_command.rb +6 -5
- data/test/test_gem_commands_fetch_command.rbc +0 -0
- data/test/test_gem_commands_generate_index_command.rbc +0 -0
- data/test/test_gem_commands_install_command.rb +36 -28
- data/test/test_gem_commands_install_command.rbc +0 -0
- data/test/test_gem_commands_mirror_command.rbc +0 -0
- data/test/test_gem_commands_pristine_command.rbc +0 -0
- data/test/test_gem_commands_query_command.rb +143 -19
- data/test/test_gem_commands_query_command.rbc +0 -0
- data/test/test_gem_commands_server_command.rb +1 -1
- data/test/test_gem_commands_server_command.rbc +0 -0
- data/test/test_gem_commands_sources_command.rb +67 -9
- data/test/test_gem_commands_sources_command.rbc +0 -0
- data/test/test_gem_commands_specification_command.rb +3 -2
- data/test/test_gem_commands_specification_command.rbc +0 -0
- data/test/test_gem_commands_unpack_command.rb +46 -4
- data/test/test_gem_commands_unpack_command.rbc +0 -0
- data/test/test_gem_commands_update_command.rb +174 -0
- data/test/test_gem_commands_update_command.rbc +0 -0
- data/test/test_gem_config_file.rbc +0 -0
- data/test/test_gem_dependency.rbc +0 -0
- data/test/test_gem_dependency_installer.rb +172 -187
- data/test/test_gem_dependency_installer.rbc +0 -0
- data/test/test_gem_dependency_list.rbc +0 -0
- data/test/test_gem_digest.rb +0 -0
- data/test/test_gem_digest.rbc +0 -0
- data/test/test_gem_doc_manager.rbc +0 -0
- data/test/test_gem_ext_configure_builder.rb +9 -6
- data/test/test_gem_ext_configure_builder.rbc +0 -0
- data/test/test_gem_ext_ext_conf_builder.rbc +0 -0
- data/test/test_gem_ext_rake_builder.rbc +0 -0
- data/test/test_gem_format.rb +1 -1
- data/test/test_gem_format.rbc +0 -0
- data/test/test_gem_gem_path_searcher.rbc +0 -0
- data/test/test_gem_gem_runner.rbc +0 -0
- data/test/test_gem_indexer.rb +7 -2
- data/test/test_gem_indexer.rbc +0 -0
- data/test/test_gem_install_update_options.rbc +0 -0
- data/test/test_gem_installer.rb +5 -84
- data/test/test_gem_installer.rbc +0 -0
- data/test/test_gem_local_remote_options.rbc +0 -0
- data/test/test_gem_outdated_command.rbc +0 -0
- data/test/test_gem_package_tar_header.rb +137 -0
- data/test/test_gem_package_tar_header.rbc +0 -0
- data/test/test_gem_package_tar_input.rb +119 -0
- data/test/test_gem_package_tar_input.rbc +0 -0
- data/test/test_gem_package_tar_output.rb +104 -0
- data/test/test_gem_package_tar_output.rbc +0 -0
- data/test/test_gem_package_tar_reader.rb +53 -0
- data/test/test_gem_package_tar_reader.rbc +0 -0
- data/test/test_gem_package_tar_reader_entry.rb +116 -0
- data/test/test_gem_package_tar_reader_entry.rbc +0 -0
- data/test/test_gem_package_tar_writer.rb +151 -0
- data/test/test_gem_package_tar_writer.rbc +0 -0
- data/test/test_gem_platform.rbc +0 -0
- data/test/test_gem_remote_fetcher.rb +189 -17
- data/test/test_gem_remote_fetcher.rbc +0 -0
- data/test/test_gem_requirement.rbc +0 -0
- data/test/test_gem_server.rb +13 -12
- data/test/test_gem_server.rbc +0 -0
- data/test/test_gem_source_index.rb +305 -56
- data/test/test_gem_source_index.rbc +0 -0
- data/test/test_gem_source_info_cache.rb +179 -53
- data/test/test_gem_source_info_cache.rbc +0 -0
- data/test/test_gem_source_info_cache_entry.rb +41 -10
- data/test/test_gem_source_info_cache_entry.rbc +0 -0
- data/test/test_gem_specification.rb +7 -7
- data/test/test_gem_specification.rbc +0 -0
- data/test/test_gem_stream_ui.rbc +0 -0
- data/test/test_gem_uninstaller.rb +43 -0
- data/test/test_gem_uninstaller.rbc +0 -0
- data/test/test_gem_validator.rbc +0 -0
- data/test/test_gem_version.rb +1 -1
- data/test/test_gem_version.rbc +0 -0
- data/test/test_gem_version_option.rbc +0 -0
- data/test/test_kernel.rb +1 -0
- data/test/test_kernel.rbc +0 -0
- metadata +85 -8
- metadata.gz.sig +0 -0
- data/lib/rubygems/gem_open_uri.rb +0 -7
- data/lib/rubygems/open-uri.rb +0 -773
- data/test/test_open_uri.rb +0 -13
- data/test/test_package.rb +0 -608
@@ -39,8 +39,11 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
39
39
|
options[:list] = !(options[:add] || options[:remove] || options[:clear_all] || options[:update])
|
40
40
|
|
41
41
|
if options[:clear_all] then
|
42
|
-
|
43
|
-
remove_cache_file
|
42
|
+
sic = Gem::SourceInfoCache
|
43
|
+
remove_cache_file 'user', sic.user_cache_file
|
44
|
+
remove_cache_file 'latest user', sic.latest_user_cache_file
|
45
|
+
remove_cache_file 'system', sic.system_cache_file
|
46
|
+
remove_cache_file 'latest system', sic.latest_system_cache_file
|
44
47
|
end
|
45
48
|
|
46
49
|
if options[:add] then
|
@@ -48,7 +51,7 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
48
51
|
|
49
52
|
sice = Gem::SourceInfoCacheEntry.new nil, nil
|
50
53
|
begin
|
51
|
-
sice.refresh source_uri
|
54
|
+
sice.refresh source_uri, true
|
52
55
|
|
53
56
|
Gem::SourceInfoCache.cache_data[source_uri] = sice
|
54
57
|
Gem::SourceInfoCache.cache.update
|
@@ -66,7 +69,7 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
66
69
|
end
|
67
70
|
|
68
71
|
if options[:update] then
|
69
|
-
Gem::SourceInfoCache.cache
|
72
|
+
Gem::SourceInfoCache.cache true
|
70
73
|
Gem::SourceInfoCache.cache.flush
|
71
74
|
|
72
75
|
say "source cache successfully updated"
|
@@ -78,6 +81,11 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
78
81
|
unless Gem.sources.include? source_uri then
|
79
82
|
say "source #{source_uri} not present in cache"
|
80
83
|
else
|
84
|
+
begin # HACK figure out how to get the cache w/o update
|
85
|
+
Gem::SourceInfoCache.cache
|
86
|
+
rescue Gem::RemoteFetcher::FetchError
|
87
|
+
end
|
88
|
+
|
81
89
|
Gem::SourceInfoCache.cache_data.delete source_uri
|
82
90
|
Gem::SourceInfoCache.cache.update
|
83
91
|
Gem::SourceInfoCache.cache.flush
|
@@ -92,19 +100,20 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
92
100
|
say "*** CURRENT SOURCES ***"
|
93
101
|
say
|
94
102
|
|
95
|
-
Gem.sources.each do |
|
96
|
-
say
|
103
|
+
Gem.sources.each do |source|
|
104
|
+
say source
|
97
105
|
end
|
98
106
|
end
|
99
107
|
end
|
100
108
|
|
101
109
|
private
|
102
110
|
|
103
|
-
def remove_cache_file(desc,
|
104
|
-
FileUtils.rm_rf
|
105
|
-
|
111
|
+
def remove_cache_file(desc, path)
|
112
|
+
FileUtils.rm_rf path
|
113
|
+
|
114
|
+
if not File.exist?(path) then
|
106
115
|
say "*** Removed #{desc} source cache ***"
|
107
|
-
elsif
|
116
|
+
elsif not File.writable?(path) then
|
108
117
|
say "*** Unable to remove #{desc} source cache (write protected) ***"
|
109
118
|
else
|
110
119
|
say "*** Unable to remove #{desc} source cache ***"
|
@@ -3,6 +3,7 @@ require 'rubygems/command'
|
|
3
3
|
require 'rubygems/local_remote_options'
|
4
4
|
require 'rubygems/version_option'
|
5
5
|
require 'rubygems/source_info_cache'
|
6
|
+
require 'rubygems/format'
|
6
7
|
|
7
8
|
class Gem::Commands::SpecificationCommand < Gem::Command
|
8
9
|
|
@@ -41,13 +42,16 @@ class Gem::Commands::SpecificationCommand < Gem::Command
|
|
41
42
|
gem = get_one_gem_name
|
42
43
|
|
43
44
|
if local? then
|
44
|
-
|
45
|
-
|
45
|
+
if File.exist? gem then
|
46
|
+
specs << Gem::Format.from_file_by_path(gem).spec rescue nil
|
47
|
+
end
|
48
|
+
|
49
|
+
if specs.empty? then
|
50
|
+
specs.push(*Gem.source_index.search(/\A#{gem}\z/, options[:version]))
|
51
|
+
end
|
46
52
|
end
|
47
53
|
|
48
54
|
if remote? then
|
49
|
-
alert_warning "Remote information is not complete\n\n"
|
50
|
-
|
51
55
|
Gem::SourceInfoCache.cache_data.each do |_,sice|
|
52
56
|
specs.push(*sice.source_index.search(gem, options[:version]))
|
53
57
|
end
|
@@ -58,12 +62,12 @@ class Gem::Commands::SpecificationCommand < Gem::Command
|
|
58
62
|
terminate_interaction 1
|
59
63
|
end
|
60
64
|
|
61
|
-
output = lambda { |
|
65
|
+
output = lambda { |s| say s.to_yaml; say "\n" }
|
62
66
|
|
63
67
|
if options[:all] then
|
64
68
|
specs.each(&output)
|
65
69
|
else
|
66
|
-
spec = specs.sort_by { |
|
70
|
+
spec = specs.sort_by { |s| s.version }.last
|
67
71
|
output[spec]
|
68
72
|
end
|
69
73
|
end
|
@@ -18,18 +18,28 @@ module Gem
|
|
18
18
|
options[:all] = value
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
add_option('-I', '--[no-]ignore-dependencies',
|
22
|
+
'Ignore dependency requirements while',
|
23
|
+
'uninstalling') do |value, options|
|
24
24
|
options[:ignore] = value
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
add_option('-x', '--[no-]executables',
|
28
28
|
'Uninstall applicable executables without',
|
29
29
|
'confirmation') do |value, options|
|
30
30
|
options[:executables] = value
|
31
31
|
end
|
32
32
|
|
33
|
+
add_option('-i', '--install-dir DIR',
|
34
|
+
'Directory to uninstall gem from') do |value, options|
|
35
|
+
options[:install_dir] = File.expand_path(value)
|
36
|
+
end
|
37
|
+
|
38
|
+
add_option('-n', '--bindir DIR',
|
39
|
+
'Directory to remove binaries from') do |value, options|
|
40
|
+
options[:bin_dir] = File.expand_path(value)
|
41
|
+
end
|
42
|
+
|
33
43
|
add_version_option
|
34
44
|
add_platform_option
|
35
45
|
end
|
@@ -39,7 +49,8 @@ module Gem
|
|
39
49
|
end
|
40
50
|
|
41
51
|
def defaults_str # :nodoc:
|
42
|
-
"--version '#{Gem::Requirement.default}' --no-force"
|
52
|
+
"--version '#{Gem::Requirement.default}' --no-force " \
|
53
|
+
"--install-dir #{Gem.dir}"
|
43
54
|
end
|
44
55
|
|
45
56
|
def usage # :nodoc:
|
@@ -48,7 +59,13 @@ module Gem
|
|
48
59
|
|
49
60
|
def execute
|
50
61
|
get_all_gem_names.each do |gem_name|
|
51
|
-
|
62
|
+
begin
|
63
|
+
Gem::Uninstaller.new(gem_name, options).uninstall
|
64
|
+
rescue Gem::GemNotInHomeException => e
|
65
|
+
spec = e.spec
|
66
|
+
alert("In order to remove #{spec.name}, please execute:\n" \
|
67
|
+
"\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
|
68
|
+
end
|
52
69
|
end
|
53
70
|
end
|
54
71
|
end
|
@@ -38,6 +38,7 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
38
38
|
def execute
|
39
39
|
gemname = get_one_gem_name
|
40
40
|
path = get_path(gemname, options[:version])
|
41
|
+
|
41
42
|
if path then
|
42
43
|
basename = File.basename(path).sub(/\.gem$/, '')
|
43
44
|
target_dir = File.expand_path File.join(options[:target], basename)
|
@@ -66,16 +67,27 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
|
66
67
|
# source directories?
|
67
68
|
def get_path(gemname, version_req)
|
68
69
|
return gemname if gemname =~ /\.gem$/i
|
69
|
-
|
70
|
+
|
71
|
+
specs = Gem::source_index.search(/\A#{gemname}\z/, version_req)
|
72
|
+
|
70
73
|
selected = specs.sort_by { |s| s.version }.last
|
74
|
+
|
71
75
|
return nil if selected.nil?
|
76
|
+
|
72
77
|
# We expect to find (basename).gem in the 'cache' directory.
|
73
78
|
# Furthermore, the name match must be exact (ignoring case).
|
74
79
|
if gemname =~ /^#{selected.name}$/i
|
75
80
|
filename = selected.full_name + '.gem'
|
76
|
-
|
81
|
+
path = nil
|
82
|
+
|
83
|
+
Gem.path.find do |gem_dir|
|
84
|
+
path = File.join gem_dir, 'cache', filename
|
85
|
+
File.exist? path
|
86
|
+
end
|
87
|
+
|
88
|
+
path
|
77
89
|
else
|
78
|
-
|
90
|
+
nil
|
79
91
|
end
|
80
92
|
end
|
81
93
|
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'rubygems/command'
|
2
|
+
require 'rubygems/command_manager'
|
2
3
|
require 'rubygems/install_update_options'
|
3
4
|
require 'rubygems/local_remote_options'
|
4
5
|
require 'rubygems/source_info_cache'
|
5
6
|
require 'rubygems/version_option'
|
7
|
+
require 'rubygems/commands/install_command'
|
6
8
|
|
7
9
|
class Gem::Commands::UpdateCommand < Gem::Command
|
8
10
|
|
@@ -45,7 +47,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
45
47
|
|
46
48
|
def execute
|
47
49
|
if options[:system] then
|
48
|
-
say "Updating RubyGems
|
50
|
+
say "Updating RubyGems"
|
49
51
|
|
50
52
|
unless options[:args].empty? then
|
51
53
|
fail "No gem names are allowed with the --system option"
|
@@ -53,10 +55,10 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
53
55
|
|
54
56
|
options[:args] = ["rubygems-update"]
|
55
57
|
else
|
56
|
-
say "Updating installed gems
|
58
|
+
say "Updating installed gems"
|
57
59
|
end
|
58
60
|
|
59
|
-
hig =
|
61
|
+
hig = {}
|
60
62
|
|
61
63
|
Gem::SourceIndex.from_installed_gems.each do |name, spec|
|
62
64
|
if hig[spec.name].nil? or hig[spec.name].version < spec.version then
|
@@ -64,25 +66,28 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
|
-
|
69
|
+
pattern = if options[:args].empty? then
|
70
|
+
//
|
71
|
+
else
|
72
|
+
Regexp.union(*options[:args])
|
73
|
+
end
|
68
74
|
|
69
|
-
|
70
|
-
which_to_update(highest_installed_gems, remote_gemspecs)
|
71
|
-
else
|
72
|
-
options[:args]
|
73
|
-
end
|
75
|
+
remote_gemspecs = Gem::SourceInfoCache.search pattern
|
74
76
|
|
75
|
-
|
77
|
+
gems_to_update = which_to_update hig, remote_gemspecs
|
76
78
|
|
77
|
-
|
78
|
-
install_command = Gem::CommandManager.instance['install']
|
79
|
+
updated = []
|
79
80
|
|
81
|
+
# HACK use the real API
|
80
82
|
gems_to_update.uniq.sort.each do |name|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
next if updated.any? { |spec| spec.name == name }
|
84
|
+
say "Updating #{name}"
|
85
|
+
installer = Gem::DependencyInstaller.new options
|
86
|
+
installer.install name
|
87
|
+
installer.installed_gems.each do |spec|
|
88
|
+
updated << spec
|
89
|
+
say "Successfully installed #{spec.full_name}"
|
90
|
+
end
|
86
91
|
end
|
87
92
|
|
88
93
|
if gems_to_update.include? "rubygems-update" then
|
@@ -97,12 +102,10 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
97
102
|
|
98
103
|
say "RubyGems system software updated" if installed
|
99
104
|
else
|
100
|
-
updated = gems_to_update.uniq.sort.collect { |g| g.to_s }
|
101
|
-
|
102
105
|
if updated.empty? then
|
103
106
|
say "Nothing to update"
|
104
107
|
else
|
105
|
-
say "Gems updated: #{updated.join ', '}"
|
108
|
+
say "Gems updated: #{updated.map { |spec| spec.name }.join ', '}"
|
106
109
|
end
|
107
110
|
end
|
108
111
|
end
|
@@ -122,11 +125,10 @@ class Gem::Commands::UpdateCommand < Gem::Command
|
|
122
125
|
setup_cmd = "#{Gem.ruby} setup.rb #{args.join ' '}"
|
123
126
|
|
124
127
|
# Make sure old rubygems isn't loaded
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
end
|
128
|
+
old = ENV["RUBYOPT"]
|
129
|
+
ENV.delete("RUBYOPT")
|
130
|
+
system setup_cmd
|
131
|
+
ENV["RUBYOPT"] = old if old
|
130
132
|
end
|
131
133
|
end
|
132
134
|
|
@@ -28,7 +28,7 @@ module Kernel
|
|
28
28
|
rescue LoadError => load_error
|
29
29
|
if load_error.message =~ /\A[Nn]o such file to load -- #{Regexp.escape path}\z/ and
|
30
30
|
spec = Gem.searcher.find(path) then
|
31
|
-
Gem.activate(spec.name,
|
31
|
+
Gem.activate(spec.name, "= #{spec.version}")
|
32
32
|
gem_original_require path
|
33
33
|
else
|
34
34
|
raise load_error
|
data/lib/rubygems/defaults.rb
CHANGED
@@ -11,6 +11,9 @@ module Gem
|
|
11
11
|
if defined? RUBY_FRAMEWORK_VERSION then
|
12
12
|
File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
|
13
13
|
ConfigMap[:ruby_version]
|
14
|
+
elsif defined? RUBY_ENGINE then
|
15
|
+
File.join ConfigMap[:libdir], RUBY_ENGINE, 'gems',
|
16
|
+
ConfigMap[:ruby_version]
|
14
17
|
else
|
15
18
|
File.join ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version]
|
16
19
|
end
|
@@ -29,7 +32,11 @@ module Gem
|
|
29
32
|
|
30
33
|
# The default directory for binaries
|
31
34
|
def self.default_bindir
|
32
|
-
|
35
|
+
if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
|
36
|
+
'/usr/bin'
|
37
|
+
else # generic install
|
38
|
+
ConfigMap[:bindir]
|
39
|
+
end
|
33
40
|
end
|
34
41
|
|
35
42
|
# The default system-wide source info cache directory.
|
@@ -22,8 +22,7 @@ class Gem::DependencyInstaller
|
|
22
22
|
}
|
23
23
|
|
24
24
|
##
|
25
|
-
# Creates a new installer instance
|
26
|
-
# version requirement +version+ and +options+.
|
25
|
+
# Creates a new installer instance.
|
27
26
|
#
|
28
27
|
# Options are:
|
29
28
|
# :env_shebang:: See Gem::Installer::new.
|
@@ -36,7 +35,7 @@ class Gem::DependencyInstaller
|
|
36
35
|
# :install_dir: See Gem::Installer#install.
|
37
36
|
# :security_policy: See Gem::Installer::new and Gem::Security.
|
38
37
|
# :wrappers: See Gem::Installer::new
|
39
|
-
def initialize(
|
38
|
+
def initialize(options = {})
|
40
39
|
options = DEFAULT_OPTIONS.merge options
|
41
40
|
@env_shebang = options[:env_shebang]
|
42
41
|
@domain = options[:domain]
|
@@ -46,49 +45,9 @@ class Gem::DependencyInstaller
|
|
46
45
|
@install_dir = options[:install_dir] || Gem.dir
|
47
46
|
@security_policy = options[:security_policy]
|
48
47
|
@wrappers = options[:wrappers]
|
48
|
+
@bin_dir = options[:bin_dir]
|
49
49
|
|
50
50
|
@installed_gems = []
|
51
|
-
|
52
|
-
spec_and_source = nil
|
53
|
-
|
54
|
-
glob = if File::ALT_SEPARATOR then
|
55
|
-
gem_name.gsub File::ALT_SEPARATOR, File::SEPARATOR
|
56
|
-
else
|
57
|
-
gem_name
|
58
|
-
end
|
59
|
-
|
60
|
-
local_gems = Dir["#{glob}*"].sort.reverse
|
61
|
-
|
62
|
-
unless local_gems.empty? then
|
63
|
-
local_gems.each do |gem_file|
|
64
|
-
next unless gem_file =~ /gem$/
|
65
|
-
begin
|
66
|
-
spec = Gem::Format.from_file_by_path(gem_file).spec
|
67
|
-
spec_and_source = [spec, gem_file]
|
68
|
-
break
|
69
|
-
rescue SystemCallError, Gem::Package::FormatError
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
if spec_and_source.nil? then
|
75
|
-
version ||= Gem::Requirement.default
|
76
|
-
@dep = Gem::Dependency.new gem_name, version
|
77
|
-
spec_and_sources = find_gems_with_sources(@dep).reverse
|
78
|
-
|
79
|
-
spec_and_source = spec_and_sources.find do |spec, source|
|
80
|
-
Gem::Platform.match spec.platform
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
if spec_and_source.nil? then
|
85
|
-
raise Gem::GemNotFoundException,
|
86
|
-
"could not find #{gem_name} locally or in a repository"
|
87
|
-
end
|
88
|
-
|
89
|
-
@specs_and_sources = [spec_and_source]
|
90
|
-
|
91
|
-
gather_dependencies
|
92
51
|
end
|
93
52
|
|
94
53
|
##
|
@@ -107,71 +66,30 @@ class Gem::DependencyInstaller
|
|
107
66
|
end
|
108
67
|
|
109
68
|
if @domain == :both or @domain == :remote then
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
[gem, source !~ /^http:\/\// ? 1 : 0] # local gems win
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
##
|
119
|
-
# Moves the gem +spec+ from +source_uri+ to the cache dir unless it is
|
120
|
-
# already there. If the source_uri is local the gem cache dir copy is
|
121
|
-
# always replaced.
|
122
|
-
def download(spec, source_uri)
|
123
|
-
gem_file_name = "#{spec.full_name}.gem"
|
124
|
-
local_gem_path = File.join @install_dir, 'cache', gem_file_name
|
125
|
-
|
126
|
-
Gem.ensure_gem_subdirectories @install_dir
|
127
|
-
|
128
|
-
source_uri = URI.parse source_uri unless URI::Generic === source_uri
|
129
|
-
scheme = source_uri.scheme
|
130
|
-
|
131
|
-
# URI.parse gets confused by MS Windows paths with forward slashes.
|
132
|
-
scheme = nil if scheme =~ /^[a-z]$/i
|
133
|
-
|
134
|
-
case scheme
|
135
|
-
when 'http' then
|
136
|
-
unless File.exist? local_gem_path then
|
137
|
-
begin
|
138
|
-
say "Downloading gem #{gem_file_name}" if
|
139
|
-
Gem.configuration.really_verbose
|
140
|
-
|
141
|
-
remote_gem_path = source_uri + "gems/#{gem_file_name}"
|
142
|
-
|
143
|
-
gem = Gem::RemoteFetcher.fetcher.fetch_path remote_gem_path
|
144
|
-
rescue Gem::RemoteFetcher::FetchError
|
145
|
-
raise if spec.original_platform == spec.platform
|
146
|
-
|
147
|
-
alternate_name = "#{spec.name}-#{spec.version}-#{spec.original_platform}.gem"
|
69
|
+
begin
|
70
|
+
requirements = dep.version_requirements.requirements.map do |req, ver|
|
71
|
+
req
|
72
|
+
end
|
148
73
|
|
149
|
-
|
150
|
-
|
74
|
+
all = requirements.length > 1 ||
|
75
|
+
requirements.first != ">=" || requirements.first != ">"
|
151
76
|
|
152
|
-
|
77
|
+
found = Gem::SourceInfoCache.search_with_source dep, true, all
|
153
78
|
|
154
|
-
|
155
|
-
end
|
79
|
+
gems_and_sources.push(*found)
|
156
80
|
|
157
|
-
|
158
|
-
|
81
|
+
rescue Gem::RemoteFetcher::FetchError => e
|
82
|
+
if Gem.configuration.really_verbose then
|
83
|
+
say "Error fetching remote data:\t\t#{e.message}"
|
84
|
+
say "Falling back to local-only install"
|
159
85
|
end
|
86
|
+
@domain = :local
|
160
87
|
end
|
161
|
-
when nil, 'file' then # TODO test for local overriding cache
|
162
|
-
begin
|
163
|
-
FileUtils.cp source_uri.to_s, local_gem_path
|
164
|
-
rescue Errno::EACCES
|
165
|
-
local_gem_path = source_uri.to_s
|
166
|
-
end
|
167
|
-
|
168
|
-
say "Using local gem #{local_gem_path}" if
|
169
|
-
Gem.configuration.really_verbose
|
170
|
-
else
|
171
|
-
raise Gem::InstallError, "unsupported URI scheme #{source_uri.scheme}"
|
172
88
|
end
|
173
89
|
|
174
|
-
|
90
|
+
gems_and_sources.sort_by do |gem, source|
|
91
|
+
[gem, source =~ /^http:\/\// ? 0 : 1] # local gems win
|
92
|
+
end
|
175
93
|
end
|
176
94
|
|
177
95
|
##
|
@@ -208,9 +126,57 @@ class Gem::DependencyInstaller
|
|
208
126
|
@gems_to_install = dependency_list.dependency_order.reverse
|
209
127
|
end
|
210
128
|
|
129
|
+
def find_spec_by_name_and_version gem_name, version = Gem::Requirement.default
|
130
|
+
spec_and_source = nil
|
131
|
+
|
132
|
+
glob = if File::ALT_SEPARATOR then
|
133
|
+
gem_name.gsub File::ALT_SEPARATOR, File::SEPARATOR
|
134
|
+
else
|
135
|
+
gem_name
|
136
|
+
end
|
137
|
+
|
138
|
+
local_gems = Dir["#{glob}*"].sort.reverse
|
139
|
+
|
140
|
+
unless local_gems.empty? then
|
141
|
+
local_gems.each do |gem_file|
|
142
|
+
next unless gem_file =~ /gem$/
|
143
|
+
begin
|
144
|
+
spec = Gem::Format.from_file_by_path(gem_file).spec
|
145
|
+
spec_and_source = [spec, gem_file]
|
146
|
+
break
|
147
|
+
rescue SystemCallError, Gem::Package::FormatError
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
if spec_and_source.nil? then
|
153
|
+
dep = Gem::Dependency.new gem_name, version
|
154
|
+
spec_and_sources = find_gems_with_sources(dep).reverse
|
155
|
+
|
156
|
+
spec_and_source = spec_and_sources.find { |spec, source|
|
157
|
+
Gem::Platform.match spec.platform
|
158
|
+
}
|
159
|
+
end
|
160
|
+
|
161
|
+
if spec_and_source.nil? then
|
162
|
+
raise Gem::GemNotFoundException,
|
163
|
+
"could not find #{gem_name} locally or in a repository"
|
164
|
+
end
|
165
|
+
|
166
|
+
@specs_and_sources = [spec_and_source]
|
167
|
+
end
|
168
|
+
|
211
169
|
##
|
212
170
|
# Installs the gem and all its dependencies.
|
213
|
-
def install
|
171
|
+
def install dep_or_name, version = Gem::Requirement.default
|
172
|
+
if String === dep_or_name then
|
173
|
+
find_spec_by_name_and_version dep_or_name, version
|
174
|
+
else
|
175
|
+
@specs_and_sources = [find_gems_with_sources(dep_or_name).last]
|
176
|
+
end
|
177
|
+
|
178
|
+
gather_dependencies
|
179
|
+
|
214
180
|
spec_dir = File.join @install_dir, 'specifications'
|
215
181
|
source_index = Gem::SourceIndex.from_gems_in spec_dir
|
216
182
|
|
@@ -219,10 +185,11 @@ class Gem::DependencyInstaller
|
|
219
185
|
# HACK is this test for full_name acceptable?
|
220
186
|
next if source_index.any? { |n,_| n == spec.full_name } and not last
|
221
187
|
|
188
|
+
# TODO: make this sorta_verbose so other users can benefit from it
|
222
189
|
say "Installing gem #{spec.full_name}" if Gem.configuration.really_verbose
|
223
190
|
|
224
191
|
_, source_uri = @specs_and_sources.assoc spec
|
225
|
-
local_gem_path = download spec, source_uri
|
192
|
+
local_gem_path = Gem::RemoteFetcher.fetcher.download spec, source_uri
|
226
193
|
|
227
194
|
inst = Gem::Installer.new local_gem_path,
|
228
195
|
:env_shebang => @env_shebang,
|
@@ -231,7 +198,8 @@ class Gem::DependencyInstaller
|
|
231
198
|
:ignore_dependencies => @ignore_dependencies,
|
232
199
|
:install_dir => @install_dir,
|
233
200
|
:security_policy => @security_policy,
|
234
|
-
:wrappers => @wrappers
|
201
|
+
:wrappers => @wrappers,
|
202
|
+
:bin_dir => @bin_dir
|
235
203
|
|
236
204
|
spec = inst.install
|
237
205
|
|