rubygems-update 1.4.2 → 1.5.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/.autotest +4 -5
- data/{test/foo/discover.rb → .gemtest} +0 -0
- data/ChangeLog +13 -0
- data/History.txt +35 -1
- data/Manifest.txt +89 -88
- data/README.rdoc +21 -10
- data/Rakefile +31 -17
- data/UPGRADING.rdoc +81 -0
- data/ci_build.sh +27 -0
- data/cruise_config.rb +20 -13
- data/lib/rbconfig/datadir.rb +1 -1
- data/lib/rubygems.rb +102 -45
- data/lib/rubygems/builder.rb +5 -11
- data/lib/rubygems/command_manager.rb +0 -1
- data/lib/rubygems/commands/check_command.rb +2 -17
- data/lib/rubygems/commands/cleanup_command.rb +1 -1
- data/lib/rubygems/commands/dependency_command.rb +5 -18
- data/lib/rubygems/commands/environment_command.rb +5 -4
- data/lib/rubygems/commands/fetch_command.rb +0 -1
- data/lib/rubygems/commands/generate_index_command.rb +1 -10
- data/lib/rubygems/commands/help_command.rb +0 -5
- data/lib/rubygems/commands/query_command.rb +4 -24
- data/lib/rubygems/commands/setup_command.rb +4 -19
- data/lib/rubygems/commands/sources_command.rb +15 -37
- data/lib/rubygems/commands/specification_command.rb +1 -2
- data/lib/rubygems/commands/unpack_command.rb +19 -7
- data/lib/rubygems/commands/update_command.rb +29 -44
- data/lib/rubygems/config_file.rb +25 -19
- data/lib/rubygems/custom_require.rb +4 -6
- data/lib/rubygems/dependency.rb +1 -43
- data/lib/rubygems/dependency_installer.rb +1 -1
- data/lib/rubygems/doc_manager.rb +3 -1
- data/lib/rubygems/ext/builder.rb +3 -1
- data/lib/rubygems/ext/rake_builder.rb +10 -2
- data/lib/rubygems/format.rb +7 -4
- data/lib/rubygems/gem_runner.rb +1 -1
- data/lib/rubygems/indexer.rb +11 -74
- data/lib/rubygems/install_update_options.rb +13 -8
- data/lib/rubygems/installer.rb +139 -95
- data/{test/gem_installer_test_case.rb → lib/rubygems/installer_test_case.rb} +41 -2
- data/{test/mockgemui.rb → lib/rubygems/mock_gem_ui.rb} +8 -1
- data/lib/rubygems/old_format.rb +2 -1
- data/lib/rubygems/package.rb +17 -2
- data/lib/rubygems/package/tar_input.rb +7 -3
- data/lib/rubygems/package/tar_output.rb +2 -0
- data/lib/rubygems/package/tar_reader/entry.rb +4 -0
- data/{test/gem_package_tar_test_case.rb → lib/rubygems/package/tar_test_case.rb} +5 -2
- data/lib/rubygems/package_task.rb +6 -4
- data/lib/rubygems/remote_fetcher.rb +10 -2
- data/lib/rubygems/require_paths_builder.rb +2 -1
- data/lib/rubygems/server.rb +3 -44
- data/lib/rubygems/source_index.rb +3 -216
- data/lib/rubygems/spec_fetcher.rb +15 -63
- data/lib/rubygems/specification.rb +1 -1
- data/{test/gemutilities.rb → lib/rubygems/test_case.rb} +219 -90
- data/lib/rubygems/test_utilities.rb +7 -20
- data/lib/rubygems/uninstaller.rb +27 -28
- data/lib/rubygems/user_interaction.rb +81 -42
- data/lib/rubygems/validator.rb +0 -73
- data/test/{bogussources.rb → rubygems/bogussources.rb} +0 -0
- data/test/{data → rubygems/data}/gem-private_key.pem +0 -0
- data/test/{data → rubygems/data}/gem-public_cert.pem +0 -0
- data/test/{fake_certlib → rubygems/fake_certlib}/openssl.rb +0 -0
- data/test/rubygems/foo/discover.rb +0 -0
- data/test/{functional.rb → rubygems/functional.rb} +0 -0
- data/test/{insure_session.rb → rubygems/insure_session.rb} +0 -0
- data/test/{plugin → rubygems/plugin}/exception/rubygems_plugin.rb +0 -0
- data/test/{plugin → rubygems/plugin}/load/rubygems_plugin.rb +0 -0
- data/test/{plugin → rubygems/plugin}/standarderror/rubygems_plugin.rb +0 -0
- data/test/{private_key.pem → rubygems/private_key.pem} +0 -0
- data/test/{public_cert.pem → rubygems/public_cert.pem} +0 -0
- data/test/rubygems/{commands → rubygems/commands}/crash_command.rb +0 -0
- data/test/{rubygems_plugin.rb → rubygems/rubygems_plugin.rb} +0 -0
- data/test/rubygems/sff/discover.rb +0 -0
- data/test/{simple_gem.rb → rubygems/simple_gem.rb} +2 -2
- data/test/{test_config.rb → rubygems/test_config.rb} +2 -2
- data/test/{test_gem.rb → rubygems/test_gem.rb} +12 -2
- data/test/{test_gem_builder.rb → rubygems/test_gem_builder.rb} +2 -2
- data/test/{test_gem_command.rb → rubygems/test_gem_command.rb} +3 -3
- data/test/{test_gem_command_manager.rb → rubygems/test_gem_command_manager.rb} +15 -6
- data/test/{test_gem_commands_build_command.rb → rubygems/test_gem_commands_build_command.rb} +2 -2
- data/test/{test_gem_commands_cert_command.rb → rubygems/test_gem_commands_cert_command.rb} +2 -2
- data/test/{test_gem_commands_check_command.rb → rubygems/test_gem_commands_check_command.rb} +2 -2
- data/test/{test_gem_commands_contents_command.rb → rubygems/test_gem_commands_contents_command.rb} +3 -3
- data/test/{test_gem_commands_dependency_command.rb → rubygems/test_gem_commands_dependency_command.rb} +4 -4
- data/test/{test_gem_commands_environment_command.rb → rubygems/test_gem_commands_environment_command.rb} +12 -3
- data/test/{test_gem_commands_fetch_command.rb → rubygems/test_gem_commands_fetch_command.rb} +2 -2
- data/test/{test_gem_commands_generate_index_command.rb → rubygems/test_gem_commands_generate_index_command.rb} +7 -11
- data/test/{test_gem_commands_install_command.rb → rubygems/test_gem_commands_install_command.rb} +2 -2
- data/test/{test_gem_commands_list_command.rb → rubygems/test_gem_commands_list_command.rb} +2 -2
- data/test/{test_gem_commands_lock_command.rb → rubygems/test_gem_commands_lock_command.rb} +2 -2
- data/test/{test_gem_commands_outdated_command.rb → rubygems/test_gem_commands_outdated_command.rb} +2 -2
- data/test/{test_gem_commands_owner_command.rb → rubygems/test_gem_commands_owner_command.rb} +5 -5
- data/test/{test_gem_commands_pristine_command.rb → rubygems/test_gem_commands_pristine_command.rb} +2 -2
- data/test/{test_gem_commands_push_command.rb → rubygems/test_gem_commands_push_command.rb} +3 -3
- data/test/{test_gem_commands_query_command.rb → rubygems/test_gem_commands_query_command.rb} +2 -2
- data/test/{test_gem_commands_server_command.rb → rubygems/test_gem_commands_server_command.rb} +2 -2
- data/test/{test_gem_commands_sources_command.rb → rubygems/test_gem_commands_sources_command.rb} +8 -8
- data/test/{test_gem_commands_specification_command.rb → rubygems/test_gem_commands_specification_command.rb} +3 -3
- data/test/{test_gem_commands_stale_command.rb → rubygems/test_gem_commands_stale_command.rb} +2 -2
- data/test/{test_gem_commands_uninstall_command.rb → rubygems/test_gem_commands_uninstall_command.rb} +16 -10
- data/test/{test_gem_commands_unpack_command.rb → rubygems/test_gem_commands_unpack_command.rb} +42 -2
- data/test/{test_gem_commands_update_command.rb → rubygems/test_gem_commands_update_command.rb} +2 -2
- data/test/{test_gem_commands_which_command.rb → rubygems/test_gem_commands_which_command.rb} +3 -3
- data/test/{test_gem_config_file.rb → rubygems/test_gem_config_file.rb} +2 -2
- data/test/{test_gem_dependency.rb → rubygems/test_gem_dependency.rb} +3 -27
- data/test/{test_gem_dependency_installer.rb → rubygems/test_gem_dependency_installer.rb} +2 -2
- data/test/{test_gem_dependency_list.rb → rubygems/test_gem_dependency_list.rb} +3 -3
- data/test/{test_gem_doc_manager.rb → rubygems/test_gem_doc_manager.rb} +2 -2
- data/test/{test_gem_ext_configure_builder.rb → rubygems/test_gem_ext_configure_builder.rb} +4 -4
- data/test/{test_gem_ext_ext_conf_builder.rb → rubygems/test_gem_ext_ext_conf_builder.rb} +46 -2
- data/test/{test_gem_ext_rake_builder.rb → rubygems/test_gem_ext_rake_builder.rb} +2 -2
- data/test/{test_gem_format.rb → rubygems/test_gem_format.rb} +24 -6
- data/test/{test_gem_gem_path_searcher.rb → rubygems/test_gem_gem_path_searcher.rb} +2 -2
- data/test/{test_gem_gem_runner.rb → rubygems/test_gem_gem_runner.rb} +2 -2
- data/test/{test_gem_gemcutter_utilities.rb → rubygems/test_gem_gemcutter_utilities.rb} +4 -4
- data/test/{test_gem_indexer.rb → rubygems/test_gem_indexer.rb} +4 -121
- data/test/{test_gem_install_update_options.rb → rubygems/test_gem_install_update_options.rb} +3 -3
- data/test/{test_gem_installer.rb → rubygems/test_gem_installer.rb} +106 -13
- data/test/{test_gem_local_remote_options.rb → rubygems/test_gem_local_remote_options.rb} +2 -2
- data/test/{test_gem_package_tar_header.rb → rubygems/test_gem_package_tar_header.rb} +2 -2
- data/test/{test_gem_package_tar_input.rb → rubygems/test_gem_package_tar_input.rb} +21 -4
- data/test/{test_gem_package_tar_output.rb → rubygems/test_gem_package_tar_output.rb} +2 -2
- data/test/{test_gem_package_tar_reader.rb → rubygems/test_gem_package_tar_reader.rb} +2 -2
- data/test/{test_gem_package_tar_reader_entry.rb → rubygems/test_gem_package_tar_reader_entry.rb} +12 -2
- data/test/{test_gem_package_tar_writer.rb → rubygems/test_gem_package_tar_writer.rb} +2 -2
- data/test/{test_gem_package_task.rb → rubygems/test_gem_package_task.rb} +15 -2
- data/test/{test_gem_platform.rb → rubygems/test_gem_platform.rb} +2 -2
- data/test/{test_gem_remote_fetcher.rb → rubygems/test_gem_remote_fetcher.rb} +7 -7
- data/test/{test_gem_requirement.rb → rubygems/test_gem_requirement.rb} +2 -2
- data/test/{test_gem_security.rb → rubygems/test_gem_security.rb} +3 -4
- data/test/{test_gem_server.rb → rubygems/test_gem_server.rb} +2 -132
- data/test/rubygems/test_gem_silent_ui.rb +113 -0
- data/test/{test_gem_source_index.rb → rubygems/test_gem_source_index.rb} +2 -61
- data/test/{test_gem_spec_fetcher.rb → rubygems/test_gem_spec_fetcher.rb} +2 -2
- data/test/{test_gem_specification.rb → rubygems/test_gem_specification.rb} +4 -4
- data/test/{test_gem_stream_ui.rb → rubygems/test_gem_stream_ui.rb} +24 -2
- data/test/{test_gem_text.rb → rubygems/test_gem_text.rb} +2 -2
- data/test/{test_gem_uninstaller.rb → rubygems/test_gem_uninstaller.rb} +15 -12
- data/test/{test_gem_validator.rb → rubygems/test_gem_validator.rb} +3 -3
- data/test/{test_gem_version.rb → rubygems/test_gem_version.rb} +2 -2
- data/test/{test_gem_version_option.rb → rubygems/test_gem_version_option.rb} +2 -2
- data/test/{test_kernel.rb → rubygems/test_kernel.rb} +7 -10
- metadata +281 -177
- metadata.gz.sig +0 -0
- data/lib/rubygems/commands/mirror_command.rb +0 -111
- data/lib/rubygems/source_info_cache.rb +0 -394
- data/lib/rubygems/source_info_cache_entry.rb +0 -56
- data/test/test_gem_commands_mirror_command.rb +0 -60
data/lib/rubygems/config_file.rb
CHANGED
@@ -47,23 +47,29 @@ class Gem::ConfigFile
|
|
47
47
|
|
48
48
|
system_config_path =
|
49
49
|
begin
|
50
|
-
require
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
50
|
+
require "etc"
|
51
|
+
Etc.sysconfdir
|
52
|
+
rescue LoadError, NoMethodError
|
53
|
+
begin
|
54
|
+
# TODO: remove after we drop 1.8.7 and 1.9.1
|
55
|
+
require 'Win32API'
|
56
|
+
|
57
|
+
CSIDL_COMMON_APPDATA = 0x0023
|
58
|
+
path = 0.chr * 260
|
59
|
+
if RUBY_VERSION > '1.9' then
|
60
|
+
SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'PLPLP',
|
61
|
+
'L', :stdcall
|
62
|
+
SHGetFolderPath.call nil, CSIDL_COMMON_APPDATA, nil, 1, path
|
63
|
+
else
|
64
|
+
SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP',
|
65
|
+
'L'
|
66
|
+
SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path
|
67
|
+
end
|
68
|
+
|
69
|
+
path.strip
|
70
|
+
rescue LoadError
|
71
|
+
"/etc"
|
62
72
|
end
|
63
|
-
|
64
|
-
path.strip
|
65
|
-
rescue LoadError
|
66
|
-
'/etc'
|
67
73
|
end
|
68
74
|
|
69
75
|
SYSTEM_WIDE_CONFIG_FILE = File.join system_config_path, 'gemrc'
|
@@ -205,7 +211,7 @@ class Gem::ConfigFile
|
|
205
211
|
dirname = File.dirname(credentials_path)
|
206
212
|
Dir.mkdir(dirname) unless File.exists?(dirname)
|
207
213
|
|
208
|
-
|
214
|
+
Gem.load_yaml
|
209
215
|
|
210
216
|
File.open(credentials_path, 'w') do |f|
|
211
217
|
f.write config.to_yaml
|
@@ -215,9 +221,10 @@ class Gem::ConfigFile
|
|
215
221
|
end
|
216
222
|
|
217
223
|
def load_file(filename)
|
224
|
+
Gem.load_yaml
|
225
|
+
|
218
226
|
return {} unless filename and File.exists?(filename)
|
219
227
|
begin
|
220
|
-
require 'yaml'
|
221
228
|
YAML.load(File.read(filename))
|
222
229
|
rescue ArgumentError
|
223
230
|
warn "Failed to load #{config_file_name}"
|
@@ -312,7 +319,6 @@ class Gem::ConfigFile
|
|
312
319
|
|
313
320
|
# Writes out this config file, replacing its source.
|
314
321
|
def write
|
315
|
-
require 'yaml'
|
316
322
|
open config_file_name, 'w' do |io|
|
317
323
|
io.write to_yaml
|
318
324
|
end
|
@@ -28,13 +28,11 @@ module Kernel
|
|
28
28
|
def require(path) # :doc:
|
29
29
|
gem_original_require path
|
30
30
|
rescue LoadError => load_error
|
31
|
-
if load_error.message
|
32
|
-
|
33
|
-
Gem.activate(spec.name, "= #{spec.version}")
|
34
|
-
gem_original_require path
|
35
|
-
else
|
36
|
-
raise load_error
|
31
|
+
if load_error.message.end_with?(path) and Gem.try_activate(path) then
|
32
|
+
return gem_original_require(path)
|
37
33
|
end
|
34
|
+
|
35
|
+
raise load_error
|
38
36
|
end
|
39
37
|
|
40
38
|
private :require
|
data/lib/rubygems/dependency.rb
CHANGED
@@ -5,18 +5,6 @@ require "rubygems/requirement"
|
|
5
5
|
|
6
6
|
class Gem::Dependency
|
7
7
|
|
8
|
-
# :stopdoc:
|
9
|
-
@warned_version_requirement = false
|
10
|
-
|
11
|
-
def self.warned_version_requirement
|
12
|
-
@warned_version_requirement
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.warned_version_requirement= value
|
16
|
-
@warned_version_requirement = value
|
17
|
-
end
|
18
|
-
# :startdoc:
|
19
|
-
|
20
8
|
##
|
21
9
|
# Valid dependency types.
|
22
10
|
#--
|
@@ -62,7 +50,7 @@ class Gem::Dependency
|
|
62
50
|
@type = type
|
63
51
|
@prerelease = false
|
64
52
|
|
65
|
-
# This is for Marshal backwards
|
53
|
+
# This is for Marshal backwards compatibility. See the comments in
|
66
54
|
# +requirement+ for the dirty details.
|
67
55
|
|
68
56
|
@version_requirements = @requirement
|
@@ -133,12 +121,6 @@ class Gem::Dependency
|
|
133
121
|
@requirement = @version_requirements if defined?(@version_requirements)
|
134
122
|
end
|
135
123
|
|
136
|
-
##
|
137
|
-
# Rails subclasses Gem::Dependency and uses this method, so we'll hack
|
138
|
-
# around it.
|
139
|
-
|
140
|
-
alias __requirement requirement # :nodoc:
|
141
|
-
|
142
124
|
def requirements_list
|
143
125
|
requirement.as_list
|
144
126
|
end
|
@@ -147,30 +129,6 @@ class Gem::Dependency
|
|
147
129
|
"#{name} (#{requirement}, #{type})"
|
148
130
|
end
|
149
131
|
|
150
|
-
def version_requirements # :nodoc:
|
151
|
-
unless Gem::Dependency.warned_version_requirement then
|
152
|
-
warn "#{Gem.location_of_caller.join ':'}:Warning: " \
|
153
|
-
"Gem::Dependency#version_requirements is deprecated " \
|
154
|
-
"and will be removed on or after August 2010. " \
|
155
|
-
"Use #requirement"
|
156
|
-
|
157
|
-
Gem::Dependency.warned_version_requirement = true
|
158
|
-
end
|
159
|
-
|
160
|
-
__requirement
|
161
|
-
end
|
162
|
-
|
163
|
-
alias version_requirement version_requirements # :nodoc:
|
164
|
-
|
165
|
-
def version_requirements= requirements # :nodoc:
|
166
|
-
warn "#{Gem.location_of_caller.join ':'}:Warning: " \
|
167
|
-
"Gem::Dependency#version_requirements= is deprecated " \
|
168
|
-
"and will be removed on or after August 2010. " \
|
169
|
-
"Use Gem::Dependency.new."
|
170
|
-
|
171
|
-
@requirement = Gem::Requirement.create requirements
|
172
|
-
end
|
173
|
-
|
174
132
|
def == other # :nodoc:
|
175
133
|
Gem::Dependency === other &&
|
176
134
|
self.name == other.name &&
|
@@ -78,7 +78,7 @@ class Gem::DependencyInstaller
|
|
78
78
|
##
|
79
79
|
# Returns a list of pairs of gemspecs and source_uris that match
|
80
80
|
# Gem::Dependency +dep+ from both local (Dir.pwd) and remote (Gem.sources)
|
81
|
-
# sources. Gems are sorted with newer gems
|
81
|
+
# sources. Gems are sorted with newer gems preferred over older gems, and
|
82
82
|
# local gems preferred over remote gems.
|
83
83
|
|
84
84
|
def find_gems_with_sources(dep)
|
data/lib/rubygems/doc_manager.rb
CHANGED
@@ -188,7 +188,9 @@ class Gem::DocManager
|
|
188
188
|
rescue Errno::EACCES => e
|
189
189
|
dirname = File.dirname e.message.split("-")[1].strip
|
190
190
|
raise Gem::FilePermissionError.new(dirname)
|
191
|
-
rescue
|
191
|
+
rescue Interrupt => e
|
192
|
+
raise e
|
193
|
+
rescue Exception => ex
|
192
194
|
alert_error "While generating documentation for #{@spec.full_name}"
|
193
195
|
ui.errs.puts "... MESSAGE: #{ex}"
|
194
196
|
ui.errs.puts "... RDOC args: #{args.join(' ')}"
|
data/lib/rubygems/ext/builder.rb
CHANGED
@@ -22,7 +22,9 @@ class Gem::Ext::Builder
|
|
22
22
|
|
23
23
|
File.open('Makefile', 'wb') {|f| f.print mf}
|
24
24
|
|
25
|
-
|
25
|
+
# try to find make program from Ruby configure arguments first
|
26
|
+
RbConfig::CONFIG['configure_args'] =~ /with-make-prog\=(\w+)/
|
27
|
+
make_program = $1 || ENV['make']
|
26
28
|
unless make_program then
|
27
29
|
make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
|
28
30
|
end
|
@@ -19,8 +19,16 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
|
|
19
19
|
# Deal with possible spaces in the path, e.g. C:/Program Files
|
20
20
|
dest_path = '"' + dest_path + '"' if dest_path.include?(' ')
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
rake = ENV['rake']
|
23
|
+
|
24
|
+
rake ||= begin
|
25
|
+
"\"#{Gem.ruby}\" -rubygems #{Gem.bin_path('rake')}"
|
26
|
+
rescue Gem::Exception
|
27
|
+
end
|
28
|
+
|
29
|
+
rake ||= Gem.default_exec_format % 'rake'
|
30
|
+
|
31
|
+
cmd = "#{rake} RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}" # ENV is frozen
|
24
32
|
|
25
33
|
run cmd, results
|
26
34
|
|
data/lib/rubygems/format.rb
CHANGED
@@ -16,8 +16,6 @@ class Gem::Format
|
|
16
16
|
attr_accessor :file_entries
|
17
17
|
attr_accessor :gem_path
|
18
18
|
|
19
|
-
extend Gem::UserInteraction
|
20
|
-
|
21
19
|
##
|
22
20
|
# Constructs a Format representing the gem's data which came from +gem_path+
|
23
21
|
|
@@ -43,8 +41,13 @@ class Gem::Format
|
|
43
41
|
|
44
42
|
Gem::OldFormat.from_file_by_path file_path
|
45
43
|
else
|
46
|
-
|
47
|
-
|
44
|
+
begin
|
45
|
+
open file_path, Gem.binary_mode do |io|
|
46
|
+
from_io io, file_path, security_policy
|
47
|
+
end
|
48
|
+
rescue Gem::Package::TarInvalidError => e
|
49
|
+
message = "corrupt gem (#{e.class}: #{e.message})"
|
50
|
+
raise Gem::Package::FormatError.new(message, file_path)
|
48
51
|
end
|
49
52
|
end
|
50
53
|
end
|
data/lib/rubygems/gem_runner.rb
CHANGED
data/lib/rubygems/indexer.rb
CHANGED
@@ -57,7 +57,7 @@ class Gem::Indexer
|
|
57
57
|
require 'tmpdir'
|
58
58
|
require 'zlib'
|
59
59
|
|
60
|
-
unless
|
60
|
+
unless defined?(Builder::XChar) then
|
61
61
|
raise "Gem::Indexer requires that the XML Builder library be installed:" \
|
62
62
|
"\n\tgem install builder"
|
63
63
|
end
|
@@ -136,42 +136,6 @@ class Gem::Indexer
|
|
136
136
|
# Builds indicies for RubyGems older than 1.2.x
|
137
137
|
|
138
138
|
def build_legacy_indicies(index)
|
139
|
-
progress = ui.progress_reporter index.size,
|
140
|
-
"Generating YAML quick index gemspecs for #{index.size} gems",
|
141
|
-
"Complete"
|
142
|
-
|
143
|
-
Gem.time 'Generated YAML quick index gemspecs' do
|
144
|
-
index.released_gems.each do |original_name, spec|
|
145
|
-
spec_file_name = "#{original_name}.gemspec.rz"
|
146
|
-
yaml_name = File.join @quick_dir, spec_file_name
|
147
|
-
|
148
|
-
yaml_zipped = Gem.deflate spec.to_yaml
|
149
|
-
open yaml_name, 'wb' do |io| io.write yaml_zipped end
|
150
|
-
|
151
|
-
progress.updated original_name
|
152
|
-
end
|
153
|
-
|
154
|
-
progress.done
|
155
|
-
end
|
156
|
-
|
157
|
-
say "Generating quick index"
|
158
|
-
|
159
|
-
Gem.time 'Generated quick index' do
|
160
|
-
open @quick_index, 'wb' do |io|
|
161
|
-
io.puts index.sort.map { |_, spec| spec.original_name }
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
say "Generating latest index"
|
166
|
-
|
167
|
-
Gem.time 'Generated latest index' do
|
168
|
-
open @latest_index, 'wb' do |io|
|
169
|
-
io.puts index.latest_specs.sort.map { |spec| spec.original_name }
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
# Don't need prerelease legacy index
|
174
|
-
|
175
139
|
say "Generating Marshal master index"
|
176
140
|
|
177
141
|
Gem.time 'Generated Marshal master index' do
|
@@ -180,32 +144,6 @@ class Gem::Indexer
|
|
180
144
|
end
|
181
145
|
end
|
182
146
|
|
183
|
-
progress = ui.progress_reporter index.size,
|
184
|
-
"Generating YAML master index for #{index.size} gems (this may take a while)",
|
185
|
-
"Complete"
|
186
|
-
|
187
|
-
Gem.time 'Generated YAML master index' do
|
188
|
-
open @master_index, 'wb' do |io|
|
189
|
-
io.puts "--- !ruby/object:#{index.class}"
|
190
|
-
io.puts "gems:"
|
191
|
-
|
192
|
-
gems = index.sort_by { |name, gemspec| gemspec.sort_obj }
|
193
|
-
gems.each do |original_name, gemspec|
|
194
|
-
yaml = gemspec.to_yaml.gsub(/^/, ' ')
|
195
|
-
yaml = yaml.sub(/\A ---/, '') # there's a needed extra ' ' here
|
196
|
-
io.print " #{original_name}:"
|
197
|
-
io.puts yaml
|
198
|
-
|
199
|
-
progress.updated original_name
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
progress.done
|
204
|
-
end
|
205
|
-
|
206
|
-
@files << @quick_dir
|
207
|
-
@files << @master_index
|
208
|
-
@files << "#{@master_index}.Z"
|
209
147
|
@files << @marshal_index
|
210
148
|
@files << "#{@marshal_index}.Z"
|
211
149
|
end
|
@@ -462,17 +400,8 @@ class Gem::Indexer
|
|
462
400
|
|
463
401
|
Gem.time 'Compressed indicies' do
|
464
402
|
if @build_legacy then
|
465
|
-
compress @quick_index, 'rz'
|
466
|
-
paranoid @quick_index, 'rz'
|
467
|
-
|
468
|
-
compress @latest_index, 'rz'
|
469
|
-
paranoid @latest_index, 'rz'
|
470
|
-
|
471
403
|
compress @marshal_index, 'Z'
|
472
404
|
paranoid @marshal_index, 'Z'
|
473
|
-
|
474
|
-
compress @master_index, 'Z'
|
475
|
-
paranoid @master_index, 'Z'
|
476
405
|
end
|
477
406
|
|
478
407
|
if @build_modern then
|
@@ -620,10 +549,18 @@ class Gem::Indexer
|
|
620
549
|
# Sanitize a single string.
|
621
550
|
|
622
551
|
def sanitize_string(string)
|
552
|
+
return string unless string
|
553
|
+
|
623
554
|
# HACK the #to_s is in here because RSpec has an Array of Arrays of
|
624
|
-
# Strings for authors. Need a way to disallow bad values on
|
555
|
+
# Strings for authors. Need a way to disallow bad values on gemspec
|
625
556
|
# generation. (Probably won't happen.)
|
626
|
-
string
|
557
|
+
string = string.to_s
|
558
|
+
|
559
|
+
begin
|
560
|
+
Builder::XChar.encode string
|
561
|
+
rescue NameError, NoMethodError
|
562
|
+
string.to_xs
|
563
|
+
end
|
627
564
|
end
|
628
565
|
|
629
566
|
##
|
@@ -5,7 +5,13 @@
|
|
5
5
|
#++
|
6
6
|
|
7
7
|
require 'rubygems'
|
8
|
-
|
8
|
+
|
9
|
+
# forward-declare
|
10
|
+
|
11
|
+
module Gem::Security # :nodoc:
|
12
|
+
class Policy # :nodoc:
|
13
|
+
end
|
14
|
+
end
|
9
15
|
|
10
16
|
##
|
11
17
|
# Mixin methods for install and update options for Gem::Commands
|
@@ -17,8 +23,12 @@ module Gem::InstallUpdateOptions
|
|
17
23
|
|
18
24
|
def add_install_update_options
|
19
25
|
OptionParser.accept Gem::Security::Policy do |value|
|
26
|
+
require 'rubygems/security'
|
27
|
+
|
20
28
|
value = Gem::Security::Policies[value]
|
21
|
-
|
29
|
+
valid = Gem::Security::Policies.keys.sort
|
30
|
+
message = "#{value} (#{valid.join ', '} are valid)"
|
31
|
+
raise OptionParser::InvalidArgument, message if value.nil?
|
22
32
|
value
|
23
33
|
end
|
24
34
|
|
@@ -58,11 +68,6 @@ module Gem::InstallUpdateOptions
|
|
58
68
|
options[:force] = value
|
59
69
|
end
|
60
70
|
|
61
|
-
add_option(:"Install/Update", '-t', '--[no-]test',
|
62
|
-
'Run unit tests prior to installation') do |value, options|
|
63
|
-
options[:test] = value
|
64
|
-
end
|
65
|
-
|
66
71
|
add_option(:"Install/Update", '-w', '--[no-]wrappers',
|
67
72
|
'Use bin wrappers for executables',
|
68
73
|
'Not available on dosish platforms') do |value, options|
|
@@ -116,7 +121,7 @@ module Gem::InstallUpdateOptions
|
|
116
121
|
# Default options for the gem install command.
|
117
122
|
|
118
123
|
def install_update_defaults_str
|
119
|
-
'--rdoc --no-force --
|
124
|
+
'--rdoc --no-force --wrappers'
|
120
125
|
end
|
121
126
|
|
122
127
|
end
|
data/lib/rubygems/installer.rb
CHANGED
@@ -8,6 +8,7 @@ require 'rubygems/format'
|
|
8
8
|
require 'rubygems/exceptions'
|
9
9
|
require 'rubygems/ext'
|
10
10
|
require 'rubygems/require_paths_builder'
|
11
|
+
require 'rubygems/user_interaction'
|
11
12
|
|
12
13
|
##
|
13
14
|
# The installer class processes RubyGem .gem files and installs the files
|
@@ -18,7 +19,7 @@ require 'rubygems/require_paths_builder'
|
|
18
19
|
# gemspec in the specifications dir, storing the cached gem in the cache dir,
|
19
20
|
# and installing either wrappers or symlinks for executables.
|
20
21
|
#
|
21
|
-
# The installer
|
22
|
+
# The installer invokes pre and post install hooks. Hooks can be added either
|
22
23
|
# through a rubygems_plugin.rb file in an installed gem or via a
|
23
24
|
# rubygems/defaults/#{RUBY_ENGINE}.rb or rubygems/defaults/operating_system.rb
|
24
25
|
# file. See Gem.pre_install and Gem.post_install for details.
|
@@ -38,7 +39,7 @@ class Gem::Installer
|
|
38
39
|
|
39
40
|
include Gem::UserInteraction
|
40
41
|
|
41
|
-
include Gem::RequirePathsBuilder
|
42
|
+
include Gem::RequirePathsBuilder if Gem::QUICKLOADER_SUCKAGE
|
42
43
|
|
43
44
|
##
|
44
45
|
# The directory a gem's executables will be installed into
|
@@ -55,6 +56,11 @@ class Gem::Installer
|
|
55
56
|
|
56
57
|
attr_reader :spec
|
57
58
|
|
59
|
+
##
|
60
|
+
# The options passed when the Gem::Installer was instantiated.
|
61
|
+
|
62
|
+
attr_reader :options
|
63
|
+
|
58
64
|
@path_warning = false
|
59
65
|
|
60
66
|
class << self
|
@@ -92,49 +98,16 @@ class Gem::Installer
|
|
92
98
|
require 'fileutils'
|
93
99
|
|
94
100
|
@gem = gem
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
:env_shebang => false,
|
99
|
-
:exec_format => false,
|
100
|
-
:force => false,
|
101
|
-
:install_dir => Gem.dir,
|
102
|
-
:source_index => Gem.source_index,
|
103
|
-
}.merge options
|
104
|
-
|
105
|
-
@env_shebang = options[:env_shebang]
|
106
|
-
@force = options[:force]
|
107
|
-
gem_home = options[:install_dir]
|
108
|
-
@gem_home = File.expand_path(gem_home)
|
109
|
-
@ignore_dependencies = options[:ignore_dependencies]
|
110
|
-
@format_executable = options[:format_executable]
|
111
|
-
@security_policy = options[:security_policy]
|
112
|
-
@wrappers = options[:wrappers]
|
113
|
-
@bin_dir = options[:bin_dir]
|
114
|
-
@development = options[:development]
|
115
|
-
@source_index = options[:source_index]
|
116
|
-
|
117
|
-
begin
|
118
|
-
@format = Gem::Format.from_file_by_path @gem, @security_policy
|
119
|
-
rescue Gem::Package::FormatError
|
120
|
-
raise Gem::InstallError, "invalid gem format for #{@gem}"
|
121
|
-
end
|
101
|
+
@options = options
|
102
|
+
process_options
|
103
|
+
load_gem_file
|
122
104
|
|
123
105
|
if options[:user_install] and not options[:unpack] then
|
124
106
|
@gem_home = Gem.user_dir
|
125
|
-
|
126
|
-
user_bin_dir = File.join(@gem_home, 'bin')
|
127
|
-
unless ENV['PATH'].split(File::PATH_SEPARATOR).include? user_bin_dir then
|
128
|
-
unless self.class.path_warning then
|
129
|
-
alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run."
|
130
|
-
self.class.path_warning = true
|
131
|
-
end
|
132
|
-
end
|
107
|
+
check_that_user_bin_dir_is_in_path
|
133
108
|
end
|
134
109
|
|
135
|
-
|
136
|
-
raise Gem::FilePermissionError, @gem_home unless
|
137
|
-
options[:unpack] or File.writable? @gem_home
|
110
|
+
verify_gem_home(options[:unpack])
|
138
111
|
|
139
112
|
@spec = @format.spec
|
140
113
|
|
@@ -154,51 +127,51 @@ class Gem::Installer
|
|
154
127
|
|
155
128
|
def install
|
156
129
|
# If we're forcing the install then disable security unless the security
|
157
|
-
# policy says that we only install
|
130
|
+
# policy says that we only install signed gems.
|
158
131
|
@security_policy = nil if @force and @security_policy and
|
159
132
|
not @security_policy.only_signed
|
160
133
|
|
161
|
-
unless @force
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
end
|
134
|
+
unless @force
|
135
|
+
ensure_required_ruby_version_met
|
136
|
+
ensure_required_rubygems_version_met
|
137
|
+
ensure_dependencies_met unless @ignore_dependencies
|
138
|
+
end
|
167
139
|
|
168
|
-
|
169
|
-
|
170
|
-
raise Gem::InstallError,
|
171
|
-
"#{@spec.name} requires RubyGems version #{rrgv}. " +
|
172
|
-
"Try 'gem update --system' to update RubyGems itself."
|
173
|
-
end
|
174
|
-
end
|
140
|
+
Gem.pre_install_hooks.each do |hook|
|
141
|
+
result = hook.call self
|
175
142
|
|
176
|
-
|
177
|
-
|
178
|
-
deps |= @spec.development_dependencies if @development
|
143
|
+
if result == false then
|
144
|
+
location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
|
179
145
|
|
180
|
-
|
181
|
-
|
182
|
-
end
|
146
|
+
message = "pre-install hook#{location} failed for #{@spec.full_name}"
|
147
|
+
raise Gem::InstallError, message
|
183
148
|
end
|
184
149
|
end
|
185
150
|
|
186
|
-
Gem.pre_install_hooks.each do |hook|
|
187
|
-
hook.call self
|
188
|
-
end
|
189
|
-
|
190
|
-
FileUtils.mkdir_p @gem_home unless File.directory? @gem_home
|
191
|
-
|
192
151
|
Gem.ensure_gem_subdirectories @gem_home
|
193
152
|
|
194
153
|
FileUtils.mkdir_p @gem_dir
|
195
154
|
|
196
155
|
extract_files
|
197
|
-
generate_bin
|
198
156
|
build_extensions
|
157
|
+
|
158
|
+
Gem.post_build_hooks.each do |hook|
|
159
|
+
result = hook.call self
|
160
|
+
|
161
|
+
if result == false then
|
162
|
+
FileUtils.rm_rf @gem_dir
|
163
|
+
|
164
|
+
location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
|
165
|
+
|
166
|
+
message = "post-build hook#{location} failed for #{@spec.full_name}"
|
167
|
+
raise Gem::InstallError, message
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
generate_bin
|
199
172
|
write_spec
|
200
173
|
|
201
|
-
write_require_paths_file_if_needed
|
174
|
+
write_require_paths_file_if_needed if Gem::QUICKLOADER_SUCKAGE
|
202
175
|
|
203
176
|
# HACK remove? Isn't this done in multiple places?
|
204
177
|
cached_gem = File.join @gem_home, "cache", @gem.split(/\//).pop
|
@@ -232,7 +205,6 @@ class Gem::Installer
|
|
232
205
|
unless installation_satisfies_dependency? dependency then
|
233
206
|
raise Gem::InstallError, "#{spec.name} requires #{dependency}"
|
234
207
|
end
|
235
|
-
|
236
208
|
true
|
237
209
|
end
|
238
210
|
|
@@ -318,24 +290,15 @@ class Gem::Installer
|
|
318
290
|
def generate_bin_script(filename, bindir)
|
319
291
|
bin_script_path = File.join bindir, formatted_program_filename(filename)
|
320
292
|
|
321
|
-
|
322
|
-
|
323
|
-
# HACK some gems don't have #! in their executables, restore 2008/06
|
324
|
-
#if File.read(exec_path, 2) == '#!' then
|
325
|
-
FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
|
293
|
+
FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
|
326
294
|
|
327
|
-
|
328
|
-
|
329
|
-
|
295
|
+
File.open bin_script_path, 'w', 0755 do |file|
|
296
|
+
file.print app_script_text(filename)
|
297
|
+
end
|
330
298
|
|
331
|
-
|
299
|
+
say bin_script_path if Gem.configuration.really_verbose
|
332
300
|
|
333
|
-
|
334
|
-
#else
|
335
|
-
# FileUtils.rm_f bin_script_path
|
336
|
-
# FileUtils.cp exec_path, bin_script_path,
|
337
|
-
# :verbose => Gem.configuration.really_verbose
|
338
|
-
#end
|
301
|
+
generate_windows_script filename, bindir
|
339
302
|
end
|
340
303
|
|
341
304
|
##
|
@@ -391,6 +354,80 @@ class Gem::Installer
|
|
391
354
|
end
|
392
355
|
end
|
393
356
|
|
357
|
+
def ensure_required_ruby_version_met
|
358
|
+
if rrv = @spec.required_ruby_version then
|
359
|
+
unless rrv.satisfied_by? Gem.ruby_version then
|
360
|
+
raise Gem::InstallError, "#{@spec.name} requires Ruby version #{rrv}."
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
def ensure_required_rubygems_version_met
|
366
|
+
if rrgv = @spec.required_rubygems_version then
|
367
|
+
unless rrgv.satisfied_by? Gem::Version.new(Gem::VERSION) then
|
368
|
+
raise Gem::InstallError,
|
369
|
+
"#{@spec.name} requires RubyGems version #{rrgv}. " +
|
370
|
+
"Try 'gem update --system' to update RubyGems itself."
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
def ensure_dependencies_met
|
376
|
+
deps = @spec.runtime_dependencies
|
377
|
+
deps |= @spec.development_dependencies if @development
|
378
|
+
|
379
|
+
deps.each do |dep_gem|
|
380
|
+
ensure_dependency @spec, dep_gem
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
def process_options
|
385
|
+
@options = {
|
386
|
+
:bin_dir => nil,
|
387
|
+
:env_shebang => false,
|
388
|
+
:exec_format => false,
|
389
|
+
:force => false,
|
390
|
+
:install_dir => Gem.dir,
|
391
|
+
:source_index => Gem.source_index,
|
392
|
+
}.merge options
|
393
|
+
|
394
|
+
@env_shebang = options[:env_shebang]
|
395
|
+
@force = options[:force]
|
396
|
+
gem_home = options[:install_dir]
|
397
|
+
@gem_home = File.expand_path(gem_home)
|
398
|
+
@ignore_dependencies = options[:ignore_dependencies]
|
399
|
+
@format_executable = options[:format_executable]
|
400
|
+
@security_policy = options[:security_policy]
|
401
|
+
@wrappers = options[:wrappers]
|
402
|
+
@bin_dir = options[:bin_dir]
|
403
|
+
@development = options[:development]
|
404
|
+
@source_index = options[:source_index]
|
405
|
+
end
|
406
|
+
|
407
|
+
def load_gem_file
|
408
|
+
begin
|
409
|
+
@format = Gem::Format.from_file_by_path @gem, @security_policy
|
410
|
+
rescue Gem::Package::FormatError
|
411
|
+
raise Gem::InstallError, "invalid gem format for #{@gem}"
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
def check_that_user_bin_dir_is_in_path
|
416
|
+
user_bin_dir = File.join(@gem_home, 'bin')
|
417
|
+
unless ENV['PATH'].split(File::PATH_SEPARATOR).include? user_bin_dir then
|
418
|
+
unless self.class.path_warning then
|
419
|
+
alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run."
|
420
|
+
self.class.path_warning = true
|
421
|
+
end
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
def verify_gem_home(unpack = false)
|
426
|
+
FileUtils.mkdir_p @gem_home
|
427
|
+
raise Gem::FilePermissionError, @gem_home unless
|
428
|
+
unpack or File.writable? @gem_home
|
429
|
+
end
|
430
|
+
|
394
431
|
##
|
395
432
|
# Return the text for an application file.
|
396
433
|
|
@@ -439,7 +476,6 @@ TEXT
|
|
439
476
|
def build_extensions
|
440
477
|
return if @spec.extensions.empty?
|
441
478
|
say "Building native extensions. This could take a while..."
|
442
|
-
start_dir = Dir.pwd
|
443
479
|
dest_path = File.join @gem_dir, @spec.require_paths.first
|
444
480
|
ran_rake = false # only run rake once
|
445
481
|
|
@@ -460,29 +496,37 @@ TEXT
|
|
460
496
|
nil
|
461
497
|
end
|
462
498
|
|
463
|
-
begin
|
464
|
-
Dir.chdir File.join(@gem_dir, File.dirname(extension))
|
465
|
-
results = builder.build(extension, @gem_dir, dest_path, results)
|
466
499
|
|
467
|
-
|
500
|
+
extension_dir = begin
|
501
|
+
File.join @gem_dir, File.dirname(extension)
|
502
|
+
rescue TypeError # extension == nil
|
503
|
+
@gem_dir
|
504
|
+
end
|
468
505
|
|
506
|
+
|
507
|
+
begin
|
508
|
+
Dir.chdir extension_dir do
|
509
|
+
results = builder.build(extension, @gem_dir, dest_path, results)
|
510
|
+
|
511
|
+
say results.join("\n") if Gem.configuration.really_verbose
|
512
|
+
end
|
469
513
|
rescue
|
470
514
|
results = results.join "\n"
|
471
515
|
|
472
|
-
File.
|
516
|
+
gem_make_out = File.join extension_dir, 'gem_make.out'
|
517
|
+
|
518
|
+
open gem_make_out, 'wb' do |io| io.puts results end
|
473
519
|
|
474
520
|
message = <<-EOF
|
475
521
|
ERROR: Failed to build gem native extension.
|
476
522
|
|
477
|
-
#{results}
|
523
|
+
#{results}
|
478
524
|
|
479
525
|
Gem files will remain installed in #{@gem_dir} for inspection.
|
480
|
-
Results logged to #{
|
481
|
-
|
526
|
+
Results logged to #{gem_make_out}
|
527
|
+
EOF
|
482
528
|
|
483
529
|
raise ExtensionBuildError, message
|
484
|
-
ensure
|
485
|
-
Dir.chdir start_dir
|
486
530
|
end
|
487
531
|
end
|
488
532
|
end
|