[DRE-commits] [SCM] gem2deb.git branch, master, updated. 0.2.9-3-gcfcc1b7

Antonio Terceiro terceiro at softwarelivre.org
Sat Sep 24 19:05:57 UTC 2011


The following commit has been merged in the master branch:
commit 5695e64b059f8a73cdf8c80f1a88999bb98988fb
Author: Antonio Terceiro <terceiro at softwarelivre.org>
Date:   Sat Sep 24 11:46:09 2011 -0700

    If all Rubies are supported, use `ruby` in PATH

diff --git a/lib/gem2deb/dh_ruby.rb b/lib/gem2deb/dh_ruby.rb
index eb08399..504628a 100644
--- a/lib/gem2deb/dh_ruby.rb
+++ b/lib/gem2deb/dh_ruby.rb
@@ -29,7 +29,7 @@ module Gem2Deb
       'ruby1.9.1' => '/usr/bin/ruby1.9.1',
     }
 
-    RUBY_BINARY = '/usr/bin/ruby'
+    RUBY_SHEBANG_CALL = '/usr/bin/env ruby'
 
     DEFAULT_RUBY_VERSION = 'ruby1.8'
 
@@ -330,7 +330,7 @@ module Gem2Deb
     def update_shebangs(package)
       ruby_binary =
         if all_ruby_versions_supported?
-          RUBY_BINARY
+          RUBY_SHEBANG_CALL
         else
           SUPPORTED_RUBY_VERSIONS[ruby_versions.first]
         end
diff --git a/test/unit/dh_ruby_test.rb b/test/unit/dh_ruby_test.rb
index b61e3b3..0d0afdb 100644
--- a/test/unit/dh_ruby_test.rb
+++ b/test/unit/dh_ruby_test.rb
@@ -26,7 +26,7 @@ class DhRubyTest < Gem2DebTestCase
       assert_installed SIMPLE_PROGRAM_DIRNAME, 'ruby-simpleprogram', '/usr/bin/simpleprogram'
     end
     should 'rewrite shebang of installed programs' do
-      assert_match %r(#!/usr/bin/ruby), read_installed_file(SIMPLE_PROGRAM_DIRNAME, 'ruby-simpleprogram', '/usr/bin/simpleprogram').lines.first
+      assert_match %r(#!/usr/bin/env ruby), read_installed_file(SIMPLE_PROGRAM_DIRNAME, 'ruby-simpleprogram', '/usr/bin/simpleprogram').lines.first
     end
   end
 
@@ -114,9 +114,9 @@ class DhRubyTest < Gem2DebTestCase
       @dh_ruby.stubs(:ruby_versions).returns(['ruby1.8'])
       assert_equal false, @dh_ruby.send(:all_ruby_versions_supported?)
     end
-    should 'rewrite shebang to use /usr/bin/ruby if all versions are supported' do
+    should 'rewrite shebang to use `/usr/bin/env ruby` if all versions are supported' do
       @dh_ruby.stubs(:all_ruby_versions_supported?).returns(true)
-      @dh_ruby.expects(:rewrite_shebangs).with(anything, '/usr/bin/ruby')
+      @dh_ruby.expects(:rewrite_shebangs).with(anything, '/usr/bin/env ruby')
       @dh_ruby.send(:update_shebangs, 'foo')
     end
     should 'rewrite shebang to usr /usr/bin/ruby1.8 if only 1.8 is supported' do
@@ -136,21 +136,21 @@ class DhRubyTest < Gem2DebTestCase
 
       # The fact that this call does not crash means we won't crash when
       # /usr/bin has subdirectories
-      @dh_ruby.send(:rewrite_shebangs, 'ruby-foo', '/usr/bin/ruby')
+      @dh_ruby.send(:rewrite_shebangs, 'ruby-foo', '/usr/bin/env ruby')
     end
     teardown do
       FileUtils.rm_f(self.class.tmpdir + '/rewrite_shebangs')
     end
 
     should 'rewrite shebangs of programs directly under bin/' do
-      assert_match %r{/usr/bin/ruby}, File.read(self.class.tmpdir + '/rewrite_shebangs/usr/bin/prog')
+      assert_match %r{/usr/bin/env ruby}, File.read(self.class.tmpdir + '/rewrite_shebangs/usr/bin/prog')
     end
     should 'rewrite shebangs in subdirs of bin/' do
-      assert_match %r{/usr/bin/ruby}, File.read(self.class.tmpdir + '/rewrite_shebangs/usr/bin/subdir/prog')
+      assert_match %r{/usr/bin/env ruby}, File.read(self.class.tmpdir + '/rewrite_shebangs/usr/bin/subdir/prog')
     end
     should 'add a shebang when there is none' do
       lines = File.readlines(self.class.tmpdir + '/rewrite_shebangs/usr/bin/no-shebang')
-      assert_match %r{/usr/bin/ruby}, lines[0]
+      assert_match %r{/usr/bin/env ruby}, lines[0]
       assert_match /puts/, lines[1]
     end
     should 'leave programs with correct permissions after rewriting shebangs' do

-- 
gem2deb.git



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