pvalena / rpms / ruby

Forked from rpms/ruby 6 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
---
3fa8028
 lib/rubygems/specification.rb | 32 ++++++++++++++++++++++++++++++--
3fa8028
 1 file changed, 30 insertions(+), 2 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
3fa8028
@@ -1250,6 +1250,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
 
6c9f7f5
@@ -1368,11 +1374,16 @@ class Gem::Specification
117278a
 
117278a
   def contains_requirable_file? file
3fa8028
     root     = full_gem_path
3fa8028
+    ext      = ext_dir
3fa8028
     suffixes = Gem.suffixes
117278a
 
3fa8028
     require_paths.any? do |lib|
117278a
-      base = "#{root}/#{lib}/#{file}"
3fa8028
-      suffixes.any? { |suf| File.file? "#{base}#{suf}" }
3fa8028
+      base = ["#{root}/#{lib}/#{file}"]
3fa8028
+      base << "#{ext}/#{lib}/#{file}" unless extensions.empty?
3fa8028
+
117278a
+      base.any? do |path|
3fa8028
+        suffixes.any? { |suf| File.file? "#{path}#{suf}" }
3fa8028
+      end
117278a
     end
117278a
   end
117278a
 
6c9f7f5
@@ -1668,6 +1679,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
-- 
3fa8028
1.8.0
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
---
3fa8028
 lib/rubygems/installer.rb     | 2 +-
3fa8028
 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
a91606d
@@ -641,7 +641,7 @@ TEXT
3fa8028
       say "This could take a while..."
3fa8028
     end
3fa8028
 
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
6c9f7f5
@@ -1683,16 +1683,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
-- 
3fa8028
1.8.0
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
---
3fa8028
 lib/rubygems/specification.rb | 11 +++++------
3fa8028
 1 file 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
3fa8028
@@ -1250,11 +1250,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
6c9f7f5
@@ -1691,7 +1687,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
-- 
3fa8028
1.8.0
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
---
3fa8028
 lib/rubygems/installer.rb     | 2 +-
3fa8028
 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
a91606d
@@ -641,7 +641,7 @@ TEXT
3fa8028
       say "This could take a while..."
3fa8028
     end
3fa8028
 
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
3fa8028
@@ -1250,7 +1250,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
6c9f7f5
@@ -1679,7 +1679,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
-- 
3fa8028
1.8.0
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
---
3fa8028
 lib/rubygems/uninstaller.rb | 1 +
3fa8028
 1 file changed, 1 insertion(+)
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
a91606d
@@ -246,6 +246,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
-- 
3fa8028
1.8.0
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
---
3fa8028
 lib/rubygems/defaults.rb      | 11 +++++++++++
3fa8028
 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
66b9825
@@ -101,6 +101,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
+  ##
3fa8028
   # A wrapper around RUBY_ENGINE const that may not be defined
117278a
 
3fa8028
   def self.ruby_engine
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
6c9f7f5
@@ -1687,10 +1687,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
-- 
3fa8028
1.8.0
117278a