[DRE-commits] [gem2deb] 01/01: dh_ruby: consider gemspec.bindir for installing executables.

Antonio Terceiro terceiro at moszumanska.debian.org
Mon Feb 15 18:07:15 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to branch master
in repository gem2deb.

commit 57d084d9ef8582076a1f522d802c48d20fa87e4d
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Mon Feb 15 15:46:08 2016 -0200

    dh_ruby: consider gemspec.bindir for installing executables.
---
 debian/changelog                          |   6 ++++++
 lib/gem2deb/installer.rb                  |   2 +-
 lib/gem2deb/metadata.rb                   |   4 ++++
 test/integration/gem2deb_test.rb          |   4 ++++
 test/sample/altbindir/altbindir.gemspec   |  17 +++++++++++++++++
 test/sample/altbindir/exe/altbindir       |   3 +++
 test/sample/altbindir/pkg/altbindir-1.gem | Bin 0 -> 4096 bytes
 test/unit/metadata_test.rb                |   8 ++++++++
 8 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 01839e7..9524b03 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+gem2deb (0.25.3) UNRELEASED; urgency=medium
+
+  * dh_ruby: consider gemspec.bindir for installing executables.
+
+ -- Antonio Terceiro <terceiro at debian.org>  Mon, 15 Feb 2016 15:45:31 -0200
+
 gem2deb (0.25.2) unstable; urgency=medium
 
   * gem2deb-test-runner: put directories under debian/ first in GEM_PATH to
diff --git a/lib/gem2deb/installer.rb b/lib/gem2deb/installer.rb
index 2915a4e..1a53004 100644
--- a/lib/gem2deb/installer.rb
+++ b/lib/gem2deb/installer.rb
@@ -116,7 +116,7 @@ module Gem2Deb
     end
 
     def bindir
-      @bindir ||= File.join(self.root, 'bin')
+      @bindir ||= File.join(self.root, metadata.bindir)
     end
 
     def libdir
diff --git a/lib/gem2deb/metadata.rb b/lib/gem2deb/metadata.rb
index 45ce863..57864ac 100644
--- a/lib/gem2deb/metadata.rb
+++ b/lib/gem2deb/metadata.rb
@@ -78,6 +78,10 @@ module Gem2Deb
       gemspec ? gemspec.test_files.select { |filename| filename =~ /\.rb$/ } : []
     end
 
+    def bindir
+      gemspec ? gemspec.bindir : 'bin'
+    end
+
     protected
 
     def load_gemspec
diff --git a/test/integration/gem2deb_test.rb b/test/integration/gem2deb_test.rb
index cd93382..eb9da9d 100644
--- a/test/integration/gem2deb_test.rb
+++ b/test/integration/gem2deb_test.rb
@@ -27,6 +27,10 @@ class Gem2DebTest < Gem2DebTestCase
     assert_match /E: ruby-simplegem: helper-templates-in-copyright/, `lintian #{changes_file}`
   end
 
+  should 'install executables for altbindir' do
+    assert_match '/usr/bin/altbindir', `dpkg --contents #{self.class.tmpdir}/ruby-altbindir*.deb`
+  end
+
   def self.build_tree(directory)
     FileUtils.cp_r(directory, tmpdir)
     dir = File.join(tmpdir, File.basename(directory))
diff --git a/test/sample/altbindir/altbindir.gemspec b/test/sample/altbindir/altbindir.gemspec
new file mode 100644
index 0000000..a9b29e7
--- /dev/null
+++ b/test/sample/altbindir/altbindir.gemspec
@@ -0,0 +1,17 @@
+# coding: utf-8
+
+Gem::Specification.new do |spec|
+  spec.name          = "altbindir"
+  spec.version       = '1'
+  spec.authors       = ["Antonio Terceiro"]
+  spec.email         = ["terceiro at debian.org"]
+
+  spec.summary       = %q{test gem}
+  spec.description   = %q{test gem}
+  spec.homepage      = "https://www.debian.org/"
+
+  spec.files         = Dir.glob('**/*')
+  spec.bindir        = "exe"
+  spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
+  spec.require_paths = ["lib"]
+end
diff --git a/test/sample/altbindir/exe/altbindir b/test/sample/altbindir/exe/altbindir
new file mode 100644
index 0000000..84a747a
--- /dev/null
+++ b/test/sample/altbindir/exe/altbindir
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+
+puts "Hello, world"
diff --git a/test/sample/altbindir/pkg/altbindir-1.gem b/test/sample/altbindir/pkg/altbindir-1.gem
new file mode 100644
index 0000000..7e3cec7
Binary files /dev/null and b/test/sample/altbindir/pkg/altbindir-1.gem differ
diff --git a/test/unit/metadata_test.rb b/test/unit/metadata_test.rb
index f416a29..497dd2d 100644
--- a/test/unit/metadata_test.rb
+++ b/test/unit/metadata_test.rb
@@ -55,6 +55,9 @@ class MetaDataTest < Gem2DebTestCase
       assert_equal 'package', @metadata.name
       assert_equal '1.2.3', @metadata.version
     end
+    should 'use bin/ as bindir' do
+      assert_equal 'bin', @metadata.bindir
+    end
   end
 
   context 'with gemspec' do
@@ -99,6 +102,11 @@ class MetaDataTest < Gem2DebTestCase
       assert_equal ['test/class1_test.rb', 'test/class2_test.rb'], @metadata.test_files
     end
 
+    should 'use whatever directory gemspec says as bindir' do
+      @gemspec.stubs(:bindir).returns('programs')
+      assert_equal 'programs', @metadata.bindir
+    end
+
   end
 
   context 'on multi-binary source packages' do

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/gem2deb.git



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