<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,17 @@
 # -*- coding: utf-8 -*-
 
+2009-06-03  Eric Hodel  &lt;drbrain@segment7.net&gt;
+
+	* bin/gem:  Support 1.8.6+
+	* lib/rubygems/digest*:  Removed, support dropped for Ruby &lt; 1.8.6
+	* lib/rubygems/installer.rb:  Support env(1) in wrong path, use
+	  /bin/sh if shebang has options.  By Nobu, ruby trunk r22853.
+	* lib/rubygems/config_file.rb:  Switch to stdcall for appdata folder.
+	  [ruby-core:22601].
+	* lib/rubygems.rb:  Use only File::expand_path on 1.9 for home dir.
+	  Don't recklessly create directories.  Simplify RbConfig::datadir
+	  definition.
+
 2009-05-30  Eric Hodel  &lt;drbrain@segment7.net&gt;
 
 	* lib/rubygems/rubygems_version.rb:  1.3.4.</diff>
      <filename>ChangeLog</filename>
    </modified>
    <modified>
      <diff>@@ -79,10 +79,6 @@ lib/rubygems/defaults.rb
 lib/rubygems/dependency.rb
 lib/rubygems/dependency_installer.rb
 lib/rubygems/dependency_list.rb
-lib/rubygems/digest/digest_adapter.rb
-lib/rubygems/digest/md5.rb
-lib/rubygems/digest/sha1.rb
-lib/rubygems/digest/sha2.rb
 lib/rubygems/doc_manager.rb
 lib/rubygems/exceptions.rb
 lib/rubygems/ext.rb
@@ -178,7 +174,6 @@ test/test_gem_config_file.rb
 test/test_gem_dependency.rb
 test/test_gem_dependency_installer.rb
 test/test_gem_dependency_list.rb
-test/test_gem_digest.rb
 test/test_gem_doc_manager.rb
 test/test_gem_ext_configure_builder.rb
 test/test_gem_ext_ext_conf_builder.rb</diff>
      <filename>Manifest.txt</filename>
    </modified>
    <modified>
      <diff>@@ -9,10 +9,10 @@ require 'rubygems'
 require 'rubygems/gem_runner'
 require 'rubygems/exceptions'
 
-required_version = Gem::Requirement.new &quot;&gt; 1.8.3&quot;
+required_version = Gem::Requirement.new &quot;&gt;= 1.8.6&quot;
 
 unless required_version.satisfied_by? Gem.ruby_version then
-  abort &quot;Expected Ruby Version #{required_version}, was #{Gem.ruby_version}&quot;
+  abort &quot;Expected Ruby Version #{required_version}, is #{Gem.ruby_version}&quot;
 end
 
 args = ARGV.clone</diff>
      <filename>bin/gem</filename>
    </modified>
    <modified>
      <diff>@@ -545,22 +545,22 @@ module Gem
   #   least on Win32).
 
   def self.find_home
-    ['HOME', 'USERPROFILE'].each do |homekey|
-      return ENV[homekey] if ENV[homekey]
-    end
+    unless RUBY_VERSION &gt; '1.9' then
+      ['HOME', 'USERPROFILE'].each do |homekey|
+        return ENV[homekey] if ENV[homekey]
+      end
 
-    if ENV['HOMEDRIVE'] &amp;&amp; ENV['HOMEPATH'] then
-      return &quot;#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}&quot;
+      if ENV['HOMEDRIVE'] &amp;&amp; ENV['HOMEPATH'] then
+        return &quot;#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}&quot;
+      end
     end
 
-    begin
-      File.expand_path(&quot;~&quot;)
-    rescue
-      if File::ALT_SEPARATOR then
-          &quot;C:/&quot;
-      else
-          &quot;/&quot;
-      end
+    File.expand_path &quot;~&quot;
+  rescue
+    if File::ALT_SEPARATOR then
+      &quot;C:/&quot;
+    else
+      &quot;/&quot;
     end
   end
 
@@ -893,9 +893,8 @@ module Gem
   # Set the Gem home directory (as reported by Gem.dir).
 
   def self.set_home(home)
-    home = home.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
+    home = home.gsub File::ALT_SEPARATOR, File::SEPARATOR if File::ALT_SEPARATOR
     @gem_home = home
-    ensure_gem_subdirectories(@gem_home)
   end
 
   private_class_method :set_home
@@ -920,18 +919,6 @@ module Gem
     end
 
     @gem_path.uniq!
-    @gem_path.each do |path|
-      if 0 == File.expand_path(path).index(Gem.user_home)
-        next unless File.directory? Gem.user_home
-        unless win_platform? then
-          # only create by matching user
-          if Etc.getpwuid.nil? || Etc.getpwuid.uid != File::Stat.new(Gem.user_home).uid
-            next
-          end
-        end
-      end
-      ensure_gem_subdirectories path
-    end
   end
 
   private_class_method :set_paths
@@ -1084,19 +1071,15 @@ module Gem
 
 end
 
-module Config
-  # :stopdoc:
-  class &lt;&lt; self
-    # Return the path to the data directory associated with the named
-    # package.  If the package is loaded as a gem, return the gem
-    # specific data directory.  Otherwise return a path to the share
-    # area as define by &quot;#{ConfigMap[:datadir]}/#{package_name}&quot;.
-    def datadir(package_name)
-      Gem.datadir(package_name) ||
-        File.join(Gem::ConfigMap[:datadir], package_name)
-    end
-  end
-  # :startdoc:
+##
+# Return the path to the data directory associated with the named package.  If
+# the package is loaded as a gem, return the gem specific data directory.
+# Otherwise return a path to the share area as define by
+# &quot;#{ConfigMap[:datadir]}/#{package_name}&quot;.
+
+def RbConfig.datadir(package_name)
+  Gem.datadir(package_name) ||
+    File.join(Gem::ConfigMap[:datadir], package_name)
 end
 
 require 'rubygems/exceptions'</diff>
      <filename>lib/rubygems.rb</filename>
    </modified>
    <modified>
      <diff>@@ -57,10 +57,10 @@ class Gem::Commands::SetupCommand &lt; Gem::Command
   end
 
   def check_ruby_version
-    required_version = Gem::Version.new '1.8.3'
+    required_version = Gem::Requirement.new '&gt;= 1.8.6'
 
-    unless Gem.ruby_version &gt; required_version then
-      alert_error &quot;Ruby version &gt; #{required_version} required, is #{Gem.ruby_version}&quot;
+    unless required_version.satisfied_by? Gem.ruby_version then
+      alert_error &quot;Expected Ruby version #{required_version}, is #{Gem.ruby_version}&quot;
       terminate_interaction 1
     end
   end</diff>
      <filename>lib/rubygems/commands/setup_command.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,14 +29,15 @@ class Gem::ConfigFile
 
   PLATFORM_DEFAULTS = {}
 
-  system_config_path = 
+  system_config_path =
     begin
       require 'Win32API'
 
       CSIDL_COMMON_APPDATA = 0x0023
       path = 0.chr * 260
-      SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP', 'L'
-      SHGetFolderPath.call 0, CSIDL_COMMON_APPDATA, 0, 1, path
+      SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'PLPLP', 'L',
+                                     :stdcall
+      SHGetFolderPath.call nil, CSIDL_COMMON_APPDATA, nil, 1, path
 
       path.strip
     rescue LoadError
@@ -44,7 +45,7 @@ class Gem::ConfigFile
     end
 
   SYSTEM_WIDE_CONFIG_FILE = File.join system_config_path, 'gemrc'
-  
+
   # List of arguments supplied to the config file object.
   attr_reader :args
 </diff>
      <filename>lib/rubygems/config_file.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,6 +29,12 @@ require 'rubygems/require_paths_builder'
 class Gem::Installer
 
   ##
+  # Paths where env(1) might live.  Some systems are broken and have it in
+  # /bin
+
+  ENV_PATHS = %w[/usr/bin/env /bin/env]
+
+  ##
   # Raised when there is an error while building extensions.
   #
   class ExtensionBuildError &lt; Gem::InstallError; end
@@ -392,23 +398,25 @@ class Gem::Installer
   # necessary.
 
   def shebang(bin_file_name)
-    if @env_shebang then
-      &quot;#!/usr/bin/env &quot; + Gem::ConfigMap[:ruby_install_name]
-    else
-      path = File.join @gem_dir, @spec.bindir, bin_file_name
-
-      File.open(path, &quot;rb&quot;) do |file|
-        first_line = file.gets
-        if first_line =~ /^#!/ then
-          # Preserve extra words on shebang line, like &quot;-w&quot;.  Thanks RPA.
-          shebang = first_line.sub(/\A\#!.*?ruby\S*/, &quot;#!#{Gem.ruby}&quot;)
-        else
-          # Create a plain shebang line.
-          shebang = &quot;#!#{Gem.ruby}&quot;
-        end
+    ruby_name = Gem::ConfigMap[:ruby_install_name] if @env_shebang
+    path = File.join @gem_dir, @spec.bindir, bin_file_name
+    first_line = File.open(path, &quot;rb&quot;) {|file| file.gets}
+
+    if /\A#!/ =~ first_line then
+      # Preserve extra words on shebang line, like &quot;-w&quot;.  Thanks RPA.
+      shebang = first_line.sub(/\A\#!.*?ruby\S*(?=(\s+\S+))/, &quot;#!#{Gem.ruby}&quot;)
+      opts = $1
+      shebang.strip! # Avoid nasty ^M issues.
+    end
 
-        shebang.strip # Avoid nasty ^M issues.
-      end
+    if not ruby_name then
+      &quot;#!#{Gem.ruby}#{opts}&quot;
+    elsif opts then
+      &quot;#!/bin/sh\n'exec' #{ruby_name.dump} '-x' \&quot;$0\&quot; \&quot;$@\&quot;\n#{shebang}&quot;
+    else
+      # Create a plain shebang line.
+      @env_path ||= ENV_PATHS.find {|env_path| File.executable? env_path }
+      &quot;#!#{@env_path} #{ruby_name}&quot;
     end
   end
 </diff>
      <filename>lib/rubygems/installer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -101,10 +101,9 @@ module Gem::LocalRemoteOptions
   end
 
   ##
-  # Add the --update-source option
+  # Add the --update-sources option
 
   def add_update_sources_option
-
     add_option(:&quot;Local/Remote&quot;, '-u', '--[no-]update-sources',
                'Update local source cache') do |value, options|
       Gem.configuration.update_sources = value</diff>
      <filename>lib/rubygems/local_remote_options.rb</filename>
    </modified>
    <modified>
      <diff>@@ -247,18 +247,18 @@ class Gem::SourceIndex
   # change in the index.
 
   def index_signature
-    require 'rubygems/digest/sha2'
+    require 'digest'
 
-    Gem::SHA256.new.hexdigest(@gems.keys.sort.join(',')).to_s
+    Digest::SHA256.new.hexdigest(@gems.keys.sort.join(',')).to_s
   end
 
   ##
   # The signature for the given gem specification.
 
   def gem_signature(gem_full_name)
-    require 'rubygems/digest/sha2'
+    require 'digest'
 
-    Gem::SHA256.new.hexdigest(@gems[gem_full_name].to_yaml).to_s
+    Digest::SHA256.new.hexdigest(@gems[gem_full_name].to_yaml).to_s
   end
 
   def size</diff>
      <filename>lib/rubygems/source_index.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@
 
 require 'find'
 
-require 'rubygems/digest/md5'
+require 'digest'
 require 'rubygems/format'
 require 'rubygems/installer'
 
@@ -40,7 +40,7 @@ class Gem::Validator
     sum_data = gem_data.gsub(/MD5SUM = &quot;([a-z0-9]+)&quot;/,
                              &quot;MD5SUM = \&quot;#{&quot;F&quot; * 32}\&quot;&quot;)
 
-    unless Gem::MD5.hexdigest(sum_data) == $1.to_s then
+    unless Digest::MD5.hexdigest(sum_data) == $1.to_s then
       raise Gem::VerificationError, 'invalid checksum for gem file'
     end
   end
@@ -139,8 +139,8 @@ class Gem::Validator
               next unless data # HACK `gem check -a mkrf`
 
               open File.join(gem_directory, entry['path']), Gem.binary_mode do |f|
-                unless Gem::MD5.hexdigest(f.read).to_s ==
-                    Gem::MD5.hexdigest(data).to_s then
+                unless Digest::MD5.hexdigest(f.read).to_s ==
+                    Digest::MD5.hexdigest(data).to_s then
                   errors[gem_name][entry['path']] = &quot;Modified from original&quot;
                 end
               end</diff>
      <filename>lib/rubygems/validator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -75,6 +75,8 @@ class RubyGemTestCase &lt; MiniTest::Unit::TestCase
     @latest_usrcache = File.join(@gemhome, &quot;.gem&quot;, &quot;latest_user_cache&quot;)
     @userhome = File.join @tempdir, 'userhome'
 
+    Gem.ensure_gem_subdirectories @gemhome
+
     @orig_ENV_HOME = ENV['HOME']
     ENV['HOME'] = @userhome
     Gem.instance_variable_set :@user_home, nil</diff>
      <filename>test/gemutilities.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,8 +11,8 @@ require 'rubygems'
 class TestConfig &lt; RubyGemTestCase
 
   def test_datadir
-    datadir = Config::CONFIG['datadir']
-    assert_equal &quot;#{datadir}/xyz&quot;, Config.datadir('xyz')
+    datadir = RbConfig::CONFIG['datadir']
+    assert_equal &quot;#{datadir}/xyz&quot;, RbConfig.datadir('xyz')
   end
 
 end</diff>
      <filename>test/test_config.rb</filename>
    </modified>
    <modified>
      <diff>@@ -103,7 +103,7 @@ class TestGem &lt; RubyGemTestCase
     bindir = if defined?(RUBY_FRAMEWORK_VERSION) then
                '/usr/bin'
              else
-               Config::CONFIG['bindir']
+               RbConfig::CONFIG['bindir']
              end
 
     assert_equal bindir, Gem.bindir(default)
@@ -194,11 +194,6 @@ class TestGem &lt; RubyGemTestCase
 
   def test_self_dir
     assert_equal @gemhome, Gem.dir
-
-    Gem::DIRECTORIES.each do |filename|
-      assert File.directory?(File.join(Gem.dir, filename)),
-             &quot;expected #{filename} to exist&quot;
-    end
   end
 
   def test_self_ensure_gem_directories
@@ -546,11 +541,11 @@ class TestGem &lt; RubyGemTestCase
     path = [@userhome, other].join File::PATH_SEPARATOR
     Gem.send :set_paths, path
 
-    assert File.exist?(File.join(@userhome, 'gems'))
-    assert File.exist?(File.join(other, 'gems'))
+    assert_equal [@userhome, other, @gemhome], Gem.path
   end
 
   def test_self_set_paths_nonexistent_home
+    ENV['GEM_HOME'] = @gemhome
     Gem.clear_paths
 
     other = File.join @tempdir, 'other'
@@ -559,7 +554,7 @@ class TestGem &lt; RubyGemTestCase
 
     Gem.send :set_paths, other
 
-    refute File.exist?(File.join(other, 'gems'))
+    assert_equal [other, @gemhome], Gem.path
   end
 
   def test_self_source_index
@@ -624,7 +619,7 @@ class TestGem &lt; RubyGemTestCase
     ENV['USERPROFILE'] = orig_user_profile
     ENV['USERDRIVE'] = orig_user_drive
     ENV['USERPATH'] = orig_user_path
-  end
+  end if '1.9' &gt; RUBY_VERSION
 
   def util_ensure_gem_dirs
     Gem.ensure_gem_subdirectories @gemhome</diff>
      <filename>test/test_gem.rb</filename>
    </modified>
    <modified>
      <diff>@@ -211,7 +211,9 @@ class TestGemCommandsInstallCommand &lt; RubyGemTestCase
 
     use_ui @ui do
       e = assert_raises Gem::SystemExitException do
-        @cmd.execute
+        capture_io do
+          @cmd.execute
+        end
       end
       assert_equal 0, e.exit_code
     end</diff>
      <filename>test/test_gem_commands_install_command.rb</filename>
    </modified>
    <modified>
      <diff>@@ -259,7 +259,7 @@ class TestGemDependencyInstaller &lt; RubyGemTestCase
       inst.install 'a'
     end
 
-    assert_match %r|\A#!/usr/bin/env #{Gem::ConfigMap[:ruby_install_name]}\n|,
+    assert_match %r|\A#!/\S+/env #{Gem::ConfigMap[:ruby_install_name]}\n|,
                  File.read(File.join(@gemhome, 'bin', 'a_bin'))
   end
 </diff>
      <filename>test/test_gem_dependency_installer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -46,7 +46,7 @@ class TestGemExtConfigureBuilder &lt; RubyGemTestCase
       end
     end
 
-    shell_error_msg = %r{(\./configure: .*)|(Can't open \./configure)}
+    shell_error_msg = %r{(\./configure: .*)|(Can't open \./configure(?:: No such file or directory)?)}
     sh_prefix_configure = &quot;sh ./configure --prefix=&quot;
 
     expected = %r(configure failed:</diff>
      <filename>test/test_gem_ext_configure_builder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -516,7 +516,7 @@ load Gem.bin_path('a', 'my_exec', version)
 
     @installer.generate_bin
 
-    default_shebang = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
+    default_shebang = Gem.ruby
     shebang_line = open(&quot;#{@gemhome}/bin/my_exec&quot;) { |f| f.readlines.first }
     assert_match(/\A#!/, shebang_line)
     assert_match(/#{default_shebang}/, shebang_line)</diff>
      <filename>test/test_gem_installer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -100,8 +100,8 @@ class TestGemPlatform &lt; RubyGemTestCase
   end
 
   def test_initialize_mswin32_vc6
-    orig_RUBY_SO_NAME = Config::CONFIG['RUBY_SO_NAME']
-    Config::CONFIG['RUBY_SO_NAME'] = 'msvcrt-ruby18'
+    orig_RUBY_SO_NAME = RbConfig::CONFIG['RUBY_SO_NAME']
+    RbConfig::CONFIG['RUBY_SO_NAME'] = 'msvcrt-ruby18'
 
     expected = ['x86', 'mswin32', nil]
 
@@ -109,7 +109,7 @@ class TestGemPlatform &lt; RubyGemTestCase
 
     assert_equal expected, platform.to_a, 'i386-mswin32 VC6'
   ensure
-    Config::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME
+    RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME
   end
 
   def test_initialize_platform</diff>
      <filename>test/test_gem_platform.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/rubygems/digest/digest_adapter.rb</filename>
    </removed>
    <removed>
      <filename>lib/rubygems/digest/md5.rb</filename>
    </removed>
    <removed>
      <filename>lib/rubygems/digest/sha1.rb</filename>
    </removed>
    <removed>
      <filename>lib/rubygems/digest/sha2.rb</filename>
    </removed>
    <removed>
      <filename>test/test_gem_digest.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>442f61ce4e315045047af9626c9f655e9245dff9</id>
    </parent>
  </parents>
  <author>
    <name>drbrain</name>
    <email>drbrain@3d4018f9-ac1a-0410-99e9-8a154d859a19</email>
  </author>
  <url>http://github.com/wycats/rubygems/commit/0a98bcafc5d412173644aff04c57757ca77fa62d</url>
  <id>0a98bcafc5d412173644aff04c57757ca77fa62d</id>
  <committed-date>2009-06-03T16:39:32-07:00</committed-date>
  <authored-date>2009-06-03T16:39:32-07:00</authored-date>
  <message>Various patches from Ruby trunk

git-svn-id: http://rubygems.rubyforge.org/svn/trunk@2221 3d4018f9-ac1a-0410-99e9-8a154d859a19</message>
  <tree>810eaecfcecab439e12d1d949a458cbb78c8e3c3</tree>
  <committer>
    <name>drbrain</name>
    <email>drbrain@3d4018f9-ac1a-0410-99e9-8a154d859a19</email>
  </committer>
</commit>
