rubygems-update 0.9.5 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (53) hide show
  1. data/ChangeLog +135 -0
  2. data/Rakefile +3 -1
  3. data/lib/rubygems.rb +27 -38
  4. data/lib/rubygems/commands/install_command.rb +2 -0
  5. data/lib/rubygems/commands/mirror_command.rb +8 -2
  6. data/lib/rubygems/commands/query_command.rb +3 -1
  7. data/lib/rubygems/commands/server_command.rb +3 -3
  8. data/lib/rubygems/commands/unpack_command.rb +11 -4
  9. data/lib/rubygems/commands/update_command.rb +114 -108
  10. data/lib/rubygems/defaults.rb +46 -0
  11. data/lib/rubygems/dependency_installer.rb +13 -2
  12. data/lib/rubygems/indexer.rb +1 -1
  13. data/lib/rubygems/install_update_options.rb +7 -0
  14. data/lib/rubygems/installer.rb +66 -11
  15. data/lib/rubygems/package.rb +2 -1
  16. data/lib/rubygems/platform.rb +24 -30
  17. data/lib/rubygems/remote_fetcher.rb +7 -3
  18. data/lib/rubygems/require_paths_builder.rb +15 -0
  19. data/lib/rubygems/rubygems_version.rb +1 -1
  20. data/lib/rubygems/security.rb +1 -1
  21. data/lib/rubygems/server.rb +18 -3
  22. data/lib/rubygems/source_index.rb +20 -23
  23. data/lib/rubygems/source_info_cache.rb +3 -3
  24. data/lib/rubygems/specification.rb +64 -31
  25. data/lib/rubygems/uninstaller.rb +1 -1
  26. data/lib/rubygems/validator.rb +3 -2
  27. data/lib/rubygems/version.rb +10 -3
  28. data/setup.rb +30 -6
  29. data/test/gemutilities.rb +23 -13
  30. data/test/gemutilities.rbc +0 -0
  31. data/test/mockgemui.rbc +0 -0
  32. data/test/test_gem.rb +46 -76
  33. data/test/test_gem.rbc +0 -0
  34. data/test/test_gem_commands_build_command.rb +12 -12
  35. data/test/test_gem_commands_dependency_command.rb +10 -10
  36. data/test/test_gem_commands_mirror_command.rb +9 -4
  37. data/test/test_gem_commands_query_command.rb +7 -3
  38. data/test/test_gem_commands_server_command.rb +27 -0
  39. data/test/test_gem_commands_unpack_command.rb +20 -2
  40. data/test/test_gem_format.rb +1 -1
  41. data/test/test_gem_indexer.rb +5 -5
  42. data/test/test_gem_install_update_options.rb +1 -1
  43. data/test/test_gem_installer.rb +149 -60
  44. data/test/test_gem_platform.rb +19 -0
  45. data/test/test_gem_remote_fetcher.rb +19 -2
  46. data/test/test_gem_server.rb +44 -1
  47. data/test/test_gem_source_index.rb +2 -2
  48. data/test/test_gem_specification.rb +300 -168
  49. data/test/test_gem_version.rb +15 -0
  50. data/test/test_kernel.rb +19 -19
  51. metadata +46 -42
  52. data/lib/rubygems/remote_installer.rb +0 -195
  53. data/test/test_gem_remote_installer.rb +0 -161
@@ -0,0 +1,46 @@
1
+ module Gem
2
+
3
+ # An Array of the default sources that come with RubyGems.
4
+ def self.default_sources
5
+ %w[http://gems.rubyforge.org]
6
+ end
7
+
8
+ # Default home directory path to be used if an alternate value is not
9
+ # specified in the environment.
10
+ def self.default_dir
11
+ if defined? RUBY_FRAMEWORK_VERSION then
12
+ File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
13
+ ConfigMap[:ruby_version]
14
+ else
15
+ File.join ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version]
16
+ end
17
+ end
18
+
19
+ # Default gem path.
20
+ def self.default_path
21
+ default_dir
22
+ end
23
+
24
+ # Deduce Ruby's --program-prefix and --program-suffix from its install name.
25
+ def self.default_exec_format
26
+ baseruby = ConfigMap[:BASERUBY] || 'ruby'
27
+ ConfigMap[:RUBY_INSTALL_NAME].sub(baseruby, '%s') rescue '%s'
28
+ end
29
+
30
+ # The default directory for binaries
31
+ def self.default_bindir
32
+ Config::CONFIG['bindir']
33
+ end
34
+
35
+ # The default system-wide source info cache directory.
36
+ def self.default_system_source_cache_dir
37
+ File.join Gem.dir, 'source_cache'
38
+ end
39
+
40
+ # The default user-specific source info cache directory.
41
+ def self.default_user_source_cache_dir
42
+ File.join Gem.user_home, '.gem', 'source_cache'
43
+ end
44
+
45
+ end
46
+
@@ -15,8 +15,9 @@ class Gem::DependencyInstaller
15
15
  :env_shebang => false,
16
16
  :domain => :both, # HACK dup
17
17
  :force => false,
18
+ :format_executable => false, # HACK dup
18
19
  :ignore_dependencies => false,
19
- :security_policy => Gem::Security::NoSecurity, # HACK AlmostNo? Low?
20
+ :security_policy => nil, # HACK NoSecurity requires OpenSSL. AlmostNo? Low?
20
21
  :wrappers => true
21
22
  }
22
23
 
@@ -30,6 +31,7 @@ class Gem::DependencyInstaller
30
31
  # current directory. :remote searches only gems in Gem::sources.
31
32
  # :both searches both.
32
33
  # :force:: See Gem::Installer#install.
34
+ # :format_executable:: See Gem::Installer#initialize.
33
35
  # :ignore_dependencies: Don't install any dependencies.
34
36
  # :install_dir: See Gem::Installer#install.
35
37
  # :security_policy: See Gem::Installer::new and Gem::Security.
@@ -39,6 +41,7 @@ class Gem::DependencyInstaller
39
41
  @env_shebang = options[:env_shebang]
40
42
  @domain = options[:domain]
41
43
  @force = options[:force]
44
+ @format_executable = options[:format_executable]
42
45
  @ignore_dependencies = options[:ignore_dependencies]
43
46
  @install_dir = options[:install_dir] || Gem.dir
44
47
  @security_policy = options[:security_policy]
@@ -48,7 +51,14 @@ class Gem::DependencyInstaller
48
51
 
49
52
  spec_and_source = nil
50
53
 
51
- local_gems = Dir["#{gem_name}*"].sort.reverse
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
+
52
62
  unless local_gems.empty? then
53
63
  local_gems.each do |gem_file|
54
64
  next unless gem_file =~ /gem$/
@@ -217,6 +227,7 @@ class Gem::DependencyInstaller
217
227
  inst = Gem::Installer.new local_gem_path,
218
228
  :env_shebang => @env_shebang,
219
229
  :force => @force,
230
+ :format_executable => @format_executable,
220
231
  :ignore_dependencies => @ignore_dependencies,
221
232
  :install_dir => @install_dir,
222
233
  :security_policy => @security_policy,
@@ -98,7 +98,7 @@ class Gem::Indexer
98
98
  files = @master_index.files + @quick_index.files + @marshal_index.files
99
99
 
100
100
  files.each do |file|
101
- relative_name = file[/\A#{@directory}.(.*)/, 1]
101
+ relative_name = file[/\A#{Regexp.escape @directory}.(.*)/, 1]
102
102
  dest_name = File.join @dest_directory, relative_name
103
103
 
104
104
  FileUtils.rm_rf dest_name, :verbose => verbose
@@ -76,6 +76,13 @@ module Gem::InstallUpdateOptions
76
76
  'dependent gems') do |value, options|
77
77
  options[:include_dependencies] = value
78
78
  end
79
+
80
+ add_option(:"Install/Update", '--[no-]format-executable',
81
+ 'Make installed executable names match ruby.',
82
+ 'If ruby is ruby18, foo_exec will be',
83
+ 'foo_exec18') do |value, options|
84
+ options[:format_executable] = value
85
+ end
79
86
  end
80
87
 
81
88
  # Default options for the gem install command.
@@ -10,6 +10,7 @@ require 'rbconfig'
10
10
 
11
11
  require 'rubygems/format'
12
12
  require 'rubygems/ext'
13
+ require 'rubygems/require_paths_builder'
13
14
 
14
15
  ##
15
16
  # The installer class processes RubyGem .gem files and installs the
@@ -28,6 +29,19 @@ class Gem::Installer
28
29
 
29
30
  include Gem::UserInteraction
30
31
 
32
+ include Gem::RequirePathsBuilder
33
+
34
+ class << self
35
+
36
+ attr_writer :exec_format
37
+
38
+ # Defaults to use Ruby's program prefix and suffix.
39
+ def exec_format
40
+ @exec_format ||= Gem.default_exec_format
41
+ end
42
+
43
+ end
44
+
31
45
  ##
32
46
  # Constructs an Installer instance that will install the gem located at
33
47
  # +gem+. +options+ is a Hash with the following keys:
@@ -37,18 +51,26 @@ class Gem::Installer
37
51
  # for a signed-gems-only policy.
38
52
  # :ignore_dependencies:: Don't raise if a dependency is missing.
39
53
  # :install_dir:: The directory to install the gem into.
54
+ # :format_executable:: Format the executable the same as the ruby executable.
55
+ # If your ruby is ruby18, foo_exec will be installed as
56
+ # foo_exec18.
40
57
  # :security_policy:: Use the specified security policy. See Gem::Security
41
58
  # :wrappers:: Install wrappers if true, symlinks if false.
42
59
  def initialize(gem, options={})
43
60
  @gem = gem
44
61
 
45
- options = { :force => false, :install_dir => Gem.dir }.merge options
62
+ options = {
63
+ :force => false,
64
+ :install_dir => Gem.dir,
65
+ :exec_format => false,
66
+ }.merge options
46
67
 
47
68
  @env_shebang = options[:env_shebang]
48
69
  @force = options[:force]
49
70
  gem_home = options[:install_dir]
50
71
  @gem_home = Pathname.new(gem_home).expand_path
51
72
  @ignore_dependencies = options[:ignore_dependencies]
73
+ @format_executable = options[:format_executable]
52
74
  @security_policy = options[:security_policy]
53
75
  @wrappers = options[:wrappers]
54
76
 
@@ -112,6 +134,8 @@ class Gem::Installer
112
134
  build_extensions
113
135
  write_spec
114
136
 
137
+ write_require_paths_file_if_needed
138
+
115
139
  # HACK remove? Isn't this done in multiple places?
116
140
  cached_gem = File.join @gem_home, "cache", @gem.split(/\//).pop
117
141
  unless File.exist? cached_gem then
@@ -185,9 +209,12 @@ class Gem::Installer
185
209
  def generate_windows_script(bindir, filename)
186
210
  if Gem.win_platform? then
187
211
  script_name = filename + ".bat"
188
- File.open(File.join(bindir, File.basename(script_name)), "w") do |file|
212
+ script_path = File.join bindir, File.basename(script_name)
213
+ File.open script_path, 'w' do |file|
189
214
  file.puts windows_stub_script(bindir, filename)
190
215
  end
216
+
217
+ say script_path if Gem.configuration.really_verbose
191
218
  end
192
219
  end
193
220
 
@@ -204,7 +231,7 @@ class Gem::Installer
204
231
 
205
232
  @spec.executables.each do |filename|
206
233
  filename.untaint
207
- bin_path = File.join @gem_dir, 'bin', filename
234
+ bin_path = File.expand_path File.join(@gem_dir, @spec.bindir, filename)
208
235
  mode = File.stat(bin_path).mode | 0111
209
236
  File.chmod mode, bin_path
210
237
 
@@ -224,10 +251,24 @@ class Gem::Installer
224
251
  # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/193379
225
252
  #
226
253
  def generate_bin_script(filename, bindir)
227
- File.open(File.join(bindir, File.basename(filename)), "w", 0755) do |file|
228
- file.print app_script_text(filename)
229
- end
230
- generate_windows_script bindir, filename
254
+ bin_script_path = File.join bindir, formatted_program_filename(filename)
255
+
256
+ exec_path = File.join @gem_dir, @spec.bindir, filename
257
+
258
+ # HACK some gems don't have #! in their executables, restore 2008/06
259
+ #if File.read(exec_path, 2) == '#!' then
260
+ File.open bin_script_path, 'w', 0755 do |file|
261
+ file.print app_script_text(filename)
262
+ end
263
+
264
+ say bin_script_path if Gem.configuration.really_verbose
265
+
266
+ generate_windows_script bindir, filename
267
+ #else
268
+ # FileUtils.rm_f bin_script_path
269
+ # FileUtils.cp exec_path, bin_script_path,
270
+ # :verbose => Gem.configuration.really_verbose
271
+ #end
231
272
  end
232
273
 
233
274
  ##
@@ -235,14 +276,14 @@ class Gem::Installer
235
276
  # the symlink if the gem being installed has a newer version.
236
277
  #
237
278
  def generate_bin_symlink(filename, bindir)
238
- if Config::CONFIG["arch"] =~ /dos|win32/i then
239
- alert_warning "Unable to use symlinks on win32, installing wrapper"
279
+ if Gem.win_platform? then
280
+ alert_warning "Unable to use symlinks on Windows, installing wrapper"
240
281
  generate_bin_script filename, bindir
241
282
  return
242
283
  end
243
284
 
244
285
  src = File.join @gem_dir, 'bin', filename
245
- dst = File.join bindir, File.basename(filename)
286
+ dst = File.join bindir, formatted_program_filename(filename)
246
287
 
247
288
  if File.exist? dst then
248
289
  if File.symlink? dst then
@@ -253,7 +294,7 @@ class Gem::Installer
253
294
  File.unlink dst
254
295
  end
255
296
 
256
- File.symlink src, dst
297
+ FileUtils.symlink src, dst, :verbose => Gem.configuration.really_verbose
257
298
  end
258
299
 
259
300
  ##
@@ -346,6 +387,9 @@ TEXT
346
387
  begin
347
388
  Dir.chdir File.join(@gem_dir, File.dirname(extension))
348
389
  results = builder.build(extension, @gem_dir, dest_path, results)
390
+
391
+ say results.join("\n") if Gem.configuration.really_verbose
392
+
349
393
  rescue => ex
350
394
  results = results.join "\n"
351
395
 
@@ -397,6 +441,17 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
397
441
  File.open(path, "wb") do |out|
398
442
  out.write file_data
399
443
  end
444
+
445
+ say path if Gem.configuration.really_verbose
446
+ end
447
+ end
448
+
449
+ # Prefix and suffix the program filename the same as ruby.
450
+ def formatted_program_filename(filename)
451
+ if @format_executable then
452
+ self.class.exec_format % File.basename(filename)
453
+ else
454
+ filename
400
455
  end
401
456
  end
402
457
 
@@ -142,6 +142,7 @@ module Gem::Package
142
142
  end
143
143
 
144
144
  def calculate_checksum(hdr)
145
+ #hdr.split('').map { |c| c[0] }.inject { |a, b| a + b } # HACK rubinius
145
146
  hdr.unpack("C*").inject{|a,b| a+b}
146
147
  end
147
148
 
@@ -379,7 +380,7 @@ module Gem::Package
379
380
  end
380
381
 
381
382
  alias_method :is_directory, :is_directory?
382
- alias_method :is_file, :is_file
383
+ alias_method :is_file, :is_file?
383
384
 
384
385
  def bytes_read
385
386
  @read
@@ -12,8 +12,25 @@ class Gem::Platform
12
12
 
13
13
  attr_accessor :version
14
14
 
15
+ DEPRECATED_CONSTS = [
16
+ :DARWIN,
17
+ :LINUX_586,
18
+ :MSWIN32,
19
+ :PPC_DARWIN,
20
+ :WIN32,
21
+ :X86_LINUX
22
+ ]
23
+
24
+ def self.const_missing(name) # TODO remove six months from 2007/12
25
+ if DEPRECATED_CONSTS.include? name then
26
+ raise NameError, "#{name} has been removed, use CURRENT instead"
27
+ else
28
+ super
29
+ end
30
+ end
31
+
15
32
  def self.local
16
- arch = Config::CONFIG['arch']
33
+ arch = Gem::ConfigMap[:arch]
17
34
  arch = "#{arch}_60" if arch =~ /mswin32$/
18
35
  @local ||= new(arch)
19
36
  end
@@ -27,6 +44,8 @@ class Gem::Platform
27
44
 
28
45
  def self.new(arch) # :nodoc:
29
46
  case arch
47
+ when Gem::Platform::CURRENT then
48
+ Gem::Platform.local
30
49
  when Gem::Platform::RUBY, nil, '' then
31
50
  Gem::Platform::RUBY
32
51
  else
@@ -71,7 +90,10 @@ class Gem::Platform
71
90
  when /^java([\d.]*)/ then [ 'java', $1 ]
72
91
  when /linux/ then [ 'linux', $1 ]
73
92
  when /mingw32/ then [ 'mingw32', nil ]
74
- when /(mswin\d+)(\_(\d+))?/ then [ $1, $3 ]
93
+ when /(mswin\d+)(\_(\d+))?/ then
94
+ os, version = $1, $3
95
+ @cpu = 'x86' if @cpu.nil? and os =~ /32$/
96
+ [os, version]
75
97
  when /netbsdelf/ then [ 'netbsdelf', nil ]
76
98
  when /openbsd(\d+\.\d+)/ then [ 'openbsd', $1 ]
77
99
  when /solaris(\d+\.\d+)/ then [ 'solaris', $1 ]
@@ -155,33 +177,5 @@ class Gem::Platform
155
177
 
156
178
  CURRENT = 'current'
157
179
 
158
- ##
159
- # A One Click Installer-compatible gem, built with VC6 for 32 bit Windows.
160
- #
161
- # CURRENT is preferred over this constant, avoid its use at all costs.
162
-
163
- MSWIN32 = new ['x86', 'mswin32', '60']
164
-
165
- ##
166
- # An x86 Linux-compatible gem
167
- #
168
- # CURRENT is preferred over this constant, avoid its use at all costs.
169
-
170
- X86_LINUX = new ['x86', 'linux', nil]
171
-
172
- ##
173
- # A PowerPC Darwin-compatible gem
174
- #
175
- # CURRENT is preferred over this constant, avoid its use at all costs.
176
-
177
- PPC_DARWIN = new ['ppc', 'darwin', nil]
178
-
179
- # :stopdoc:
180
- # Here lie legacy constants. These are deprecated.
181
- WIN32 = 'mswin32'
182
- LINUX_586 = 'i586-linux'
183
- DARWIN = 'powerpc-darwin'
184
- # :startdoc:
185
-
186
180
  end
187
181
 
@@ -16,7 +16,7 @@ class Gem::RemoteFetcher
16
16
 
17
17
  # Cached RemoteFetcher instance.
18
18
  def self.fetcher
19
- @fetcher ||= new Gem.configuration[:http_proxy]
19
+ @fetcher ||= self.new Gem.configuration[:http_proxy]
20
20
  end
21
21
 
22
22
  # Initialize a remote fetcher using the source URI and possible proxy
@@ -45,8 +45,12 @@ class Gem::RemoteFetcher
45
45
  end
46
46
  rescue Timeout::Error
47
47
  raise FetchError, "timed out fetching #{uri}"
48
- rescue OpenURI::HTTPError, IOError, SocketError, SystemCallError => e
48
+ rescue IOError, SocketError, SystemCallError => e
49
49
  raise FetchError, "#{e.class}: #{e} reading #{uri}"
50
+ rescue OpenURI::HTTPError => e
51
+ body = e.io.readlines.join "\n\t"
52
+ message = "#{e.class}: #{e} reading #{uri}\n\t#{body}"
53
+ raise FetchError, message
50
54
  end
51
55
 
52
56
  # Returns the size of +uri+ in bytes.
@@ -79,7 +83,7 @@ class Gem::RemoteFetcher
79
83
  end
80
84
 
81
85
  rescue SocketError, SystemCallError, Timeout::Error => e
82
- raise FetchError, "#{e.message} (#{e.class})"
86
+ raise FetchError, "#{e.message} (#{e.class})\n\tgetting size of #{uri}"
83
87
  end
84
88
 
85
89
  private
@@ -0,0 +1,15 @@
1
+ module Gem
2
+ module RequirePathsBuilder
3
+ def write_require_paths_file_if_needed(spec = @spec, gem_home = @gem_home)
4
+ return if spec.require_paths == ["lib"] && (spec.bindir.nil? || spec.bindir == "bin")
5
+ file_name = File.join(gem_home, 'gems', "#{@spec.full_name}", ".require_paths")
6
+ file_name.untaint
7
+ File.open(file_name, "w") do |file|
8
+ spec.require_paths.each do |path|
9
+ file.puts path
10
+ end
11
+ file.puts spec.bindir if spec.bindir
12
+ end
13
+ end
14
+ end
15
+ end
@@ -2,5 +2,5 @@
2
2
  # This file is auto-generated by build scripts.
3
3
  # See: rake update_version
4
4
  module Gem
5
- RubyGemsVersion = '0.9.5'
5
+ RubyGemsVersion = '1.0.0'
6
6
  end
@@ -318,7 +318,7 @@ require 'rubygems/gem_openssl'
318
318
 
319
319
  module Gem::Security
320
320
 
321
- class Exception < Exception; end
321
+ class Exception < Gem::Exception; end
322
322
 
323
323
  #
324
324
  # default options for most of the methods below