[DRE-commits] [SCM] gem2deb.git branch, master, updated. debian/0.2.3-9-g5a67a0f
Antonio Terceiro
terceiro at softwarelivre.org
Fri Jun 3 17:42:17 UTC 2011
The following commit has been merged in the master branch:
commit 5a67a0f1e1f9f3d52c476fad47d83f2d8c97b063
Author: Antonio Terceiro <terceiro at softwarelivre.org>
Date: Fri Jun 3 10:39:09 2011 -0700
Support subdirs in /usr/bin (Closes: #629036)
No sane package should install subdirectories of /usr/bin, though. But
if a broken package does it, we shall not crash.
diff --git a/lib/gem2deb/dh_ruby.rb b/lib/gem2deb/dh_ruby.rb
index d3320a6..2ac28ad 100644
--- a/lib/gem2deb/dh_ruby.rb
+++ b/lib/gem2deb/dh_ruby.rb
@@ -346,7 +346,8 @@ module Gem2Deb
end
def rewrite_shebangs(package, ruby_binary)
- Dir.glob(File.join(destdir_for(package), @bindir, '*')).each do |path|
+ Dir.glob(File.join(destdir_for(package), @bindir, '**/*')).each do |path|
+ next if File.directory?(path)
puts "Rewriting shebang line of #{path}" if @verbose
atomic_rewrite(path) do |input, output|
old = input.gets # discard
diff --git a/test/sample/rewrite_shebangs/usr/bin/prog b/test/sample/rewrite_shebangs/usr/bin/prog
new file mode 100755
index 0000000..c365342
--- /dev/null
+++ b/test/sample/rewrite_shebangs/usr/bin/prog
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+
+exit 0
diff --git a/test/sample/rewrite_shebangs/usr/bin/subdir/prog b/test/sample/rewrite_shebangs/usr/bin/subdir/prog
new file mode 100755
index 0000000..c365342
--- /dev/null
+++ b/test/sample/rewrite_shebangs/usr/bin/subdir/prog
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+
+exit 0
diff --git a/test/unit/dh_ruby_test.rb b/test/unit/dh_ruby_test.rb
index e13531b..16f4c18 100644
--- a/test/unit/dh_ruby_test.rb
+++ b/test/unit/dh_ruby_test.rb
@@ -116,6 +116,30 @@ class DhRubyTest < Gem2DebTestCase
end
end
+ context 'rewriting shebangs' do
+ setup do
+ @dh_ruby = Gem2Deb::DhRuby.new
+ @dh_ruby.verbose = false
+
+ FileUtils.cp_r('test/sample/rewrite_shebangs', self.class.tmpdir)
+ @dh_ruby.expects(:destdir_for).returns(self.class.tmpdir + '/rewrite_shebangs')
+
+ # 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')
+ 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')
+ 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')
+ end
+ end
+
context 'checking for require "rubygems"' do
setup do
@dh_ruby = Gem2Deb::DhRuby.new
--
gem2deb.git
More information about the Pkg-ruby-extras-commits
mailing list