heidistein / rpms / ruby

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