heidistein / rpms / ruby

Forked from rpms/ruby 5 years ago
Clone
117278a
From 5a37a3489491a33f2e7011043fbbcd9a765e1777 Mon Sep 17 00:00:00 2001
117278a
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
117278a
Date: Thu, 3 Nov 2011 16:43:05 +0100
117278a
Subject: [PATCH 1/6] Add dedicate extensions folder into $LOAD_PATH.
117278a
117278a
---
117278a
 lib/rubygems/specification.rb |   37 ++++++++++++++++++++++++++++++-------
117278a
 1 files changed, 30 insertions(+), 7 deletions(-)
117278a
117278a
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
117278a
index 97db19e..263e7d3 100644
117278a
--- a/lib/rubygems/specification.rb
117278a
+++ b/lib/rubygems/specification.rb
117278a
@@ -843,6 +843,12 @@ class Gem::Specification
117278a
       File.join full_gem_path, path
117278a
     end
117278a
 
117278a
+    unless extensions.empty?
117278a
+      paths += require_paths.map do |path|
117278a
+        File.join ext_dir, path
117278a
+      end
117278a
+    end
117278a
+
117278a
     # gem directories must come after -I and ENV['RUBYLIB']
117278a
     insert_index = Gem.load_path_insert_index
117278a
 
117278a
@@ -954,16 +960,16 @@ class Gem::Specification
117278a
 
117278a
   def contains_requirable_file? file
117278a
     root = full_gem_path
117278a
+    ext = ext_dir
117278a
+
117278a
+    require_paths.any? do |lib|
117278a
+      base = ["#{root}/#{lib}/#{file}"]
117278a
+      base << "#{ext}/#{lib}/#{file}" unless extensions.empty?
117278a
 
117278a
-    require_paths.each do |lib|
117278a
-      base = "#{root}/#{lib}/#{file}"
117278a
-      Gem.suffixes.each do |suf|
117278a
-        path = "#{base}#{suf}"
117278a
-        return true if File.file? path
117278a
+      base.any? do |path|
117278a
+        Gem.suffixes.any? { |suf| File.file? "#{path}#{suf}" }
117278a
       end
117278a
     end
117278a
-
117278a
-    return false
117278a
   end
117278a
 
117278a
   ##
117278a
@@ -1273,6 +1279,23 @@ class Gem::Specification
117278a
   end
117278a
 
117278a
   ##
117278a
+  # Returns the full path to this spec's ext directory.
117278a
+  # eg: /usr/local/lib/ruby/1.8/exts/mygem-1.0
117278a
+
117278a
+  def ext_dir
117278a
+    @gem_dir ||= File.expand_path File.join(exts_dir, full_name)
117278a
+  end
117278a
+
117278a
+  ##
117278a
+  # Returns the full path to the exts directory containing this spec's
117278a
+  # gem directory. eg: /usr/local/lib/ruby/1.8/exts
117278a
+
117278a
+  def exts_dir
117278a
+    # TODO: this logic seems terribly broken, but tests fail if just base_dir
117278a
+    @exts_dir ||= File.join(loaded_from && base_dir || Gem.dir, "exts")
117278a
+  end
117278a
+
117278a
+  ##
117278a
   # Deprecated and ignored, defaults to true.
117278a
   #
117278a
   # Formerly used to indicate this gem was RDoc-capable.
117278a
-- 
117278a
1.7.7.3
117278a
117278a
117278a
From 671e4285bf9db948bc5f054d7d3d931cdd7a17f8 Mon Sep 17 00:00:00 2001
117278a
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
117278a
Date: Wed, 16 Nov 2011 13:26:48 +0100
117278a
Subject: [PATCH 2/6] Use spec's ext dir for extension installation.
117278a
117278a
---
117278a
 lib/rubygems/installer.rb     |    2 +-
117278a
 lib/rubygems/specification.rb |    7 +++----
117278a
 2 files changed, 4 insertions(+), 5 deletions(-)
117278a
117278a
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
117278a
index 74d803d..0063c7f 100644
117278a
--- a/lib/rubygems/installer.rb
117278a
+++ b/lib/rubygems/installer.rb
117278a
@@ -499,7 +499,7 @@ TEXT
117278a
   def build_extensions
117278a
     return if spec.extensions.empty?
117278a
     say "Building native extensions.  This could take a while..."
117278a
-    dest_path = File.join gem_dir, spec.require_paths.first
117278a
+    dest_path = spec.ext_dir
117278a
     ran_rake = false # only run rake once
117278a
 
117278a
     spec.extensions.each do |extension|
117278a
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
117278a
index 263e7d3..d31b93b 100644
117278a
--- a/lib/rubygems/specification.rb
117278a
+++ b/lib/rubygems/specification.rb
117278a
@@ -1283,16 +1283,15 @@ class Gem::Specification
117278a
   # eg: /usr/local/lib/ruby/1.8/exts/mygem-1.0
117278a
 
117278a
   def ext_dir
117278a
-    @gem_dir ||= File.expand_path File.join(exts_dir, full_name)
117278a
+    @ext_dir ||= File.join exts_dir, full_name, require_paths.first
117278a
   end
117278a
 
117278a
   ##
117278a
   # Returns the full path to the exts directory containing this spec's
117278a
-  # gem directory. eg: /usr/local/lib/ruby/1.8/exts
117278a
+  # gem directory. eg: /usr/local/lib/ruby/1.8/gems
117278a
 
117278a
   def exts_dir
117278a
-    # TODO: this logic seems terribly broken, but tests fail if just base_dir
117278a
-    @exts_dir ||= File.join(loaded_from && base_dir || Gem.dir, "exts")
117278a
+    @exts_dir ||= gems_dir
117278a
   end
117278a
 
117278a
   ##
117278a
-- 
117278a
1.7.7.3
117278a
117278a
117278a
From 11b4a0cbadd8b1d3320f838881aa60feb6f848e7 Mon Sep 17 00:00:00 2001
117278a
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
117278a
Date: Wed, 16 Nov 2011 14:52:16 +0100
117278a
Subject: [PATCH 3/6] Simplify the extending of $LOAD_PATH for binary gems.
117278a
117278a
---
117278a
 lib/rubygems/specification.rb |   11 +++++------
117278a
 1 files changed, 5 insertions(+), 6 deletions(-)
117278a
117278a
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
117278a
index d31b93b..e65ea2d 100644
117278a
--- a/lib/rubygems/specification.rb
117278a
+++ b/lib/rubygems/specification.rb
117278a
@@ -843,11 +843,7 @@ class Gem::Specification
117278a
       File.join full_gem_path, path
117278a
     end
117278a
 
117278a
-    unless extensions.empty?
117278a
-      paths += require_paths.map do |path|
117278a
-        File.join ext_dir, path
117278a
-      end
117278a
-    end
117278a
+    paths << ext_dir unless extensions.empty? || paths.include?(ext_dir)
117278a
 
117278a
     # gem directories must come after -I and ENV['RUBYLIB']
117278a
     insert_index = Gem.load_path_insert_index
117278a
@@ -1291,7 +1287,10 @@ class Gem::Specification
117278a
   # gem directory. eg: /usr/local/lib/ruby/1.8/gems
117278a
 
117278a
   def exts_dir
117278a
-    @exts_dir ||= gems_dir
117278a
+    @exts_dir ||= begin
117278a
+      dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir}
117278a
+      dirs ? File.join(dirs.last[:ext_dir], 'exts') : gems_dir
117278a
+    end
117278a
   end
117278a
 
117278a
   ##
117278a
-- 
117278a
1.7.7.3
117278a
117278a
117278a
From 5d46cd2b1ac9517a9cbcfa430261e62bb3a376b8 Mon Sep 17 00:00:00 2001
117278a
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
117278a
Date: Fri, 9 Dec 2011 16:31:04 +0100
117278a
Subject: [PATCH 4/6] Fix the binary extension search path construction.
117278a
117278a
---
117278a
 lib/rubygems/installer.rb     |    2 +-
117278a
 lib/rubygems/specification.rb |    4 ++--
117278a
 2 files changed, 3 insertions(+), 3 deletions(-)
117278a
117278a
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
117278a
index 0063c7f..83b8fd5 100644
117278a
--- a/lib/rubygems/installer.rb
117278a
+++ b/lib/rubygems/installer.rb
117278a
@@ -499,7 +499,7 @@ TEXT
117278a
   def build_extensions
117278a
     return if spec.extensions.empty?
117278a
     say "Building native extensions.  This could take a while..."
117278a
-    dest_path = spec.ext_dir
117278a
+    dest_path = File.join spec.ext_dir, spec.require_paths.first
117278a
     ran_rake = false # only run rake once
117278a
 
117278a
     spec.extensions.each do |extension|
117278a
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
117278a
index e65ea2d..8be2ade 100644
117278a
--- a/lib/rubygems/specification.rb
117278a
+++ b/lib/rubygems/specification.rb
117278a
@@ -843,7 +843,7 @@ class Gem::Specification
117278a
       File.join full_gem_path, path
117278a
     end
117278a
 
117278a
-    paths << ext_dir unless extensions.empty? || paths.include?(ext_dir)
117278a
+    paths << File.join(ext_dir, require_paths.first) unless extensions.empty? || (ext_dir == full_gem_path)
117278a
 
117278a
     # gem directories must come after -I and ENV['RUBYLIB']
117278a
     insert_index = Gem.load_path_insert_index
117278a
@@ -1279,7 +1279,7 @@ class Gem::Specification
117278a
   # eg: /usr/local/lib/ruby/1.8/exts/mygem-1.0
117278a
 
117278a
   def ext_dir
117278a
-    @ext_dir ||= File.join exts_dir, full_name, require_paths.first
117278a
+    @ext_dir ||= File.join exts_dir, full_name
117278a
   end
117278a
 
117278a
   ##
117278a
-- 
117278a
1.7.7.3
117278a
117278a
117278a
From 6229583633802b45e5a3e5689ab9077347cd9ef7 Mon Sep 17 00:00:00 2001
117278a
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
117278a
Date: Tue, 13 Dec 2011 12:14:54 +0100
117278a
Subject: [PATCH 5/6] Remove binary extensions during uninstall.
117278a
117278a
---
117278a
 lib/rubygems/uninstaller.rb |    1 +
117278a
 1 files changed, 1 insertions(+), 0 deletions(-)
117278a
117278a
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb
117278a
index cc32ea4..94d78e0 100644
117278a
--- a/lib/rubygems/uninstaller.rb
117278a
+++ b/lib/rubygems/uninstaller.rb
117278a
@@ -213,6 +213,7 @@ class Gem::Uninstaller
117278a
       File.writable?(spec.base_dir)
117278a
 
117278a
     FileUtils.rm_rf spec.full_gem_path
117278a
+    FileUtils.rm_rf spec.ext_dir
117278a
 
117278a
     # TODO: should this be moved to spec?... I vote eww (also exists in docmgr)
117278a
     old_platform_name = [spec.name,
117278a
-- 
117278a
1.7.7.3
117278a
117278a
117278a
From bc40e1b9f60a9a04456e3504ffe6ee600b6da269 Mon Sep 17 00:00:00 2001
117278a
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
117278a
Date: Tue, 13 Dec 2011 14:27:14 +0100
117278a
Subject: [PATCH 6/6] Avoid dependency on customized operating_system.rb.
117278a
117278a
---
117278a
 lib/rubygems/defaults.rb      |   11 +++++++++++
117278a
 lib/rubygems/specification.rb |    5 +----
117278a
 2 files changed, 12 insertions(+), 4 deletions(-)
117278a
117278a
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
117278a
index 20b4198..6d8711f 100644
117278a
--- a/lib/rubygems/defaults.rb
117278a
+++ b/lib/rubygems/defaults.rb
117278a
@@ -87,6 +87,17 @@ module Gem
117278a
   end
117278a
 
117278a
   ##
117278a
+  # Returns binary extensions dir for specified RubyGems base dir or nil
117278a
+  # if such directory cannot be determined.
117278a
+  #
117278a
+  # By default, the binary extensions are located side by side with their
117278a
+  # Ruby counterparts, therefore nil is returned
117278a
+
117278a
+  def self.default_ext_dir_for base_dir
117278a
+    nil
117278a
+  end
117278a
+
117278a
+  ##
117278a
   # The default system-wide source info cache directory
117278a
 
117278a
   def self.default_system_source_cache_dir
117278a
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
117278a
index 8be2ade..f54210a 100644
117278a
--- a/lib/rubygems/specification.rb
117278a
+++ b/lib/rubygems/specification.rb
117278a
@@ -1287,10 +1287,7 @@ class Gem::Specification
117278a
   # gem directory. eg: /usr/local/lib/ruby/1.8/gems
117278a
 
117278a
   def exts_dir
117278a
-    @exts_dir ||= begin
117278a
-      dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir}
117278a
-      dirs ? File.join(dirs.last[:ext_dir], 'exts') : gems_dir
117278a
-    end
117278a
+    @exts_dir ||= Gem.default_ext_dir_for(base_dir) || gems_dir
117278a
   end
117278a
 
117278a
   ##
117278a
-- 
117278a
1.7.7.3
117278a