[DRE-commits] [SCM] gem2deb.git branch, master, updated. 7ec46a91564d286f29dcb79e6fa9bf4301ed631e
Antonio Terceiro
terceiro at softwarelivre.org
Mon May 9 20:20:54 UTC 2011
The following commit has been merged in the master branch:
commit 7ec46a91564d286f29dcb79e6fa9bf4301ed631e
Author: Antonio Terceiro <terceiro at softwarelivre.org>
Date: Mon May 9 12:21:15 2011 -0700
Correct handling of shebangs
If the package supports all Ruby versions, use /usr/bin/ruby. Otherwise,
use the first version in XS-Ruby-Versions.
diff --git a/lib/gem2deb/dh_ruby.rb b/lib/gem2deb/dh_ruby.rb
index d70acab..9451e4a 100644
--- a/lib/gem2deb/dh_ruby.rb
+++ b/lib/gem2deb/dh_ruby.rb
@@ -47,6 +47,8 @@ module Gem2Deb
'ruby1.9.1' => '/usr/bin/ruby1.9.1',
}
+ RUBY_BINARY = '/usr/bin/ruby'
+
DEFAULT_RUBY_VERSION = 'ruby1.8'
RUBY_CODE_DIR = '/usr/lib/ruby/vendor_ruby'
@@ -317,8 +319,16 @@ module Gem2Deb
end
def update_shebangs(package)
- rubyver = DEFAULT_RUBY_VERSION
- ruby_binary = SUPPORTED_RUBY_VERSIONS[rubyver] || SUPPORTED_RUBY_VERSIONS[DEFAULT_RUBY_VERSION]
+ ruby_binary =
+ if all_ruby_versions_supported?
+ RUBY_BINARY
+ else
+ SUPPORTED_RUBY_VERSIONS[ruby_versions.first]
+ end
+ rewrite_shebangs(package, ruby_binary)
+ end
+
+ def rewrite_shebangs(package, ruby_binary)
Dir.glob(File.join(destdir_for(package), @bindir, '*')).each do |path|
puts "Rewriting shebang line of #{path}" if @verbose
atomic_rewrite(path) do |input, output|
diff --git a/test/unit/dh_ruby_test.rb b/test/unit/dh_ruby_test.rb
index 3d4ee2d..d48e1d5 100644
--- a/test/unit/dh_ruby_test.rb
+++ b/test/unit/dh_ruby_test.rb
@@ -25,7 +25,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/ruby1.8), read_installed_file(SIMPLE_PROGRAM_DIRNAME, 'ruby-simpleprogram', '/usr/bin/simpleprogram').lines.first.strip
+ assert_match %r(#!/usr/bin/ruby), read_installed_file(SIMPLE_PROGRAM_DIRNAME, 'ruby-simpleprogram', '/usr/bin/simpleprogram').lines.first
end
end
@@ -44,9 +44,6 @@ class DhRubyTest < Gem2DebTestCase
assert_match /libruby-?#{version_number}/, `ldd #{installed_so}`
end
end
- should "update the shebang to use the default ruby version" do
- assert_match %r(#!/usr/bin/ruby1.8), read_installed_file(SIMPLE_EXTENSION_DIRNAME, 'ruby-simpleextension', '/usr/bin/simpleextension').lines.first.strip
- end
end
context 'installing native extension with extconf.rb in the sources root' do
@@ -107,6 +104,16 @@ 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
+ @dh_ruby.stubs(:all_ruby_versions_supported?).returns(true)
+ @dh_ruby.expects(:rewrite_shebangs).with(anything, '/usr/bin/ruby')
+ @dh_ruby.send(:update_shebangs, 'foo')
+ end
+ should 'rewrite shebang to usr /usr/bin/ruby1.8 if only 1.8 is supported' do
+ @dh_ruby.stubs(:ruby_versions).returns(['ruby1.8'])
+ @dh_ruby.expects(:rewrite_shebangs).with(anything, '/usr/bin/ruby1.8')
+ @dh_ruby.send(:update_shebangs, 'foo')
+ end
end
protected
--
gem2deb.git
More information about the Pkg-ruby-extras-commits
mailing list