rubygems-update 1.3.1 → 1.3.2
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 +24 -0
- data/.document +4 -3
- data/ChangeLog +382 -1
- data/Manifest.txt +214 -0
- data/README +1 -49
- data/Rakefile +124 -191
- data/bin/gem +1 -4
- data/cruise_config.rb +22 -0
- data/doc/release_notes/rel_1_3_1.rdoc +3 -3
- data/doc/release_notes/rel_1_3_2.rdoc +119 -0
- data/lib/gauntlet_rubygems.rb +50 -0
- data/lib/rubygems.rb +250 -25
- data/lib/rubygems/builder.rb +62 -60
- data/lib/rubygems/command.rb +421 -319
- data/lib/rubygems/command_manager.rb +153 -125
- data/lib/rubygems/commands/check_command.rb +12 -7
- data/lib/rubygems/commands/cleanup_command.rb +11 -2
- data/lib/rubygems/commands/contents_command.rb +42 -18
- data/lib/rubygems/commands/generate_index_command.rb +91 -15
- data/lib/rubygems/commands/install_command.rb +33 -47
- data/lib/rubygems/commands/query_command.rb +36 -20
- data/lib/rubygems/commands/rdoc_command.rb +62 -68
- data/lib/rubygems/commands/search_command.rb +26 -32
- data/lib/rubygems/commands/setup_command.rb +353 -0
- data/lib/rubygems/commands/sources_command.rb +5 -0
- data/lib/rubygems/commands/specification_command.rb +23 -3
- data/lib/rubygems/commands/uninstall_command.rb +71 -61
- data/lib/rubygems/commands/unpack_command.rb +14 -12
- data/lib/rubygems/commands/update_command.rb +26 -5
- data/lib/rubygems/defaults.rb +16 -3
- data/lib/rubygems/dependency.rb +38 -7
- data/lib/rubygems/dependency_installer.rb +7 -4
- data/lib/rubygems/digest/digest_adapter.rb +42 -33
- data/lib/rubygems/digest/sha1.rb +6 -1
- data/lib/rubygems/digest/sha2.rb +5 -0
- data/lib/rubygems/doc_manager.rb +31 -11
- data/lib/rubygems/ext/ext_conf_builder.rb +2 -1
- data/lib/rubygems/ext/rake_builder.rb +6 -2
- data/lib/rubygems/format.rb +63 -63
- data/lib/rubygems/gem_openssl.rb +14 -2
- data/lib/rubygems/gem_path_searcher.rb +7 -3
- data/lib/rubygems/gem_runner.rb +59 -39
- data/lib/rubygems/indexer.rb +450 -109
- data/lib/rubygems/install_update_options.rb +13 -1
- data/lib/rubygems/installer.rb +25 -22
- data/lib/rubygems/local_remote_options.rb +5 -3
- data/lib/rubygems/old_format.rb +124 -120
- data/lib/rubygems/package/tar_header.rb +25 -3
- data/lib/rubygems/package/tar_input.rb +5 -5
- data/lib/rubygems/package/tar_output.rb +2 -0
- data/lib/rubygems/package/tar_reader.rb +19 -0
- data/lib/rubygems/package/tar_reader/entry.rb +43 -0
- data/lib/rubygems/package/tar_writer.rb +65 -3
- data/lib/rubygems/package_task.rb +117 -0
- data/lib/rubygems/platform.rb +12 -8
- data/lib/rubygems/remote_fetcher.rb +43 -24
- data/lib/rubygems/require_paths_builder.rb +14 -12
- data/lib/rubygems/requirement.rb +15 -6
- data/lib/rubygems/rubygems_version.rb +14 -1
- data/lib/rubygems/source_index.rb +38 -16
- data/lib/rubygems/source_info_cache_entry.rb +2 -2
- data/lib/rubygems/spec_fetcher.rb +43 -20
- data/lib/rubygems/specification.rb +1122 -947
- data/lib/rubygems/text.rb +30 -0
- data/lib/rubygems/timer.rb +14 -11
- data/lib/rubygems/uninstaller.rb +25 -5
- data/lib/rubygems/user_interaction.rb +294 -264
- data/lib/rubygems/validator.rb +70 -36
- data/lib/rubygems/version.rb +97 -33
- data/lib/rubygems/version_option.rb +1 -0
- data/setup.rb +11 -306
- data/test/foo/discover.rb +0 -0
- data/test/gem_installer_test_case.rb +22 -11
- data/test/gem_package_tar_test_case.rb +0 -14
- data/test/gemutilities.rb +89 -8
- data/test/mockgemui.rb +2 -1
- data/test/rubygems_plugin.rb +16 -0
- data/test/test_gem.rb +107 -36
- data/test/test_gem_command.rb +3 -13
- data/test/test_gem_command_manager.rb +1 -14
- data/test/test_gem_commands_cert_command.rb +1 -1
- data/test/test_gem_commands_contents_command.rb +63 -0
- data/test/test_gem_commands_environment_command.rb +1 -1
- data/test/test_gem_commands_generate_index_command.rb +104 -1
- data/test/test_gem_commands_install_command.rb +95 -0
- data/test/test_gem_commands_pristine_command.rb +3 -3
- data/test/test_gem_commands_query_command.rb +46 -0
- data/test/test_gem_commands_sources_command.rb +9 -5
- data/test/test_gem_commands_specification_command.rb +31 -0
- data/test/test_gem_commands_uninstall_command.rb +3 -2
- data/test/test_gem_commands_unpack_command.rb +3 -2
- data/test/test_gem_commands_update_command.rb +12 -7
- data/test/test_gem_dependency.rb +62 -11
- data/test/test_gem_dependency_installer.rb +18 -5
- data/test/test_gem_dependency_list.rb +6 -6
- data/test/test_gem_doc_manager.rb +7 -1
- data/test/test_gem_ext_configure_builder.rb +8 -10
- data/test/test_gem_ext_ext_conf_builder.rb +14 -8
- data/test/test_gem_gem_path_searcher.rb +1 -1
- data/test/test_gem_gem_runner.rb +11 -0
- data/test/test_gem_indexer.rb +398 -21
- data/test/test_gem_install_update_options.rb +20 -6
- data/test/test_gem_installer.rb +22 -14
- data/test/test_gem_local_remote_options.rb +2 -1
- data/test/test_gem_package_tar_header.rb +3 -3
- data/test/test_gem_package_tar_input.rb +3 -3
- data/test/test_gem_package_tar_output.rb +2 -2
- data/test/test_gem_package_task.rb +70 -0
- data/test/test_gem_platform.rb +12 -6
- data/test/test_gem_remote_fetcher.rb +23 -1
- data/test/test_gem_source_index.rb +32 -21
- data/test/test_gem_spec_fetcher.rb +77 -5
- data/test/test_gem_specification.rb +274 -1
- data/test/test_gem_uninstaller.rb +34 -4
- data/test/test_gem_version.rb +94 -4
- data/test/test_gem_version_option.rb +13 -0
- data/test/test_kernel.rb +4 -4
- data/util/CL2notes +56 -0
- data/util/gem_prelude.rb.template +251 -0
- metadata +30 -20
- metadata.gz.sig +3 -4
- data/TODO +0 -1
- data/scripts/buildtests.rb +0 -31
- data/scripts/gemdoc.rb +0 -67
- data/scripts/runtest.rb +0 -40
- data/scripts/specdoc.rb +0 -171
- data/scripts/upload_gemdoc.rb +0 -140
data/lib/rubygems/validator.rb
CHANGED
@@ -10,6 +10,13 @@ require 'rubygems/digest/md5'
|
|
10
10
|
require 'rubygems/format'
|
11
11
|
require 'rubygems/installer'
|
12
12
|
|
13
|
+
# Load test-unit 2.x if it's a gem
|
14
|
+
begin
|
15
|
+
Gem.activate('test-unit')
|
16
|
+
rescue Gem::LoadError
|
17
|
+
# Ignore - use the test-unit library that's part of the standard library
|
18
|
+
end
|
19
|
+
|
13
20
|
##
|
14
21
|
# Validator performs various gem file and gem database validation
|
15
22
|
|
@@ -48,7 +55,7 @@ class Gem::Validator
|
|
48
55
|
gem_data = file.read
|
49
56
|
verify_gem gem_data
|
50
57
|
end
|
51
|
-
rescue Errno::ENOENT
|
58
|
+
rescue Errno::ENOENT, Errno::EINVAL
|
52
59
|
raise Gem::VerificationError, "missing gem file #{gem_path}"
|
53
60
|
end
|
54
61
|
|
@@ -56,13 +63,11 @@ class Gem::Validator
|
|
56
63
|
|
57
64
|
def find_files_for_gem(gem_directory)
|
58
65
|
installed_files = []
|
59
|
-
Find.find
|
60
|
-
fn = file_name
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}
|
66
|
+
Find.find gem_directory do |file_name|
|
67
|
+
fn = file_name[gem_directory.size..file_name.size-1].sub(/^\//, "")
|
68
|
+
installed_files << fn unless
|
69
|
+
fn =~ /CVS/ || fn.empty? || File.directory?(file_name)
|
70
|
+
end
|
66
71
|
installed_files
|
67
72
|
end
|
68
73
|
|
@@ -81,53 +86,82 @@ class Gem::Validator
|
|
81
86
|
#
|
82
87
|
# returns a hash of ErrorData objects, keyed on the problem gem's name.
|
83
88
|
|
84
|
-
def alien
|
85
|
-
errors = {}
|
89
|
+
def alien(gems=[])
|
90
|
+
errors = Hash.new { |h,k| h[k] = {} }
|
86
91
|
|
87
92
|
Gem::SourceIndex.from_installed_gems.each do |gem_name, gem_spec|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
93
|
+
next unless gems.include? gem_spec.name unless gems.empty?
|
94
|
+
|
95
|
+
install_dir = gem_spec.installation_path
|
96
|
+
gem_path = File.join(install_dir, "cache", gem_spec.full_name) + ".gem"
|
97
|
+
spec_path = File.join(install_dir, "specifications",
|
98
|
+
gem_spec.full_name) + ".gemspec"
|
99
|
+
gem_directory = gem_spec.full_gem_path
|
100
|
+
|
101
|
+
unless File.directory? gem_directory then
|
102
|
+
errors[gem_name][gem_spec.full_name] =
|
103
|
+
"Gem registered but doesn't exist at #{gem_directory}"
|
104
|
+
next
|
105
|
+
end
|
95
106
|
|
96
107
|
unless File.exist? spec_path then
|
97
|
-
errors[gem_name]
|
108
|
+
errors[gem_name][spec_path] = "Spec file missing for installed gem"
|
98
109
|
end
|
99
110
|
|
100
111
|
begin
|
101
112
|
verify_gem_file(gem_path)
|
102
113
|
|
114
|
+
good, gone, unreadable = nil, nil, nil, nil
|
115
|
+
|
103
116
|
open gem_path, Gem.binary_mode do |file|
|
104
117
|
format = Gem::Format.from_file_by_path(gem_path)
|
105
|
-
format.file_entries.each do |entry, data|
|
106
|
-
# Found this file. Delete it from list
|
107
|
-
installed_files.delete remove_leading_dot_dir(entry['path'])
|
108
118
|
|
109
|
-
|
119
|
+
good, gone = format.file_entries.partition { |entry, _|
|
120
|
+
File.exist? File.join(gem_directory, entry['path'])
|
121
|
+
}
|
122
|
+
|
123
|
+
gone.map! { |entry, _| entry['path'] }
|
124
|
+
gone.sort.each do |path|
|
125
|
+
errors[gem_name][path] = "Missing file"
|
126
|
+
end
|
110
127
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
128
|
+
good, unreadable = good.partition { |entry, _|
|
129
|
+
File.readable? File.join(gem_directory, entry['path'])
|
130
|
+
}
|
131
|
+
|
132
|
+
unreadable.map! { |entry, _| entry['path'] }
|
133
|
+
unreadable.sort.each do |path|
|
134
|
+
errors[gem_name][path] = "Unreadable file"
|
135
|
+
end
|
136
|
+
|
137
|
+
good.each do |entry, data|
|
138
|
+
begin
|
139
|
+
next unless data # HACK `gem check -a mkrf`
|
140
|
+
|
141
|
+
open File.join(gem_directory, entry['path']), Gem.binary_mode do |f|
|
142
|
+
unless Gem::MD5.hexdigest(f.read).to_s ==
|
143
|
+
Gem::MD5.hexdigest(data).to_s then
|
144
|
+
errors[gem_name][entry['path']] = "Modified from original"
|
145
|
+
end
|
115
146
|
end
|
116
147
|
end
|
117
148
|
end
|
118
149
|
end
|
150
|
+
|
151
|
+
installed_files = find_files_for_gem(gem_directory)
|
152
|
+
good.map! { |entry, _| entry['path'] }
|
153
|
+
extras = installed_files - good - unreadable
|
154
|
+
|
155
|
+
extras.each do |extra|
|
156
|
+
errors[gem_name][extra] = "Extra file"
|
157
|
+
end
|
119
158
|
rescue Gem::VerificationError => e
|
120
|
-
errors[gem_name]
|
159
|
+
errors[gem_name][gem_path] = e.message
|
121
160
|
end
|
161
|
+
end
|
122
162
|
|
123
|
-
|
124
|
-
|
125
|
-
installed_files.delete_if {|potential_directory|
|
126
|
-
File.directory?(File.join(gem_directory, potential_directory))
|
127
|
-
}
|
128
|
-
if(installed_files.size > 0) then
|
129
|
-
errors[gem_name] << ErrorData.new(gem_path, "Unmanaged files in gem: #{installed_files.inspect}")
|
130
|
-
end
|
163
|
+
errors.each do |name, subhash|
|
164
|
+
errors[name] = subhash.map { |path, msg| ErrorData.new(path, msg) }
|
131
165
|
end
|
132
166
|
|
133
167
|
errors
|
@@ -167,7 +201,7 @@ class Gem::Validator
|
|
167
201
|
def unit_test(gem_spec)
|
168
202
|
start_dir = Dir.pwd
|
169
203
|
Dir.chdir(gem_spec.full_gem_path)
|
170
|
-
$: <<
|
204
|
+
$: << gem_spec.full_gem_path
|
171
205
|
# XXX: why do we need this gem_spec when we've already got 'spec'?
|
172
206
|
test_files = gem_spec.test_files
|
173
207
|
|
data/lib/rubygems/version.rb
CHANGED
@@ -7,24 +7,74 @@
|
|
7
7
|
require 'rubygems'
|
8
8
|
|
9
9
|
##
|
10
|
-
# The Version class processes string versions into comparable
|
10
|
+
# The Version class processes string versions into comparable
|
11
|
+
# values. A version string should normally be a series of numbers
|
12
|
+
# separated by periods. Each part (digits separated by periods) is
|
13
|
+
# considered its own number, and these are used for sorting. So for
|
14
|
+
# instance, 3.10 sorts higher than 3.2 because ten is greater than
|
15
|
+
# two.
|
16
|
+
#
|
17
|
+
# If any part contains letters (currently only a-z are supported) then
|
18
|
+
# that version is considered prerelease. Versions with a prerelease
|
19
|
+
# part in the Nth part sort less than versions with N-1 parts. Prerelease
|
20
|
+
# parts are sorted alphabetically using the normal Ruby string sorting
|
21
|
+
# rules.
|
22
|
+
#
|
11
23
|
|
12
24
|
class Gem::Version
|
25
|
+
|
26
|
+
class Part
|
27
|
+
include Comparable
|
28
|
+
|
29
|
+
attr_reader :value
|
30
|
+
|
31
|
+
def initialize(value)
|
32
|
+
@value = (value =~ /\A\d+\z/) ? value.to_i : value
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
self.value.to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
def inspect
|
40
|
+
@value
|
41
|
+
end
|
42
|
+
|
43
|
+
def alpha?
|
44
|
+
String === value
|
45
|
+
end
|
46
|
+
|
47
|
+
def numeric?
|
48
|
+
Fixnum === value
|
49
|
+
end
|
50
|
+
|
51
|
+
def <=>(other)
|
52
|
+
if self.numeric? && other.alpha? then
|
53
|
+
1
|
54
|
+
elsif self.alpha? && other.numeric? then
|
55
|
+
-1
|
56
|
+
else
|
57
|
+
self.value <=> other.value
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def succ
|
62
|
+
self.class.new(self.value.succ)
|
63
|
+
end
|
64
|
+
end
|
13
65
|
|
14
66
|
include Comparable
|
15
67
|
|
16
|
-
|
68
|
+
VERSION_PATTERN = '[0-9]+(\.[0-9a-z]+)*'
|
17
69
|
|
18
70
|
attr_reader :version
|
19
71
|
|
20
|
-
##
|
21
|
-
# Returns true if +version+ is a valid version string.
|
22
|
-
|
23
72
|
def self.correct?(version)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
73
|
+
pattern = /\A\s*(#{VERSION_PATTERN})*\s*\z/
|
74
|
+
|
75
|
+
version.is_a? Integer or
|
76
|
+
version =~ pattern or
|
77
|
+
version.to_s =~ pattern
|
28
78
|
end
|
29
79
|
|
30
80
|
##
|
@@ -47,7 +97,7 @@ class Gem::Version
|
|
47
97
|
|
48
98
|
##
|
49
99
|
# Constructs a Version from the +version+ string. A version string is a
|
50
|
-
# series of digits separated by dots.
|
100
|
+
# series of digits or ASCII letters separated by dots.
|
51
101
|
|
52
102
|
def initialize(version)
|
53
103
|
raise ArgumentError, "Malformed version number string #{version}" unless
|
@@ -70,17 +120,20 @@ class Gem::Version
|
|
70
120
|
self.version = array[0]
|
71
121
|
end
|
72
122
|
|
123
|
+
def parts
|
124
|
+
@parts ||= normalize
|
125
|
+
end
|
126
|
+
|
73
127
|
##
|
74
128
|
# Strip ignored trailing zeros.
|
75
129
|
|
76
130
|
def normalize
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
@ints = [0] if @ints.empty?
|
131
|
+
parts_arr = parse_parts_from_version_string
|
132
|
+
if parts_arr.length != 1
|
133
|
+
parts_arr.pop while parts_arr.last && parts_arr.last.value == 0
|
134
|
+
parts_arr = [Part.new(0)] if parts_arr.empty?
|
135
|
+
end
|
136
|
+
parts_arr
|
84
137
|
end
|
85
138
|
|
86
139
|
##
|
@@ -92,14 +145,6 @@ class Gem::Version
|
|
92
145
|
@version
|
93
146
|
end
|
94
147
|
|
95
|
-
##
|
96
|
-
# Returns an integer array representation of this Version.
|
97
|
-
|
98
|
-
def to_ints
|
99
|
-
normalize unless @ints
|
100
|
-
@ints
|
101
|
-
end
|
102
|
-
|
103
148
|
def to_yaml_properties
|
104
149
|
['@version']
|
105
150
|
end
|
@@ -109,6 +154,13 @@ class Gem::Version
|
|
109
154
|
normalize
|
110
155
|
end
|
111
156
|
|
157
|
+
##
|
158
|
+
# A version is considered a prerelease if any part contains a letter.
|
159
|
+
|
160
|
+
def prerelease?
|
161
|
+
parts.any? { |part| part.alpha? }
|
162
|
+
end
|
163
|
+
|
112
164
|
def yaml_initialize(tag, values)
|
113
165
|
self.version = values['version']
|
114
166
|
end
|
@@ -120,7 +172,14 @@ class Gem::Version
|
|
120
172
|
def <=>(other)
|
121
173
|
return nil unless self.class === other
|
122
174
|
return 1 unless other
|
123
|
-
|
175
|
+
mine, theirs = balance(self.parts.dup, other.parts.dup)
|
176
|
+
mine <=> theirs
|
177
|
+
end
|
178
|
+
|
179
|
+
def balance(a, b)
|
180
|
+
a << Part.new(0) while a.size < b.size
|
181
|
+
b << Part.new(0) while b.size < a.size
|
182
|
+
[a, b]
|
124
183
|
end
|
125
184
|
|
126
185
|
##
|
@@ -137,17 +196,22 @@ class Gem::Version
|
|
137
196
|
|
138
197
|
# Return a new version object where the next to the last revision
|
139
198
|
# number is one greater. (e.g. 5.3.1 => 5.4)
|
199
|
+
# Pre-release (alpha) parts are ignored. (e.g 5.3.1.b2 => 5.4)
|
140
200
|
def bump
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
201
|
+
parts = parse_parts_from_version_string
|
202
|
+
parts.pop while parts.any? { |part| part.alpha? }
|
203
|
+
parts.pop if parts.size > 1
|
204
|
+
parts[-1] = parts[-1].succ
|
205
|
+
self.class.new(parts.join("."))
|
206
|
+
end
|
207
|
+
|
208
|
+
def parse_parts_from_version_string # :nodoc:
|
209
|
+
@version.to_s.scan(/[0-9a-z]+/i).map { |s| Part.new(s) }
|
145
210
|
end
|
146
211
|
|
147
|
-
def
|
148
|
-
|
212
|
+
def pretty_print(q) # :nodoc:
|
213
|
+
q.text "Gem::Version.new(#{@version.inspect})"
|
149
214
|
end
|
150
|
-
private :build_array_from_version_string
|
151
215
|
|
152
216
|
#:stopdoc:
|
153
217
|
|
data/setup.rb
CHANGED
@@ -18,317 +18,22 @@ if ENV['RUBYOPT'] and defined? Gem then
|
|
18
18
|
exec(ruby, 'setup.rb', *ARGV)
|
19
19
|
end
|
20
20
|
|
21
|
+
Dir.chdir File.dirname(__FILE__)
|
22
|
+
|
21
23
|
$:.unshift 'lib'
|
22
24
|
require 'rubygems'
|
23
|
-
require '
|
24
|
-
|
25
|
-
opts = GetoptLong.new(
|
26
|
-
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
27
|
-
[ '--prefix', GetoptLong::REQUIRED_ARGUMENT ],
|
28
|
-
[ '--no-format-executable', GetoptLong::NO_ARGUMENT ],
|
29
|
-
[ '--no-rdoc', GetoptLong::NO_ARGUMENT ],
|
30
|
-
[ '--no-ri', GetoptLong::NO_ARGUMENT ],
|
31
|
-
[ '--vendor', GetoptLong::NO_ARGUMENT ],
|
32
|
-
[ '--destdir', GetoptLong::REQUIRED_ARGUMENT ]
|
33
|
-
)
|
34
|
-
|
35
|
-
prefix = ''
|
36
|
-
format_executable = true
|
37
|
-
rdoc = true
|
38
|
-
ri = true
|
39
|
-
site_or_vendor = :sitelibdir
|
40
|
-
install_destdir = ''
|
41
|
-
|
42
|
-
opts.each do | opt, arg |
|
43
|
-
case opt
|
44
|
-
when '--help'
|
45
|
-
puts <<HELP
|
46
|
-
ruby setup.rb [options]:
|
47
|
-
|
48
|
-
RubyGems will install the gem command with a name matching ruby's
|
49
|
-
prefix and suffix. If ruby was installed as `ruby18`, gem will be
|
50
|
-
installed as `gem18`.
|
25
|
+
require 'rubygems/gem_runner'
|
26
|
+
require 'rubygems/exceptions'
|
51
27
|
|
52
|
-
|
53
|
-
#{Gem.default_exec_format % 'gem'}
|
28
|
+
Gem::CommandManager.instance.register_command :setup
|
54
29
|
|
55
|
-
|
56
|
-
--help Print this message
|
57
|
-
--prefix=DIR Prefix path for installing RubyGems
|
58
|
-
Will not affect gem repository location
|
59
|
-
--no-format-executable Force installation as `gem`
|
60
|
-
--no-rdoc Don't build RDoc for RubyGems
|
61
|
-
--no-ri Don't build ri for RubyGems
|
62
|
-
--vendor Install into vendorlibdir not sitelibdir
|
63
|
-
(Requires Ruby 1.8.7)
|
64
|
-
--destdir Root directory to install rubygems into
|
65
|
-
Used mainly for packaging RubyGems
|
66
|
-
HELP
|
67
|
-
exit 0
|
30
|
+
args = ARGV.clone
|
68
31
|
|
69
|
-
|
70
|
-
rdoc = false
|
32
|
+
args.unshift 'setup'
|
71
33
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
format_executable = false
|
77
|
-
|
78
|
-
when '--prefix'
|
79
|
-
prefix = File.expand_path(arg)
|
80
|
-
|
81
|
-
when '--vendor'
|
82
|
-
vendor_dir_version = Gem::Version::Requirement.create('>= 1.8.7')
|
83
|
-
unless vendor_dir_version.satisfied_by? Gem.ruby_version then
|
84
|
-
abort "To use --vendor you need ruby #{vendor_dir_version}, current #{Gem.ruby_version}"
|
85
|
-
end
|
86
|
-
site_or_vendor = :vendorlibdir
|
87
|
-
|
88
|
-
when '--destdir'
|
89
|
-
install_destdir = File.expand_path(arg)
|
90
|
-
end
|
34
|
+
begin
|
35
|
+
Gem::GemRunner.new.run args
|
36
|
+
rescue Gem::SystemExitException => e
|
37
|
+
exit e.exit_code
|
91
38
|
end
|
92
39
|
|
93
|
-
require 'fileutils'
|
94
|
-
require 'rbconfig'
|
95
|
-
require 'tmpdir'
|
96
|
-
require 'pathname'
|
97
|
-
|
98
|
-
unless install_destdir.empty? then
|
99
|
-
default_dir = Pathname.new(Gem.default_dir)
|
100
|
-
top_dir = Pathname.new(RbConfig::TOPDIR)
|
101
|
-
ENV['GEM_HOME'] ||= File.join(install_destdir,
|
102
|
-
default_dir.relative_path_from(top_dir))
|
103
|
-
end
|
104
|
-
|
105
|
-
include FileUtils::Verbose
|
106
|
-
|
107
|
-
# check ruby version
|
108
|
-
|
109
|
-
required_version = Gem::Version::Requirement.create("> 1.8.3")
|
110
|
-
|
111
|
-
unless required_version.satisfied_by? Gem.ruby_version then
|
112
|
-
abort "Expected Ruby version #{required_version}, was #{Gem.ruby_version}"
|
113
|
-
end
|
114
|
-
|
115
|
-
# install stuff
|
116
|
-
|
117
|
-
lib_dir = nil
|
118
|
-
bin_dir = nil
|
119
|
-
|
120
|
-
if prefix.empty?
|
121
|
-
lib_dir = Gem::ConfigMap[site_or_vendor]
|
122
|
-
bin_dir = Gem::ConfigMap[:bindir]
|
123
|
-
else
|
124
|
-
# Apple installed RubyGems into libdir, and RubyGems <= 1.1.0 gets confused
|
125
|
-
# about installation location, so switch back to sitelibdir/vendorlibdir.
|
126
|
-
if defined?(APPLE_GEM_HOME) and
|
127
|
-
# just in case Apple and RubyGems don't get this patched up proper.
|
128
|
-
(prefix == Gem::ConfigMap[:libdir] or
|
129
|
-
# this one is important
|
130
|
-
prefix == File.join(Gem::ConfigMap[:libdir], 'ruby')) then
|
131
|
-
lib_dir = Gem::ConfigMap[site_or_vendor]
|
132
|
-
bin_dir = Gem::ConfigMap[:bindir]
|
133
|
-
else
|
134
|
-
lib_dir = File.join prefix, 'lib'
|
135
|
-
bin_dir = File.join prefix, 'bin'
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
unless install_destdir.empty?
|
140
|
-
top_dir = Pathname.new(RbConfig::TOPDIR)
|
141
|
-
lib_dir_p = Pathname.new(lib_dir)
|
142
|
-
bin_dir_p = Pathname.new(bin_dir)
|
143
|
-
|
144
|
-
lib_dir = File.join install_destdir, lib_dir_p.relative_path_from(top_dir)
|
145
|
-
bin_dir = File.join install_destdir, bin_dir_p.relative_path_from(top_dir)
|
146
|
-
end
|
147
|
-
|
148
|
-
mkdir_p lib_dir
|
149
|
-
mkdir_p bin_dir
|
150
|
-
|
151
|
-
Dir.chdir 'lib' do
|
152
|
-
lib_files = Dir[File.join('**', '*rb')]
|
153
|
-
|
154
|
-
lib_files.each do |lib_file|
|
155
|
-
dest_file = File.join lib_dir, lib_file
|
156
|
-
dest_dir = File.dirname dest_file
|
157
|
-
mkdir_p dest_dir unless File.directory? dest_dir
|
158
|
-
|
159
|
-
install lib_file, dest_file, :mode => 0644
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
bin_file_names = []
|
164
|
-
|
165
|
-
Dir.chdir 'bin' do
|
166
|
-
bin_files = Dir['*']
|
167
|
-
|
168
|
-
bin_files.delete 'update_rubygems'
|
169
|
-
|
170
|
-
bin_files.each do |bin_file|
|
171
|
-
bin_file_formatted = if format_executable then
|
172
|
-
Gem.default_exec_format % bin_file
|
173
|
-
else
|
174
|
-
bin_file
|
175
|
-
end
|
176
|
-
|
177
|
-
dest_file = File.join bin_dir, bin_file_formatted
|
178
|
-
bin_tmp_file = File.join Dir.tmpdir, bin_file
|
179
|
-
|
180
|
-
begin
|
181
|
-
cp bin_file, bin_tmp_file
|
182
|
-
bin = File.readlines bin_tmp_file
|
183
|
-
bin[0] = "#!#{Gem.ruby}\n"
|
184
|
-
|
185
|
-
File.open bin_tmp_file, 'w' do |fp|
|
186
|
-
fp.puts bin.join
|
187
|
-
end
|
188
|
-
|
189
|
-
install bin_tmp_file, dest_file, :mode => 0755
|
190
|
-
bin_file_names << dest_file
|
191
|
-
ensure
|
192
|
-
rm bin_tmp_file
|
193
|
-
end
|
194
|
-
|
195
|
-
next unless Gem.win_platform?
|
196
|
-
|
197
|
-
begin
|
198
|
-
bin_cmd_file = File.join Dir.tmpdir, "#{bin_file}.bat"
|
199
|
-
|
200
|
-
File.open bin_cmd_file, 'w' do |file|
|
201
|
-
file.puts <<-TEXT
|
202
|
-
@ECHO OFF
|
203
|
-
IF NOT "%~f0" == "~f0" GOTO :WinNT
|
204
|
-
@"#{File.basename(Gem.ruby)}" "#{dest_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
205
|
-
GOTO :EOF
|
206
|
-
:WinNT
|
207
|
-
@"#{File.basename(Gem.ruby)}" "%~dpn0" %*
|
208
|
-
TEXT
|
209
|
-
end
|
210
|
-
|
211
|
-
install bin_cmd_file, "#{dest_file}.bat", :mode => 0755
|
212
|
-
ensure
|
213
|
-
rm bin_cmd_file
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
# Replace old bin files with ones that abort.
|
219
|
-
|
220
|
-
old_bin_files = {
|
221
|
-
'gem_mirror' => 'gem mirror',
|
222
|
-
'gem_server' => 'gem server',
|
223
|
-
'gemlock' => 'gem lock',
|
224
|
-
'gemri' => 'ri',
|
225
|
-
'gemwhich' => 'gem which',
|
226
|
-
'index_gem_repository.rb' => 'gem generate_index',
|
227
|
-
}
|
228
|
-
|
229
|
-
old_bin_files.each do |old_bin_file, new_name|
|
230
|
-
old_bin_path = File.join bin_dir, old_bin_file
|
231
|
-
next unless File.exist? old_bin_path
|
232
|
-
|
233
|
-
deprecation_message = "`#{old_bin_file}` has been deprecated. Use `#{new_name}` instead."
|
234
|
-
|
235
|
-
File.open old_bin_path, 'w' do |fp|
|
236
|
-
fp.write <<-EOF
|
237
|
-
#!#{Gem.ruby}
|
238
|
-
|
239
|
-
abort "#{deprecation_message}"
|
240
|
-
EOF
|
241
|
-
end
|
242
|
-
|
243
|
-
next unless Gem.win_platform?
|
244
|
-
|
245
|
-
File.open "#{old_bin_path}.bat", 'w' do |fp|
|
246
|
-
fp.puts %{@ECHO.#{deprecation_message}}
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
# Remove source caches
|
251
|
-
if install_destdir.empty?
|
252
|
-
require 'rubygems/source_info_cache'
|
253
|
-
|
254
|
-
user_cache_file = File.join(install_destdir,
|
255
|
-
Gem::SourceInfoCache.user_cache_file)
|
256
|
-
system_cache_file = File.join(install_destdir,
|
257
|
-
Gem::SourceInfoCache.system_cache_file)
|
258
|
-
|
259
|
-
rm_f user_cache_file if File.writable? File.dirname(user_cache_file)
|
260
|
-
rm_f system_cache_file if File.writable? File.dirname(system_cache_file)
|
261
|
-
end
|
262
|
-
|
263
|
-
# install RDoc
|
264
|
-
|
265
|
-
gem_doc_dir = File.join Gem.dir, 'doc'
|
266
|
-
rubygems_name = "rubygems-#{Gem::RubyGemsVersion}"
|
267
|
-
rubygems_doc_dir = File.join gem_doc_dir, rubygems_name
|
268
|
-
|
269
|
-
if File.writable? gem_doc_dir and
|
270
|
-
(not File.exist? rubygems_doc_dir or
|
271
|
-
File.writable? rubygems_doc_dir) then
|
272
|
-
puts "Removing old RubyGems RDoc and ri"
|
273
|
-
Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir|
|
274
|
-
rm_rf dir
|
275
|
-
end
|
276
|
-
|
277
|
-
def run_rdoc(*args)
|
278
|
-
begin
|
279
|
-
gem 'rdoc'
|
280
|
-
rescue Gem::LoadError
|
281
|
-
end
|
282
|
-
|
283
|
-
require 'rdoc/rdoc'
|
284
|
-
|
285
|
-
args << '--quiet'
|
286
|
-
args << '--main' << 'README'
|
287
|
-
args << '.' << 'README' << 'LICENSE.txt' << 'GPL.txt'
|
288
|
-
|
289
|
-
r = RDoc::RDoc.new
|
290
|
-
r.document args
|
291
|
-
end
|
292
|
-
|
293
|
-
if ri then
|
294
|
-
ri_dir = File.join rubygems_doc_dir, 'ri'
|
295
|
-
puts "Installing #{rubygems_name} ri into #{ri_dir}"
|
296
|
-
run_rdoc '--ri', '--op', ri_dir
|
297
|
-
end
|
298
|
-
|
299
|
-
if rdoc then
|
300
|
-
rdoc_dir = File.join rubygems_doc_dir, 'rdoc'
|
301
|
-
puts "Installing #{rubygems_name} rdoc into #{rdoc_dir}"
|
302
|
-
run_rdoc '--op', rdoc_dir
|
303
|
-
end
|
304
|
-
else
|
305
|
-
puts "Skipping RDoc generation, #{gem_doc_dir} not writable"
|
306
|
-
puts "Set the GEM_HOME environment variable if you want RDoc generated"
|
307
|
-
end
|
308
|
-
|
309
|
-
puts
|
310
|
-
puts "-" * 78
|
311
|
-
puts
|
312
|
-
|
313
|
-
release_notes = File.join File.dirname(__FILE__), 'doc', 'release_notes',
|
314
|
-
"rel_#{Gem::RubyGemsVersion.gsub '.', '_'}.rdoc"
|
315
|
-
|
316
|
-
if File.exist? release_notes then
|
317
|
-
puts File.read(release_notes)
|
318
|
-
else
|
319
|
-
puts "Oh-no! Unable to find release notes in:\n\t#{release_notes}"
|
320
|
-
end
|
321
|
-
|
322
|
-
puts
|
323
|
-
puts "-" * 78
|
324
|
-
puts
|
325
|
-
|
326
|
-
puts "RubyGems installed the following executables:"
|
327
|
-
puts bin_file_names.map { |name| "\t#{name}\n" }
|
328
|
-
puts
|
329
|
-
|
330
|
-
puts "If `gem` was installed by a previous RubyGems installation, you may need"
|
331
|
-
puts "to remove it by hand."
|
332
|
-
puts
|
333
|
-
|
334
|
-
|