[DRE-commits] [SCM] gem2deb.git branch, master, updated. debian/0.2.3-48-gae05bb2

Antonio Terceiro terceiro at softwarelivre.org
Sat Jul 9 05:51:15 UTC 2011


The following commit has been merged in the master branch:
commit 9a54c8b64fffaf6447ce72c6f494843929c744c2
Author: Antonio Terceiro <terceiro at softwarelivre.org>
Date:   Sun Jul 3 21:20:59 2011 -0700

    Install symlinks for .rb files masked by .so files
    
    This fixes the following issue with Ruby 1.8: when there is both a
    foo.rb file *and* a foo.so extension, `require 'foo'` is supposed to
    load foo.rb first, but /usr/lib/ruby/vendor_ruby (the place where we
    install .rb files) comes after /usr/lib/ruby/vendor_ruby/$arch (the
    place where we install .so files) in the $LOAD_PATH, what makes `require
    'foo'` load foo.so instead! See for example Debian bug #632071 and the
    corresponding discussion with upstream:
    
    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=632071
    https://github.com/rcairo/rcairo/issues/5
    
    It is not likely that this is going to be changed in Ruby 1.8 anymore,
    so we need to workaround it:
    
    http://redmine.ruby-lang.org/issues/4979
    
    Note that Ruby 1.9+ is NOT affected by this issue, and that's why we are
    installing the symlinks only for Ruby 1.8

diff --git a/lib/gem2deb/dh_ruby.rb b/lib/gem2deb/dh_ruby.rb
index 1cb221d..28786b4 100644
--- a/lib/gem2deb/dh_ruby.rb
+++ b/lib/gem2deb/dh_ruby.rb
@@ -141,6 +141,24 @@ module Gem2Deb
           end
         end
       end
+
+      install_symlinks(package, supported_versions)
+    end
+
+    def install_symlinks(package, supported_versions)
+      supported_versions.select { |v| v == 'ruby1.8' }.each do |rubyver|
+        archdir = destdir(package, :archdir, rubyver)
+        vendordir = destdir(packages, :libdir, rubyver)
+        vendorlibdir = File.dirname(archdir)
+        Dir.glob(File.join(archdir, '*.so')).each do |so|
+          rb = File.basename(so).gsub(/\.so$/, '.rb')
+          if File.exists?(File.join(vendordir, rb))
+            Dir.chdir(vendorlibdir) do
+              FileUtils.ln_s "../#{rb}", rb
+            end
+          end
+        end
+      end
     end
 
     def remove_duplicate_files(src, dst)
diff --git a/test/helper/samples.rb b/test/helper/samples.rb
index 0aa90d6..18a09bb 100644
--- a/test/helper/samples.rb
+++ b/test/helper/samples.rb
@@ -34,5 +34,6 @@ class Gem2DebTestCase
 
     SIMPLE_EXTENSION_WITH_NAME_CLASH_NAME = 'simpleextension_with_name_clash'
     SIMPLE_EXTENSION_WITH_NAME_CLASH_DIRNAME = SIMPLE_EXTENSION_WITH_NAME_CLASH_NAME.gsub('_', '-') + '-1.2.3'
+    SIMPLE_EXTENSION_WITH_NAME_CLASH = File.join(SAMPLE_DIR, SIMPLE_EXTENSION_WITH_NAME_CLASH_NAME, 'pkg', SIMPLE_EXTENSION_WITH_NAME_CLASH_DIRNAME + '.gem')
   end
 end
diff --git a/test/unit/dh_ruby_test.rb b/test/unit/dh_ruby_test.rb
index b13728a..21d1335 100644
--- a/test/unit/dh_ruby_test.rb
+++ b/test/unit/dh_ruby_test.rb
@@ -12,6 +12,7 @@ class DhRubyTest < Gem2DebTestCase
     build(SIMPLE_EXTENSION, SIMPLE_EXTENSION_DIRNAME)
     build(SIMPLE_MIXED, SIMPLE_MIXED_DIRNAME)
     build(SIMPLE_ROOT_EXTENSION, SIMPLE_ROOT_EXTENSION_DIRNAME)
+    build(SIMPLE_EXTENSION_WITH_NAME_CLASH, SIMPLE_EXTENSION_WITH_NAME_CLASH_DIRNAME)
   end
 
   context 'installing simplegem' do
@@ -166,6 +167,17 @@ class DhRubyTest < Gem2DebTestCase
     end
   end
 
+  context 'libraries with name clash (between foo.rb and foo.so)' do
+    should "install symlinks for foo.rb in Ruby 1.8 vendorlibdir" do
+      symlink = installed_file_path(SIMPLE_EXTENSION_WITH_NAME_CLASH_DIRNAME, 'ruby-simpleextension-with-name-clash', "/usr/lib/ruby/vendor_ruby/1.8/simpleextension_with_name_clash.rb")
+      assert_file_exists symlink
+    end
+    should 'not install symlink for foo.rb in Ruby 1.9 vendorlibdir' do
+      symlink = installed_file_path(SIMPLE_EXTENSION_WITH_NAME_CLASH_DIRNAME, 'ruby-simpleextension-with-name-clash', "/usr/lib/ruby/vendor_ruby/1.9.1/simpleextension_with_name_clash.rb")
+      assert !File.exist?(symlink), 'should not install symlink for Ruby 1.9 (it\'s not needed'
+    end
+  end
+
   protected
 
   def read_installed_file(gem_dirname, package, path)

-- 
gem2deb.git



More information about the Pkg-ruby-extras-commits mailing list