slimgems 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5811 -0
- data/History.txt +887 -0
- data/LICENSE.txt +51 -0
- data/README.md +87 -0
- data/Rakefile +120 -0
- data/bin/gem +25 -0
- data/bin/update_slimgems +35 -0
- data/bootstrap/Rakefile +4 -0
- data/hide_lib_for_update/note.txt +5 -0
- data/lib/gauntlet_rubygems.rb +50 -0
- data/lib/rbconfig/datadir.rb +20 -0
- data/lib/rubygems.rb +1220 -0
- data/lib/rubygems/builder.rb +102 -0
- data/lib/rubygems/command.rb +534 -0
- data/lib/rubygems/command_manager.rb +182 -0
- data/lib/rubygems/commands/build_command.rb +53 -0
- data/lib/rubygems/commands/cert_command.rb +86 -0
- data/lib/rubygems/commands/check_command.rb +80 -0
- data/lib/rubygems/commands/cleanup_command.rb +106 -0
- data/lib/rubygems/commands/contents_command.rb +98 -0
- data/lib/rubygems/commands/dependency_command.rb +195 -0
- data/lib/rubygems/commands/environment_command.rb +132 -0
- data/lib/rubygems/commands/fetch_command.rb +67 -0
- data/lib/rubygems/commands/generate_index_command.rb +133 -0
- data/lib/rubygems/commands/help_command.rb +172 -0
- data/lib/rubygems/commands/install_command.rb +178 -0
- data/lib/rubygems/commands/list_command.rb +35 -0
- data/lib/rubygems/commands/lock_command.rb +110 -0
- data/lib/rubygems/commands/mirror_command.rb +111 -0
- data/lib/rubygems/commands/outdated_command.rb +33 -0
- data/lib/rubygems/commands/owner_command.rb +75 -0
- data/lib/rubygems/commands/pristine_command.rb +93 -0
- data/lib/rubygems/commands/push_command.rb +56 -0
- data/lib/rubygems/commands/query_command.rb +280 -0
- data/lib/rubygems/commands/rdoc_command.rb +91 -0
- data/lib/rubygems/commands/search_command.rb +31 -0
- data/lib/rubygems/commands/server_command.rb +86 -0
- data/lib/rubygems/commands/setup_command.rb +387 -0
- data/lib/rubygems/commands/sources_command.rb +157 -0
- data/lib/rubygems/commands/specification_command.rb +125 -0
- data/lib/rubygems/commands/stale_command.rb +27 -0
- data/lib/rubygems/commands/uninstall_command.rb +83 -0
- data/lib/rubygems/commands/unpack_command.rb +121 -0
- data/lib/rubygems/commands/update_command.rb +212 -0
- data/lib/rubygems/commands/which_command.rb +86 -0
- data/lib/rubygems/config_file.rb +345 -0
- data/lib/rubygems/custom_require.rb +44 -0
- data/lib/rubygems/defaults.rb +101 -0
- data/lib/rubygems/dependency.rb +227 -0
- data/lib/rubygems/dependency_installer.rb +286 -0
- data/lib/rubygems/dependency_list.rb +208 -0
- data/lib/rubygems/doc_manager.rb +242 -0
- data/lib/rubygems/errors.rb +35 -0
- data/lib/rubygems/exceptions.rb +91 -0
- data/lib/rubygems/ext.rb +18 -0
- data/lib/rubygems/ext/builder.rb +56 -0
- data/lib/rubygems/ext/configure_builder.rb +25 -0
- data/lib/rubygems/ext/ext_conf_builder.rb +24 -0
- data/lib/rubygems/ext/rake_builder.rb +39 -0
- data/lib/rubygems/format.rb +81 -0
- data/lib/rubygems/gem_openssl.rb +92 -0
- data/lib/rubygems/gem_path_searcher.rb +100 -0
- data/lib/rubygems/gem_runner.rb +79 -0
- data/lib/rubygems/gemcutter_utilities.rb +49 -0
- data/lib/rubygems/indexer.rb +720 -0
- data/lib/rubygems/install_update_options.rb +125 -0
- data/lib/rubygems/installer.rb +604 -0
- data/lib/rubygems/local_remote_options.rb +135 -0
- data/lib/rubygems/old_format.rb +153 -0
- data/lib/rubygems/package.rb +97 -0
- data/lib/rubygems/package/f_sync_dir.rb +23 -0
- data/lib/rubygems/package/tar_header.rb +266 -0
- data/lib/rubygems/package/tar_input.rb +222 -0
- data/lib/rubygems/package/tar_output.rb +144 -0
- data/lib/rubygems/package/tar_reader.rb +106 -0
- data/lib/rubygems/package/tar_reader/entry.rb +141 -0
- data/lib/rubygems/package/tar_writer.rb +241 -0
- data/lib/rubygems/package_task.rb +126 -0
- data/lib/rubygems/platform.rb +183 -0
- data/lib/rubygems/remote_fetcher.rb +414 -0
- data/lib/rubygems/require_paths_builder.rb +18 -0
- data/lib/rubygems/requirement.rb +153 -0
- data/lib/rubygems/security.rb +814 -0
- data/lib/rubygems/server.rb +872 -0
- data/lib/rubygems/source_index.rb +597 -0
- data/lib/rubygems/source_info_cache.rb +395 -0
- data/lib/rubygems/source_info_cache_entry.rb +56 -0
- data/lib/rubygems/spec_fetcher.rb +337 -0
- data/lib/rubygems/specification.rb +1486 -0
- data/lib/rubygems/test_utilities.rb +147 -0
- data/lib/rubygems/text.rb +65 -0
- data/lib/rubygems/uninstaller.rb +278 -0
- data/lib/rubygems/user_interaction.rb +527 -0
- data/lib/rubygems/validator.rb +240 -0
- data/lib/rubygems/version.rb +316 -0
- data/lib/rubygems/version_option.rb +65 -0
- data/lib/ubygems.rb +10 -0
- data/setup.rb +42 -0
- data/test/bogussources.rb +8 -0
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/fake_certlib/openssl.rb +7 -0
- data/test/foo/discover.rb +0 -0
- data/test/functional.rb +92 -0
- data/test/gem_installer_test_case.rb +97 -0
- data/test/gem_package_tar_test_case.rb +132 -0
- data/test/gemutilities.rb +605 -0
- data/test/insure_session.rb +43 -0
- data/test/mockgemui.rb +56 -0
- data/test/plugin/exception/rubygems_plugin.rb +2 -0
- data/test/plugin/load/rubygems_plugin.rb +1 -0
- data/test/plugin/standarderror/rubygems_plugin.rb +2 -0
- data/test/private_key.pem +27 -0
- data/test/public_cert.pem +20 -0
- data/test/rubygems_plugin.rb +21 -0
- data/test/simple_gem.rb +66 -0
- data/test/test_config.rb +12 -0
- data/test/test_gem.rb +766 -0
- data/test/test_gem_builder.rb +27 -0
- data/test/test_gem_command.rb +178 -0
- data/test/test_gem_command_manager.rb +207 -0
- data/test/test_gem_commands_build_command.rb +74 -0
- data/test/test_gem_commands_cert_command.rb +124 -0
- data/test/test_gem_commands_check_command.rb +18 -0
- data/test/test_gem_commands_contents_command.rb +156 -0
- data/test/test_gem_commands_dependency_command.rb +216 -0
- data/test/test_gem_commands_environment_command.rb +144 -0
- data/test/test_gem_commands_fetch_command.rb +76 -0
- data/test/test_gem_commands_generate_index_command.rb +135 -0
- data/test/test_gem_commands_install_command.rb +315 -0
- data/test/test_gem_commands_list_command.rb +36 -0
- data/test/test_gem_commands_lock_command.rb +68 -0
- data/test/test_gem_commands_mirror_command.rb +60 -0
- data/test/test_gem_commands_outdated_command.rb +40 -0
- data/test/test_gem_commands_owner_command.rb +105 -0
- data/test/test_gem_commands_pristine_command.rb +108 -0
- data/test/test_gem_commands_push_command.rb +81 -0
- data/test/test_gem_commands_query_command.rb +426 -0
- data/test/test_gem_commands_server_command.rb +59 -0
- data/test/test_gem_commands_sources_command.rb +209 -0
- data/test/test_gem_commands_specification_command.rb +139 -0
- data/test/test_gem_commands_stale_command.rb +38 -0
- data/test/test_gem_commands_uninstall_command.rb +83 -0
- data/test/test_gem_commands_unpack_command.rb +199 -0
- data/test/test_gem_commands_update_command.rb +353 -0
- data/test/test_gem_commands_which_command.rb +66 -0
- data/test/test_gem_config_file.rb +287 -0
- data/test/test_gem_dependency.rb +149 -0
- data/test/test_gem_dependency_installer.rb +661 -0
- data/test/test_gem_dependency_list.rb +230 -0
- data/test/test_gem_doc_manager.rb +31 -0
- data/test/test_gem_ext_configure_builder.rb +84 -0
- data/test/test_gem_ext_ext_conf_builder.rb +173 -0
- data/test/test_gem_ext_rake_builder.rb +81 -0
- data/test/test_gem_format.rb +70 -0
- data/test/test_gem_gem_path_searcher.rb +78 -0
- data/test/test_gem_gem_runner.rb +45 -0
- data/test/test_gem_gemcutter_utilities.rb +103 -0
- data/test/test_gem_indexer.rb +673 -0
- data/test/test_gem_install_update_options.rb +68 -0
- data/test/test_gem_installer.rb +857 -0
- data/test/test_gem_local_remote_options.rb +97 -0
- data/test/test_gem_package_tar_header.rb +130 -0
- data/test/test_gem_package_tar_input.rb +112 -0
- data/test/test_gem_package_tar_output.rb +97 -0
- data/test/test_gem_package_tar_reader.rb +46 -0
- data/test/test_gem_package_tar_reader_entry.rb +109 -0
- data/test/test_gem_package_tar_writer.rb +144 -0
- data/test/test_gem_package_task.rb +59 -0
- data/test/test_gem_platform.rb +264 -0
- data/test/test_gem_remote_fetcher.rb +740 -0
- data/test/test_gem_requirement.rb +292 -0
- data/test/test_gem_server.rb +356 -0
- data/test/test_gem_silent_ui.rb +113 -0
- data/test/test_gem_source_index.rb +461 -0
- data/test/test_gem_spec_fetcher.rb +410 -0
- data/test/test_gem_specification.rb +1291 -0
- data/test/test_gem_stream_ui.rb +218 -0
- data/test/test_gem_text.rb +43 -0
- data/test/test_gem_uninstaller.rb +146 -0
- data/test/test_gem_validator.rb +63 -0
- data/test/test_gem_version.rb +181 -0
- data/test/test_gem_version_option.rb +89 -0
- data/test/test_kernel.rb +59 -0
- metadata +413 -0
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/server'
|
3
|
+
|
4
|
+
class Gem::Commands::ServerCommand < Gem::Command
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super 'server', 'Documentation and gem repository HTTP server',
|
8
|
+
:port => 8808, :gemdir => [], :daemon => false
|
9
|
+
|
10
|
+
OptionParser.accept :Port do |port|
|
11
|
+
if port =~ /\A\d+\z/ then
|
12
|
+
port = Integer port
|
13
|
+
raise OptionParser::InvalidArgument, "#{port}: not a port number" if
|
14
|
+
port > 65535
|
15
|
+
|
16
|
+
port
|
17
|
+
else
|
18
|
+
begin
|
19
|
+
Socket.getservbyname port
|
20
|
+
rescue SocketError
|
21
|
+
raise OptionParser::InvalidArgument, "#{port}: no such named service"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
add_option '-p', '--port=PORT', :Port,
|
27
|
+
'port to listen on' do |port, options|
|
28
|
+
options[:port] = port
|
29
|
+
end
|
30
|
+
|
31
|
+
add_option '-d', '--dir=GEMDIR',
|
32
|
+
'directories from which to serve gems',
|
33
|
+
'multiple directories may be provided' do |gemdir, options|
|
34
|
+
options[:gemdir] << File.expand_path(gemdir)
|
35
|
+
end
|
36
|
+
|
37
|
+
add_option '--[no-]daemon', 'run as a daemon' do |daemon, options|
|
38
|
+
options[:daemon] = daemon
|
39
|
+
end
|
40
|
+
|
41
|
+
add_option '-b', '--bind=HOST,HOST',
|
42
|
+
'addresses to bind', Array do |address, options|
|
43
|
+
options[:addresses] ||= []
|
44
|
+
options[:addresses].push(*address)
|
45
|
+
end
|
46
|
+
|
47
|
+
add_option '-l', '--launch[=COMMAND]',
|
48
|
+
'launches a browser window',
|
49
|
+
"COMMAND defaults to 'start' on Windows",
|
50
|
+
"and 'open' on all other platforms" do |launch, options|
|
51
|
+
launch ||= Gem.win_platform? ? 'start' : 'open'
|
52
|
+
options[:launch] = launch
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def defaults_str # :nodoc:
|
57
|
+
"--port 8808 --dir #{Gem.dir} --no-daemon"
|
58
|
+
end
|
59
|
+
|
60
|
+
def description # :nodoc:
|
61
|
+
<<-EOF
|
62
|
+
The server command starts up a web server that hosts the RDoc for your
|
63
|
+
installed gems and can operate as a server for installation of gems on other
|
64
|
+
machines.
|
65
|
+
|
66
|
+
The cache files for installed gems must exist to use the server as a source
|
67
|
+
for gem installation.
|
68
|
+
|
69
|
+
To install gems from a running server, use `gem install GEMNAME --source
|
70
|
+
http://gem_server_host:8808`
|
71
|
+
|
72
|
+
You can set up a shortcut to gem server documentation using the URL:
|
73
|
+
|
74
|
+
http://localhost:8808/rdoc?q=%s - Firefox
|
75
|
+
http://localhost:8808/rdoc?q=* - LaunchBar
|
76
|
+
|
77
|
+
EOF
|
78
|
+
end
|
79
|
+
|
80
|
+
def execute
|
81
|
+
options[:gemdir] << Gem.dir if options[:gemdir].empty?
|
82
|
+
Gem::Server.run options
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
@@ -0,0 +1,387 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'rbconfig'
|
4
|
+
require 'tmpdir'
|
5
|
+
|
6
|
+
##
|
7
|
+
# Installs SlimGems itself. This command is ordinarily only available from a
|
8
|
+
# SlimGems checkout or tarball.
|
9
|
+
|
10
|
+
class Gem::Commands::SetupCommand < Gem::Command
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super 'setup', "Install #{Gem::NAME}",
|
14
|
+
:format_executable => true, :rdoc => true, :ri => true,
|
15
|
+
:site_or_vendor => :sitelibdir,
|
16
|
+
:destdir => '', :prefix => ''
|
17
|
+
|
18
|
+
add_option '--prefix=PREFIX',
|
19
|
+
"Prefix path for installing #{Gem::NAME}",
|
20
|
+
'Will not affect gem repository location' do |prefix, options|
|
21
|
+
options[:prefix] = File.expand_path prefix
|
22
|
+
end
|
23
|
+
|
24
|
+
add_option '--destdir=DESTDIR',
|
25
|
+
"Root directory to install #{Gem::NAME} into",
|
26
|
+
"Mainly used for packaging #{Gem::NAME}" do |destdir, options|
|
27
|
+
options[:destdir] = File.expand_path destdir
|
28
|
+
end
|
29
|
+
|
30
|
+
add_option '--[no-]vendor',
|
31
|
+
'Install into vendorlibdir not sitelibdir',
|
32
|
+
'(Requires Ruby 1.8.7)' do |vendor, options|
|
33
|
+
if vendor and Gem.ruby_version < Gem::Version.new('1.8.7') then
|
34
|
+
raise OptionParser::InvalidOption,
|
35
|
+
"requires ruby 1.8.7+ (you have #{Gem.ruby_version})"
|
36
|
+
end
|
37
|
+
|
38
|
+
options[:site_or_vendor] = vendor ? :vendorlibdir : :sitelibdir
|
39
|
+
end
|
40
|
+
|
41
|
+
add_option '--[no-]format-executable',
|
42
|
+
'Makes `gem` match ruby',
|
43
|
+
'If ruby is ruby18, gem will be gem18' do |value, options|
|
44
|
+
options[:format_executable] = value
|
45
|
+
end
|
46
|
+
|
47
|
+
add_option '--[no-]rdoc',
|
48
|
+
"Generate RDoc documentation for #{Gem::NAME}" do |value, options|
|
49
|
+
options[:rdoc] = value
|
50
|
+
end
|
51
|
+
|
52
|
+
add_option '--[no-]ri',
|
53
|
+
"Generate RI documentation for #{Gem::NAME}" do |value, options|
|
54
|
+
options[:ri] = value
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def check_ruby_version
|
59
|
+
required_version = Gem::Requirement.new '>= 1.8.6'
|
60
|
+
|
61
|
+
unless required_version.satisfied_by? Gem.ruby_version then
|
62
|
+
alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"
|
63
|
+
terminate_interaction 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def defaults_str # :nodoc:
|
68
|
+
"--format-executable --rdoc --ri"
|
69
|
+
end
|
70
|
+
|
71
|
+
def description # :nodoc:
|
72
|
+
<<-EOF
|
73
|
+
Installs #{Gem::NAME} itself.
|
74
|
+
|
75
|
+
#{Gem::NAME} installs RDoc for itself in GEM_HOME. By default this is:
|
76
|
+
#{Gem.dir}
|
77
|
+
|
78
|
+
If you prefer a different directory, set the GEM_HOME environment variable.
|
79
|
+
|
80
|
+
#{Gem::NAME} will install the gem command with a name matching ruby's
|
81
|
+
prefix and suffix. If ruby was installed as `ruby18`, gem will be
|
82
|
+
installed as `gem18`.
|
83
|
+
|
84
|
+
By default, this #{Gem::NAME} will install gem as:
|
85
|
+
#{Gem.default_exec_format % 'gem'}
|
86
|
+
EOF
|
87
|
+
end
|
88
|
+
|
89
|
+
def execute
|
90
|
+
@verbose = Gem.configuration.really_verbose
|
91
|
+
|
92
|
+
install_destdir = options[:destdir]
|
93
|
+
|
94
|
+
unless install_destdir.empty? then
|
95
|
+
ENV['GEM_HOME'] ||= File.join(install_destdir,
|
96
|
+
Gem.default_dir.gsub(/^[a-zA-Z]:/, ''))
|
97
|
+
end
|
98
|
+
|
99
|
+
check_ruby_version
|
100
|
+
|
101
|
+
if Gem.configuration.really_verbose then
|
102
|
+
extend FileUtils::Verbose
|
103
|
+
else
|
104
|
+
extend FileUtils
|
105
|
+
end
|
106
|
+
|
107
|
+
lib_dir, bin_dir = make_destination_dirs install_destdir
|
108
|
+
|
109
|
+
backup_lib lib_dir
|
110
|
+
|
111
|
+
install_lib lib_dir
|
112
|
+
|
113
|
+
install_executables bin_dir
|
114
|
+
|
115
|
+
remove_old_bin_files bin_dir
|
116
|
+
|
117
|
+
remove_source_caches install_destdir
|
118
|
+
|
119
|
+
say "#{Gem::NAME} #{Gem::VERSION} installed"
|
120
|
+
|
121
|
+
uninstall_old_gemcutter
|
122
|
+
|
123
|
+
uninstall_old_rubygems
|
124
|
+
|
125
|
+
install_rdoc
|
126
|
+
|
127
|
+
say
|
128
|
+
if @verbose then
|
129
|
+
say "-" * 78
|
130
|
+
say
|
131
|
+
end
|
132
|
+
|
133
|
+
release_notes = File.join Dir.pwd, 'History.txt'
|
134
|
+
|
135
|
+
release_notes = if File.exist? release_notes then
|
136
|
+
open release_notes do |io|
|
137
|
+
text = io.gets '==='
|
138
|
+
text << io.gets('===')
|
139
|
+
text[0...-3]
|
140
|
+
end
|
141
|
+
else
|
142
|
+
"Oh-no! Unable to find release notes!"
|
143
|
+
end
|
144
|
+
|
145
|
+
say release_notes
|
146
|
+
|
147
|
+
say
|
148
|
+
say "-" * 78
|
149
|
+
say
|
150
|
+
|
151
|
+
say "#{Gem::NAME} installed the following executables:"
|
152
|
+
say @bin_file_names.map { |name| "\t#{name}\n" }
|
153
|
+
say
|
154
|
+
|
155
|
+
unless @bin_file_names.grep(/#{File::SEPARATOR}gem$/) then
|
156
|
+
say "If `gem` was installed by a previous #{Gem::NAME} installation, you may need"
|
157
|
+
say "to remove it by hand."
|
158
|
+
say
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def install_executables(bin_dir)
|
163
|
+
say "Installing gem executable" if @verbose
|
164
|
+
|
165
|
+
@bin_file_names = []
|
166
|
+
|
167
|
+
Dir.chdir 'bin' do
|
168
|
+
bin_files = Dir['*']
|
169
|
+
|
170
|
+
bin_files.delete "update_#{Gem::GEM_NAME}"
|
171
|
+
|
172
|
+
bin_files.each do |bin_file|
|
173
|
+
bin_file_formatted = if options[:format_executable] then
|
174
|
+
Gem.default_exec_format % bin_file
|
175
|
+
else
|
176
|
+
bin_file
|
177
|
+
end
|
178
|
+
|
179
|
+
dest_file = File.join bin_dir, bin_file_formatted
|
180
|
+
bin_tmp_file = File.join Dir.tmpdir, bin_file
|
181
|
+
|
182
|
+
begin
|
183
|
+
bin = File.readlines bin_file
|
184
|
+
bin[0] = "#!#{Gem.ruby}\n"
|
185
|
+
|
186
|
+
File.open bin_tmp_file, 'w' do |fp|
|
187
|
+
fp.puts bin.join
|
188
|
+
end
|
189
|
+
|
190
|
+
install bin_tmp_file, dest_file, :mode => 0755
|
191
|
+
@bin_file_names << dest_file
|
192
|
+
ensure
|
193
|
+
rm bin_tmp_file
|
194
|
+
end
|
195
|
+
|
196
|
+
next unless Gem.win_platform?
|
197
|
+
|
198
|
+
begin
|
199
|
+
bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat"
|
200
|
+
|
201
|
+
File.open bin_cmd_file, 'w' do |file|
|
202
|
+
file.puts <<-TEXT
|
203
|
+
@ECHO OFF
|
204
|
+
IF NOT "%~f0" == "~f0" GOTO :WinNT
|
205
|
+
@"#{File.basename(Gem.ruby).chomp('"')}" "#{dest_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
206
|
+
GOTO :EOF
|
207
|
+
:WinNT
|
208
|
+
@"#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %*
|
209
|
+
TEXT
|
210
|
+
end
|
211
|
+
|
212
|
+
install bin_cmd_file, "#{dest_file}.bat", :mode => 0755
|
213
|
+
ensure
|
214
|
+
rm bin_cmd_file
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def backup_lib(lib_dir)
|
221
|
+
return unless ENV['GEM_BOOTSTRAP']
|
222
|
+
backup_dir = File.join(lib_dir, 'rubygems-backup')
|
223
|
+
rm_rf(backup_dir) if File.directory?(backup_dir)
|
224
|
+
mkdir_p(backup_dir)
|
225
|
+
list = %w(rubygems rubygems.rb ubygems.rb gauntlet_rubygems.rb).map do |f|
|
226
|
+
File.join(lib_dir, f)
|
227
|
+
end
|
228
|
+
mv(list, backup_dir)
|
229
|
+
end
|
230
|
+
|
231
|
+
def install_lib(lib_dir)
|
232
|
+
say "Installing #{Gem::NAME}" if @verbose
|
233
|
+
|
234
|
+
Dir.chdir 'lib' do
|
235
|
+
lib_files = Dir[File.join('**', '*rb')]
|
236
|
+
|
237
|
+
lib_files.each do |lib_file|
|
238
|
+
dest_file = File.join lib_dir, lib_file
|
239
|
+
dest_dir = File.dirname dest_file
|
240
|
+
mkdir_p dest_dir unless File.directory? dest_dir
|
241
|
+
|
242
|
+
install lib_file, dest_file, :mode => 0644
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
def install_rdoc
|
248
|
+
gem_doc_dir = File.join Gem.dir, 'doc'
|
249
|
+
rubygems_name = "#{Gem::GEM_NAME}-#{Gem::VERSION}"
|
250
|
+
rubygems_doc_dir = File.join gem_doc_dir, rubygems_name
|
251
|
+
|
252
|
+
if File.writable? gem_doc_dir and
|
253
|
+
(not File.exist? rubygems_doc_dir or
|
254
|
+
File.writable? rubygems_doc_dir) then
|
255
|
+
say "Removing old #{Gem::NAME} RDoc and ri" if @verbose
|
256
|
+
Dir[File.join(Gem.dir, 'doc', "#{Gem::GEM_NAME}-[0-9]*")].each do |dir|
|
257
|
+
rm_rf dir
|
258
|
+
end
|
259
|
+
Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir|
|
260
|
+
rm_rf dir
|
261
|
+
end
|
262
|
+
|
263
|
+
if options[:ri] then
|
264
|
+
ri_dir = File.join rubygems_doc_dir, 'ri'
|
265
|
+
say "Installing #{rubygems_name} ri into #{ri_dir}" if @verbose
|
266
|
+
run_rdoc '--ri', '--op', ri_dir
|
267
|
+
end
|
268
|
+
|
269
|
+
if options[:rdoc] then
|
270
|
+
rdoc_dir = File.join rubygems_doc_dir, 'rdoc'
|
271
|
+
say "Installing #{rubygems_name} rdoc into #{rdoc_dir}" if @verbose
|
272
|
+
run_rdoc '--op', rdoc_dir
|
273
|
+
end
|
274
|
+
elsif @verbose then
|
275
|
+
say "Skipping RDoc generation, #{gem_doc_dir} not writable"
|
276
|
+
say "Set the GEM_HOME environment variable if you want RDoc generated"
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def make_destination_dirs(install_destdir)
|
281
|
+
lib_dir = nil
|
282
|
+
bin_dir = nil
|
283
|
+
|
284
|
+
prefix = options[:prefix]
|
285
|
+
site_or_vendor = options[:site_or_vendor]
|
286
|
+
|
287
|
+
if prefix.empty? then
|
288
|
+
lib_dir = Gem::ConfigMap[site_or_vendor]
|
289
|
+
bin_dir = Gem::ConfigMap[:bindir]
|
290
|
+
else
|
291
|
+
# Apple installed this lib into libdir, and version <= 1.1.0 gets
|
292
|
+
# confused about installation location, so switch back to
|
293
|
+
# sitelibdir/vendorlibdir.
|
294
|
+
if defined?(APPLE_GEM_HOME) and
|
295
|
+
# just in case us and Apple don't get this patched up proper.
|
296
|
+
(prefix == Gem::ConfigMap[:libdir] or
|
297
|
+
# this one is important
|
298
|
+
prefix == File.join(Gem::ConfigMap[:libdir], 'ruby')) then
|
299
|
+
lib_dir = Gem::ConfigMap[site_or_vendor]
|
300
|
+
bin_dir = Gem::ConfigMap[:bindir]
|
301
|
+
else
|
302
|
+
lib_dir = File.join prefix, 'lib'
|
303
|
+
bin_dir = File.join prefix, 'bin'
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
unless install_destdir.empty? then
|
308
|
+
lib_dir = File.join install_destdir, lib_dir.gsub(/^[a-zA-Z]:/, '')
|
309
|
+
bin_dir = File.join install_destdir, bin_dir.gsub(/^[a-zA-Z]:/, '')
|
310
|
+
end
|
311
|
+
|
312
|
+
mkdir_p lib_dir
|
313
|
+
mkdir_p bin_dir
|
314
|
+
|
315
|
+
return lib_dir, bin_dir
|
316
|
+
end
|
317
|
+
|
318
|
+
def remove_old_bin_files(bin_dir)
|
319
|
+
old_bin_files = {
|
320
|
+
'gem_mirror' => 'gem mirror',
|
321
|
+
'gem_server' => 'gem server',
|
322
|
+
'gemlock' => 'gem lock',
|
323
|
+
'gemri' => 'ri',
|
324
|
+
'gemwhich' => 'gem which',
|
325
|
+
'index_gem_repository.rb' => 'gem generate_index',
|
326
|
+
}
|
327
|
+
|
328
|
+
old_bin_files.each do |old_bin_file, new_name|
|
329
|
+
old_bin_path = File.join bin_dir, old_bin_file
|
330
|
+
next unless File.exist? old_bin_path
|
331
|
+
|
332
|
+
deprecation_message = "`#{old_bin_file}` has been deprecated. Use `#{new_name}` instead."
|
333
|
+
|
334
|
+
File.open old_bin_path, 'w' do |fp|
|
335
|
+
fp.write <<-EOF
|
336
|
+
#!#{Gem.ruby}
|
337
|
+
|
338
|
+
abort "#{deprecation_message}"
|
339
|
+
EOF
|
340
|
+
end
|
341
|
+
|
342
|
+
next unless Gem.win_platform?
|
343
|
+
|
344
|
+
File.open "#{old_bin_path}.bat", 'w' do |fp|
|
345
|
+
fp.puts %{@ECHO.#{deprecation_message}}
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
def remove_source_caches(install_destdir)
|
351
|
+
if install_destdir.empty?
|
352
|
+
require 'rubygems/source_info_cache'
|
353
|
+
|
354
|
+
user_cache_file = File.join(install_destdir,
|
355
|
+
Gem::SourceInfoCache.user_cache_file)
|
356
|
+
system_cache_file = File.join(install_destdir,
|
357
|
+
Gem::SourceInfoCache.system_cache_file)
|
358
|
+
|
359
|
+
say "Removing old source_cache files" if Gem.configuration.really_verbose
|
360
|
+
rm_f user_cache_file if File.writable? File.dirname(user_cache_file)
|
361
|
+
rm_f system_cache_file if File.writable? File.dirname(system_cache_file)
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
def run_rdoc(*args)
|
366
|
+
# don't need to do this
|
367
|
+
end
|
368
|
+
|
369
|
+
def uninstall_old_gemcutter
|
370
|
+
require 'rubygems/uninstaller'
|
371
|
+
|
372
|
+
ui = Gem::Uninstaller.new('gemcutter', :all => true, :ignore => true,
|
373
|
+
:version => '< 0.4')
|
374
|
+
ui.uninstall
|
375
|
+
rescue Gem::InstallError
|
376
|
+
end
|
377
|
+
|
378
|
+
def uninstall_old_rubygems
|
379
|
+
require 'rubygems/uninstaller'
|
380
|
+
|
381
|
+
ui = Gem::Uninstaller.new('rubygems-update', :all => true, :ignore => true,
|
382
|
+
:executables => true)
|
383
|
+
ui.uninstall
|
384
|
+
rescue Gem::InstallError
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|