rubygems-update 0.9.4 → 0.9.5

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.

Files changed (225) hide show
  1. data/ChangeLog +587 -0
  2. data/README +0 -1
  3. data/Rakefile +39 -12
  4. data/TODO +0 -5
  5. data/bin/gem +7 -7
  6. data/bin/update_rubygems +1 -1
  7. data/examples/application/an-app.gemspec +1 -1
  8. data/gemspecs/cgikit-1.1.0.gemspec +1 -2
  9. data/gemspecs/jabber4r.gemspec +1 -1
  10. data/gemspecs/linguistics.gemspec +1 -1
  11. data/gemspecs/ook.gemspec +1 -1
  12. data/gemspecs/progressbar.gemspec +1 -1
  13. data/gemspecs/redcloth.gemspec +1 -1
  14. data/gemspecs/rublog.gemspec +1 -1
  15. data/gemspecs/ruby-doom.gemspec +1 -1
  16. data/gemspecs/rubyjdwp.gemspec +1 -1
  17. data/gemspecs/statistics.gemspec +1 -1
  18. data/lib/rubygems.rb +167 -105
  19. data/lib/rubygems/builder.rb +12 -10
  20. data/lib/rubygems/command.rb +177 -60
  21. data/lib/rubygems/command_manager.rb +30 -38
  22. data/lib/rubygems/commands/build_command.rb +42 -46
  23. data/lib/rubygems/commands/cert_command.rb +72 -69
  24. data/lib/rubygems/commands/check_command.rb +63 -63
  25. data/lib/rubygems/commands/cleanup_command.rb +25 -7
  26. data/lib/rubygems/commands/contents_command.rb +70 -62
  27. data/lib/rubygems/commands/dependency_command.rb +131 -86
  28. data/lib/rubygems/commands/environment_command.rb +67 -46
  29. data/lib/rubygems/commands/fetch_command.rb +62 -0
  30. data/lib/rubygems/commands/generate_index_command.rb +57 -0
  31. data/lib/rubygems/commands/help_command.rb +163 -73
  32. data/lib/rubygems/commands/install_command.rb +114 -128
  33. data/lib/rubygems/commands/list_command.rb +10 -8
  34. data/lib/rubygems/commands/lock_command.rb +101 -0
  35. data/lib/rubygems/commands/mirror_command.rb +105 -0
  36. data/lib/rubygems/commands/outdated_command.rb +24 -15
  37. data/lib/rubygems/commands/pristine_command.rb +118 -88
  38. data/lib/rubygems/commands/query_command.rb +109 -77
  39. data/lib/rubygems/commands/rdoc_command.rb +13 -10
  40. data/lib/rubygems/commands/search_command.rb +10 -8
  41. data/lib/rubygems/commands/server_command.rb +48 -0
  42. data/lib/rubygems/commands/sources_command.rb +104 -83
  43. data/lib/rubygems/commands/specification_command.rb +65 -51
  44. data/lib/rubygems/commands/uninstall_command.rb +17 -12
  45. data/lib/rubygems/commands/unpack_command.rb +68 -68
  46. data/lib/rubygems/commands/update_command.rb +72 -25
  47. data/lib/rubygems/commands/which_command.rb +86 -0
  48. data/lib/rubygems/config_file.rb +202 -78
  49. data/lib/rubygems/custom_require.rb +7 -88
  50. data/lib/rubygems/dependency.rb +65 -0
  51. data/lib/rubygems/dependency_installer.rb +232 -0
  52. data/lib/rubygems/dependency_list.rb +133 -105
  53. data/lib/rubygems/digest/md5.rb +4 -1
  54. data/lib/rubygems/digest/sha2.rb +1 -1
  55. data/lib/rubygems/doc_manager.rb +41 -19
  56. data/lib/rubygems/exceptions.rb +63 -0
  57. data/lib/rubygems/ext.rb +18 -0
  58. data/lib/rubygems/ext/builder.rb +56 -0
  59. data/lib/rubygems/ext/configure_builder.rb +24 -0
  60. data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
  61. data/lib/rubygems/ext/rake_builder.rb +27 -0
  62. data/lib/rubygems/format.rb +16 -6
  63. data/lib/rubygems/gem_openssl.rb +43 -6
  64. data/lib/rubygems/gem_path_searcher.rb +84 -0
  65. data/lib/rubygems/gem_runner.rb +20 -5
  66. data/lib/rubygems/indexer.rb +163 -0
  67. data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
  68. data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
  69. data/lib/rubygems/indexer/master_index_builder.rb +53 -0
  70. data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
  71. data/lib/rubygems/install_update_options.rb +87 -0
  72. data/lib/rubygems/installer.rb +316 -562
  73. data/lib/rubygems/local_remote_options.rb +106 -0
  74. data/lib/rubygems/old_format.rb +5 -13
  75. data/lib/rubygems/open-uri.rb +2 -0
  76. data/lib/rubygems/package.rb +28 -32
  77. data/lib/rubygems/platform.rb +187 -0
  78. data/lib/rubygems/remote_fetcher.rb +46 -29
  79. data/lib/rubygems/remote_installer.rb +11 -18
  80. data/lib/rubygems/requirement.rb +157 -0
  81. data/lib/rubygems/rubygems_version.rb +1 -1
  82. data/lib/rubygems/security.rb +715 -457
  83. data/lib/rubygems/server.rb +77 -59
  84. data/lib/rubygems/source_index.rb +154 -83
  85. data/lib/rubygems/source_info_cache.rb +73 -30
  86. data/lib/rubygems/source_info_cache_entry.rb +12 -3
  87. data/lib/rubygems/specification.rb +378 -145
  88. data/lib/rubygems/uninstaller.rb +183 -0
  89. data/lib/rubygems/user_interaction.rb +38 -9
  90. data/lib/rubygems/validator.rb +53 -24
  91. data/lib/rubygems/version.rb +126 -289
  92. data/lib/rubygems/version_option.rb +49 -0
  93. data/pkgs/sources/lib/sources.rb +1 -4
  94. data/pkgs/sources/sources.gemspec +3 -3
  95. data/scripts/gemdoc.rb +0 -1
  96. data/setup.rb +166 -1505
  97. data/test/bogussources.rb +0 -1
  98. data/test/data/gem-private_key.pem +27 -0
  99. data/test/data/gem-public_cert.pem +20 -0
  100. data/test/functional.rb +3 -105
  101. data/test/gemutilities.rb +145 -24
  102. data/test/insure_session.rb +0 -1
  103. data/test/{test_datadir.rb → test_config.rb} +7 -13
  104. data/test/test_gem.rb +360 -9
  105. data/test/test_gem_builder.rb +34 -0
  106. data/test/{test_command.rb → test_gem_command.rb} +119 -62
  107. data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
  108. data/test/test_gem_commands_build_command.rb +75 -0
  109. data/test/test_gem_commands_cert_command.rb +122 -0
  110. data/test/test_gem_commands_check_command.rb +25 -0
  111. data/test/test_gem_commands_contents_command.rb +92 -0
  112. data/test/test_gem_commands_dependency_command.rb +108 -0
  113. data/test/test_gem_commands_environment_command.rb +117 -0
  114. data/test/test_gem_commands_fetch_command.rb +34 -0
  115. data/test/test_gem_commands_generate_index_command.rb +32 -0
  116. data/test/test_gem_commands_install_command.rb +160 -0
  117. data/test/test_gem_commands_mirror_command.rb +56 -0
  118. data/test/test_gem_commands_pristine_command.rb +100 -0
  119. data/test/test_gem_commands_query_command.rb +82 -0
  120. data/test/test_gem_commands_sources_command.rb +147 -0
  121. data/test/test_gem_commands_specification_command.rb +93 -0
  122. data/test/test_gem_commands_unpack_command.rb +55 -0
  123. data/test/test_gem_config_file.rb +210 -0
  124. data/test/test_gem_dependency.rb +89 -0
  125. data/test/test_gem_dependency_installer.rb +542 -0
  126. data/test/test_gem_dependency_list.rb +212 -0
  127. data/test/test_gem_doc_manager.rb +32 -0
  128. data/test/test_gem_ext_configure_builder.rb +13 -17
  129. data/test/test_gem_ext_ext_conf_builder.rb +9 -9
  130. data/test/test_gem_ext_rake_builder.rb +23 -11
  131. data/test/test_gem_format.rb +69 -0
  132. data/test/test_gem_gem_path_searcher.rb +57 -0
  133. data/test/test_gem_gem_runner.rb +35 -0
  134. data/test/test_gem_indexer.rb +119 -0
  135. data/test/test_gem_install_update_options.rb +40 -0
  136. data/test/test_gem_installer.rb +796 -0
  137. data/test/test_gem_local_remote_options.rb +84 -0
  138. data/test/test_gem_outdated_command.rb +11 -9
  139. data/test/test_gem_platform.rb +240 -0
  140. data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
  141. data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
  142. data/test/test_gem_requirement.rb +223 -0
  143. data/test/test_gem_server.rb +71 -0
  144. data/test/test_gem_source_index.rb +429 -0
  145. data/test/test_gem_source_info_cache.rb +79 -17
  146. data/test/test_gem_source_info_cache_entry.rb +11 -9
  147. data/test/test_gem_specification.rb +738 -0
  148. data/test/test_gem_stream_ui.rb +117 -0
  149. data/test/test_gem_validator.rb +70 -0
  150. data/test/test_gem_version.rb +191 -0
  151. data/test/test_gem_version_option.rb +77 -0
  152. data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
  153. data/test/test_open_uri.rb +1 -2
  154. data/test/test_package.rb +45 -34
  155. metadata +116 -141
  156. data/Releases +0 -127
  157. data/bin/gem_mirror +0 -73
  158. data/bin/gem_server +0 -6
  159. data/bin/gemlock +0 -127
  160. data/bin/gemri +0 -24
  161. data/bin/gemwhich +0 -89
  162. data/bin/index_gem_repository.rb +0 -302
  163. data/lib/gemconfigure.rb +0 -24
  164. data/lib/rubygems/gem_commands.rb +0 -273
  165. data/pkgs/sources/sources-0.0.1.gem +0 -0
  166. data/post-install.rb +0 -121
  167. data/test/brokenbuildgem.rb +0 -35
  168. data/test/data/PostMessage-0.0.1.gem +0 -0
  169. data/test/data/a-0.0.1.gem +0 -0
  170. data/test/data/a-0.0.2.gem +0 -0
  171. data/test/data/b-0.0.2.gem +0 -0
  172. data/test/data/broken-1.0.0.gem +0 -0
  173. data/test/data/broken_build/broken-build.gemspec +0 -20
  174. data/test/data/broken_build/ext/extconf.rb +0 -3
  175. data/test/data/broken_build/ext/foo.c +0 -1
  176. data/test/data/c-1.2.gem +0 -0
  177. data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
  178. data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
  179. data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
  180. data/test/data/gemhome/cache/c-1.2.gem +0 -0
  181. data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
  182. data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
  183. data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
  184. data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
  185. data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
  186. data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
  187. data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
  188. data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
  189. data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
  190. data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
  191. data/test/data/lib/code.rb +0 -1
  192. data/test/data/one/README.one +0 -1
  193. data/test/data/one/lib/one.rb +0 -9
  194. data/test/data/one/one-0.0.1.gem +0 -0
  195. data/test/data/one/one.gemspec +0 -17
  196. data/test/data/one/one.yaml +0 -40
  197. data/test/data/post_install.gemspec +0 -19
  198. data/test/functional_extension_gems.rb +0 -48
  199. data/test/functional_generate_yaml_index.rb +0 -104
  200. data/test/gemenvironment.rb +0 -59
  201. data/test/io_capture.rb +0 -33
  202. data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
  203. data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
  204. data/test/onegem.rb +0 -35
  205. data/test/test_builder.rb +0 -34
  206. data/test/test_check_command.rb +0 -34
  207. data/test/test_configfile.rb +0 -42
  208. data/test/test_dependency_list.rb +0 -169
  209. data/test/test_file_list.rb +0 -101
  210. data/test/test_format.rb +0 -49
  211. data/test/test_gem_sources_command.rb +0 -135
  212. data/test/test_gemloadpaths.rb +0 -51
  213. data/test/test_gempaths.rb +0 -170
  214. data/test/test_installer.rb +0 -369
  215. data/test/test_loadmanager.rb +0 -48
  216. data/test/test_process_commands.rb +0 -52
  217. data/test/test_source_index.rb +0 -231
  218. data/test/test_specific_extras.rb +0 -46
  219. data/test/test_specification.rb +0 -565
  220. data/test/test_user_interaction.rb +0 -48
  221. data/test/test_validator.rb +0 -59
  222. data/test/test_version_comparison.rb +0 -321
  223. data/test/testgem.rc +0 -7
  224. data/test/user_capture.rb +0 -7
  225. data/test/yaml_data.rb +0 -63
@@ -7,6 +7,7 @@
7
7
 
8
8
  require 'digest/md5'
9
9
 
10
+ # :stopdoc:
10
11
  module Gem
11
12
  if RUBY_VERSION >= '1.8.6'
12
13
  MD5 = Digest::MD5
@@ -17,4 +18,6 @@ module Gem
17
18
  self.hexdigest(string)
18
19
  end
19
20
  end
20
- end
21
+ end
22
+ # :startdoc:
23
+
@@ -14,4 +14,4 @@ module Gem
14
14
  require 'rubygems/digest/digest_adapter'
15
15
  SHA256 = DigestAdapter.new(Digest::SHA256)
16
16
  end
17
- end
17
+ end
@@ -4,10 +4,10 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
+ require 'fileutils'
8
+
7
9
  module Gem
8
10
 
9
- class DocumentError < Gem::Exception; end
10
-
11
11
  class DocManager
12
12
 
13
13
  include UserInteraction
@@ -20,7 +20,6 @@ module Gem
20
20
  def initialize(spec, rdoc_args="")
21
21
  @spec = spec
22
22
  @doc_dir = File.join(spec.installation_path, "doc", spec.full_name)
23
- Gem::FilePermissionError.new(spec.installation_path) unless File.writable?(spec.installation_path)
24
23
  @rdoc_args = rdoc_args.nil? ? [] : rdoc_args.split
25
24
  end
26
25
 
@@ -35,8 +34,6 @@ module Gem
35
34
  # same process, the RI docs should be done first (a likely bug in
36
35
  # RDoc will cause RI docs generation to fail if run after RDoc).
37
36
  def generate_ri
38
- require 'fileutils'
39
-
40
37
  if @spec.has_rdoc then
41
38
  load_rdoc
42
39
  install_ri # RDoc bug, ri goes first
@@ -51,8 +48,6 @@ module Gem
51
48
  # same process, the RI docs should be done first (a likely bug in
52
49
  # RDoc will cause RI docs generation to fail if run after RDoc).
53
50
  def generate_rdoc
54
- require 'fileutils'
55
-
56
51
  if @spec.has_rdoc then
57
52
  load_rdoc
58
53
  install_rdoc
@@ -63,26 +58,36 @@ module Gem
63
58
 
64
59
  # Load the RDoc documentation generator library.
65
60
  def load_rdoc
66
- if File.exist?(@doc_dir) && !File.writable?(@doc_dir)
67
- Gem::FilePermissionError.new(@doc_dir)
61
+ if File.exist?(@doc_dir) && !File.writable?(@doc_dir) then
62
+ raise Gem::FilePermissionError.new(@doc_dir)
68
63
  end
64
+
69
65
  FileUtils.mkdir_p @doc_dir unless File.exist?(@doc_dir)
66
+
70
67
  begin
71
68
  require 'rdoc/rdoc'
72
69
  rescue LoadError => e
73
- raise DocumentError,
70
+ raise Gem::DocumentError,
74
71
  "ERROR: RDoc documentation generator not installed!"
75
72
  end
76
73
  end
77
74
 
78
75
  def install_rdoc
76
+ rdoc_dir = File.join @doc_dir, 'rdoc'
77
+
78
+ FileUtils.rm_rf rdoc_dir
79
+
79
80
  say "Installing RDoc documentation for #{@spec.full_name}..."
80
- run_rdoc '--op', File.join(@doc_dir, 'rdoc')
81
+ run_rdoc '--op', rdoc_dir
81
82
  end
82
83
 
83
84
  def install_ri
85
+ ri_dir = File.join @doc_dir, 'ri'
86
+
87
+ FileUtils.rm_rf ri_dir
88
+
84
89
  say "Installing ri documentation for #{@spec.full_name}..."
85
- run_rdoc '--ri', '--op', File.join(@doc_dir, 'ri')
90
+ run_rdoc '--ri', '--op', ri_dir
86
91
  end
87
92
 
88
93
  def run_rdoc(*args)
@@ -103,20 +108,37 @@ module Gem
103
108
  dirname = File.dirname e.message.split("-")[1].strip
104
109
  raise Gem::FilePermissionError.new(dirname)
105
110
  rescue RuntimeError => ex
106
- STDERR.puts "While generating documentation for #{@spec.full_name}"
107
- STDERR.puts "... MESSAGE: #{ex}"
108
- STDERR.puts "... RDOC args: #{args.join(' ')}"
109
- STDERR.puts ex.backtrace if Gem.configuration.backtrace
110
- STDERR.puts "(continuing with the rest of the installation)"
111
+ alert_error "While generating documentation for #{@spec.full_name}"
112
+ ui.errs.puts "... MESSAGE: #{ex}"
113
+ ui.errs.puts "... RDOC args: #{args.join(' ')}"
114
+ ui.errs.puts "\t#{ex.backtrace.join "\n\t"}" if
115
+ Gem.configuration.backtrace
116
+ ui.errs.puts "(continuing with the rest of the installation)"
111
117
  ensure
112
118
  Dir.chdir(old_pwd)
113
119
  end
114
120
  end
115
121
 
116
122
  def uninstall_doc
117
- doc_dir = File.join(@spec.installation_path, "doc", @spec.full_name)
123
+ raise Gem::FilePermissionError.new(@spec.installation_path) unless
124
+ File.writable? @spec.installation_path
125
+
126
+ original_name = [
127
+ @spec.name, @spec.version, @spec.original_platform].join '-'
128
+
129
+ doc_dir = File.join @spec.installation_path, 'doc', @spec.full_name
130
+ unless File.directory? doc_dir then
131
+ doc_dir = File.join @spec.installation_path, 'doc', original_name
132
+ end
133
+
118
134
  FileUtils.rm_rf doc_dir
119
- ri_dir = File.join(@spec.installation_path, "ri", @spec.full_name)
135
+
136
+ ri_dir = File.join @spec.installation_path, 'ri', @spec.full_name
137
+
138
+ unless File.directory? ri_dir then
139
+ ri_dir = File.join @spec.installation_path, 'ri', original_name
140
+ end
141
+
120
142
  FileUtils.rm_rf ri_dir
121
143
  end
122
144
 
@@ -0,0 +1,63 @@
1
+ require 'rubygems'
2
+
3
+ ##
4
+ # Base exception class for RubyGems. All exception raised by RubyGems are a
5
+ # subclass of this one.
6
+ class Gem::Exception < RuntimeError; end
7
+
8
+ class Gem::CommandLineError < Gem::Exception; end
9
+
10
+ class Gem::DependencyError < Gem::Exception; end
11
+
12
+ class Gem::DependencyRemovalException < Gem::Exception; end
13
+
14
+ class Gem::DocumentError < Gem::Exception; end
15
+
16
+ ##
17
+ # Potentially raised when a specification is validated.
18
+ class Gem::EndOfYAMLException < Gem::Exception; end
19
+
20
+ ##
21
+ # Signals that a file permission error is preventing the user from
22
+ # installing in the requested directories.
23
+ class Gem::FilePermissionError < Gem::Exception
24
+ def initialize(path)
25
+ super("You don't have write permissions into the #{path} directory.")
26
+ end
27
+ end
28
+
29
+ ##
30
+ # Used to raise parsing and loading errors
31
+ class Gem::FormatException < Gem::Exception
32
+ attr_accessor :file_path
33
+ end
34
+
35
+ class Gem::GemNotFoundException < Gem::Exception; end
36
+
37
+ class Gem::InstallError < Gem::Exception; end
38
+
39
+ ##
40
+ # Potentially raised when a specification is validated.
41
+ class Gem::InvalidSpecificationException < Gem::Exception; end
42
+
43
+ class Gem::OperationNotSupportedError < Gem::Exception; end
44
+
45
+ ##
46
+ # Signals that a remote operation cannot be conducted, probably due to not
47
+ # being connected (or just not finding host).
48
+ #--
49
+ # TODO: create a method that tests connection to the preferred gems server.
50
+ # All code dealing with remote operations will want this. Failure in that
51
+ # method should raise this error.
52
+ class Gem::RemoteError < Gem::Exception; end
53
+
54
+ class Gem::RemoteInstallationCancelled < Gem::Exception; end
55
+
56
+ class Gem::RemoteInstallationSkipped < Gem::Exception; end
57
+
58
+ ##
59
+ # Represents an error communicating via HTTP.
60
+ class Gem::RemoteSourceException < Gem::Exception; end
61
+
62
+ class Gem::VerificationError < Gem::Exception; end
63
+
@@ -0,0 +1,18 @@
1
+ #--
2
+ # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
+ # All rights reserved.
4
+ # See LICENSE.txt for permissions.
5
+ #++
6
+
7
+ require 'rubygems'
8
+
9
+ ##
10
+ # Classes for building C extensions live here.
11
+
12
+ module Gem::Ext; end
13
+
14
+ require 'rubygems/ext/builder'
15
+ require 'rubygems/ext/configure_builder'
16
+ require 'rubygems/ext/ext_conf_builder'
17
+ require 'rubygems/ext/rake_builder'
18
+
@@ -0,0 +1,56 @@
1
+ #--
2
+ # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
+ # All rights reserved.
4
+ # See LICENSE.txt for permissions.
5
+ #++
6
+
7
+ require 'rubygems/ext'
8
+
9
+ class Gem::Ext::Builder
10
+
11
+ def self.class_name
12
+ name =~ /Ext::(.*)Builder/
13
+ $1.downcase
14
+ end
15
+
16
+ def self.make(dest_path, results)
17
+ unless File.exist? 'Makefile' then
18
+ raise Gem::InstallError, "Makefile not found:\n\n#{results.join "\n"}"
19
+ end
20
+
21
+ mf = File.read('Makefile')
22
+ mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
23
+ mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}")
24
+
25
+ File.open('Makefile', 'wb') {|f| f.print mf}
26
+
27
+ make_program = ENV['make']
28
+ unless make_program then
29
+ make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
30
+ end
31
+
32
+ ['', ' install'].each do |target|
33
+ cmd = "#{make_program}#{target}"
34
+ results << cmd
35
+ results << `#{cmd} #{redirector}`
36
+
37
+ raise Gem::InstallError, "make#{target} failed:\n\n#{results}" unless
38
+ $?.exitstatus.zero?
39
+ end
40
+ end
41
+
42
+ def self.redirector
43
+ '2>&1'
44
+ end
45
+
46
+ def self.run(command, results)
47
+ results << command
48
+ results << `#{command} #{redirector}`
49
+
50
+ unless $?.exitstatus.zero? then
51
+ raise Gem::InstallError, "#{class_name} failed:\n\n#{results.join "\n"}"
52
+ end
53
+ end
54
+
55
+ end
56
+
@@ -0,0 +1,24 @@
1
+ #--
2
+ # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
+ # All rights reserved.
4
+ # See LICENSE.txt for permissions.
5
+ #++
6
+
7
+ require 'rubygems/ext/builder'
8
+
9
+ class Gem::Ext::ConfigureBuilder < Gem::Ext::Builder
10
+
11
+ def self.build(extension, directory, dest_path, results)
12
+ unless File.exist?('Makefile') then
13
+ cmd = "sh ./configure --prefix=#{dest_path}"
14
+
15
+ run cmd, results
16
+ end
17
+
18
+ make dest_path, results
19
+
20
+ results
21
+ end
22
+
23
+ end
24
+
@@ -0,0 +1,23 @@
1
+ #--
2
+ # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
+ # All rights reserved.
4
+ # See LICENSE.txt for permissions.
5
+ #++
6
+
7
+ require 'rubygems/ext/builder'
8
+
9
+ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
10
+
11
+ def self.build(extension, directory, dest_path, results)
12
+ cmd = "#{Gem.ruby} #{File.basename extension}"
13
+ cmd << " #{ARGV.join ' '}" unless ARGV.empty?
14
+
15
+ run cmd, results
16
+
17
+ make dest_path, results
18
+
19
+ results
20
+ end
21
+
22
+ end
23
+
@@ -0,0 +1,27 @@
1
+ #--
2
+ # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
+ # All rights reserved.
4
+ # See LICENSE.txt for permissions.
5
+ #++
6
+
7
+ require 'rubygems/ext/builder'
8
+
9
+ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
10
+
11
+ def self.build(extension, directory, dest_path, results)
12
+ if File.basename(extension) =~ /mkrf_conf/i then
13
+ cmd = "#{Gem.ruby} #{File.basename extension}"
14
+ cmd << " #{ARGV.join " "}" unless ARGV.empty?
15
+ run cmd, results
16
+ end
17
+
18
+ cmd = ENV['rake'] || 'rake'
19
+ cmd << " RUBYARCHDIR=#{dest_path} RUBYLIBDIR=#{dest_path}"
20
+
21
+ run cmd, results
22
+
23
+ results
24
+ end
25
+
26
+ end
27
+
@@ -4,6 +4,8 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
+ require 'fileutils'
8
+
7
9
  require 'rubygems/package'
8
10
 
9
11
  module Gem
@@ -33,19 +35,27 @@ module Gem
33
35
  # file_path:: [String] Path to the gem file
34
36
  #
35
37
  def self.from_file_by_path(file_path, security_policy = nil)
38
+ format = nil
39
+
36
40
  unless File.exist?(file_path)
37
41
  raise Gem::Exception, "Cannot load gem at [#{file_path}] in #{Dir.pwd}"
38
42
  end
39
- require 'fileutils'
43
+
40
44
  # check for old version gem
41
45
  if File.read(file_path, 20).include?("MD5SUM =")
42
46
  #alert_warning "Gem #{file_path} is in old format."
43
47
  require 'rubygems/old_format'
44
- return OldFormat.from_file_by_path(file_path)
48
+ format = OldFormat.from_file_by_path(file_path)
45
49
  else
46
- f = File.open(file_path, 'rb')
47
- return from_io(f, file_path, security_policy)
50
+ begin
51
+ f = File.open(file_path, 'rb')
52
+ format = from_io(f, file_path, security_policy)
53
+ ensure
54
+ f.close unless f.closed?
55
+ end
48
56
  end
57
+
58
+ return format
49
59
  end
50
60
 
51
61
  ##
@@ -60,8 +70,8 @@ module Gem
60
70
  format.spec = pkg.metadata
61
71
  format.file_entries = []
62
72
  pkg.each do |entry|
63
- format.file_entries << [{"size", entry.size, "mode", entry.mode,
64
- "path", entry.full_name}, entry.read]
73
+ format.file_entries << [{"size" => entry.size, "mode" => entry.mode,
74
+ "path" => entry.full_name}, entry.read]
65
75
  end
66
76
  end
67
77
  format
@@ -4,7 +4,6 @@
4
4
  # See LICENSE.txt for permissions.
5
5
  #++
6
6
 
7
-
8
7
  # Some system might not have OpenSSL installed, therefore the core
9
8
  # library file openssl might not be available. We localize testing
10
9
  # for the presence of OpenSSL in this file.
@@ -17,10 +16,10 @@ module Gem
17
16
  require 'rubygems/gem_openssl'
18
17
  @ssl_available
19
18
  end
20
-
19
+
21
20
  # Set the value of the ssl_avilable flag.
22
21
  attr_writer :ssl_available
23
-
22
+
24
23
  # Ensure that SSL is available. Throw an exception if it is not.
25
24
  def ensure_ssl_available
26
25
  unless ssl_available?
@@ -39,8 +38,46 @@ begin
39
38
  dummy = OpenSSL::Digest::SHA1
40
39
 
41
40
  Gem.ssl_available = true
42
- rescue LoadError
43
- Gem.ssl_available = false
44
- rescue
41
+
42
+ class OpenSSL::X509::Certificate # :nodoc:
43
+ # Check the validity of this certificate.
44
+ def check_validity(issuer_cert = nil, time = Time.now)
45
+ ret = if @not_before && @not_before > time
46
+ [false, :expired, "not valid before '#@not_before'"]
47
+ elsif @not_after && @not_after < time
48
+ [false, :expired, "not valid after '#@not_after'"]
49
+ elsif issuer_cert && !verify(issuer_cert.public_key)
50
+ [false, :issuer, "#{issuer_cert.subject} is not issuer"]
51
+ else
52
+ [true, :ok, 'Valid certificate']
53
+ end
54
+
55
+ # return hash
56
+ { :is_valid => ret[0], :error => ret[1], :desc => ret[2] }
57
+ end
58
+ end
59
+
60
+ rescue LoadError, StandardError
45
61
  Gem.ssl_available = false
46
62
  end
63
+
64
+ module Gem::SSL
65
+
66
+ # We make our own versions of the constants here. This allows us
67
+ # to reference the constants, even though some systems might not
68
+ # have SSL installed in the Ruby core package.
69
+ #
70
+ # These constants are only used during load time. At runtime, any
71
+ # method that makes a direct reference to SSL software must be
72
+ # protected with a Gem.ensure_ssl_available call.
73
+ #
74
+ if Gem.ssl_available? then
75
+ PKEY_RSA = OpenSSL::PKey::RSA
76
+ DIGEST_SHA1 = OpenSSL::Digest::SHA1
77
+ else
78
+ PKEY_RSA = :rsa
79
+ DIGEST_SHA1 = :sha1
80
+ end
81
+
82
+ end
83
+