[DRE-commits] [gem2deb] 02/05: dh_ruby: call {make, rake} on debian/dh_ruby.{mk, rake}

Antonio Terceiro terceiro at moszumanska.debian.org
Sat Feb 21 22:33:48 UTC 2015


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

terceiro pushed a commit to branch master
in repository gem2deb.

commit e02e61dd25a484fac29693f8edc85b2d68bb7645
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Sat Feb 21 18:40:14 2015 -0200

    dh_ruby: call {make,rake} on debian/dh_ruby.{mk,rake}
---
 bin/dh_ruby                 | 36 +++++++++++++++++++++++++++++++++
 debian/changelog            |  7 +++++++
 lib/gem2deb/dh_ruby.rb      | 28 +++++++++++++++++++++++---
 lib/gem2deb/installer.rb    | 10 +--------
 lib/gem2deb/make.rb         | 49 +++++++++++++++++++++++++++++++++++++++++++++
 lib/gem2deb/version.rb      |  2 +-
 test/unit/dh_ruby_test.rb   | 17 ++++++++++++++++
 test/unit/installer_test.rb | 18 -----------------
 8 files changed, 136 insertions(+), 31 deletions(-)

diff --git a/bin/dh_ruby b/bin/dh_ruby
index 900c748..06add65 100755
--- a/bin/dh_ruby
+++ b/bin/dh_ruby
@@ -323,6 +323,42 @@ As you can see above, you have to list filenames based on their corresponding
 install locations in the package temporary install directory, i.e.
 `debian/${pkg}/..`
 
+=item debian/I<dh_ruby.mk>
+
+If this file is present, dh_ruby will call B<make> passing it as the makefile
+during the build, in the I<clean>, I<build>, and I<install> steps, like this:
+
+=over
+
+=item clean: B<make -f debian/dh_ruby.mk clean>
+
+=item build: B<make -f debian/dh_ruby.mk>
+
+=item install: B<make -f debian/dh_ruby.mk install>
+
+=back
+
+If you want the upstream Makefile to be used, just make I<debian/dh_ruby.mk> a
+symlink to I<../Makefile>.
+
+=item debian/I<dh_ruby.rake>
+
+If this file is present, dh_ruby will call B<rake> passing it as the rakefile
+during the build, in the I<clean>, I<build>, and I<install> steps, like this:
+
+=over
+
+=item clean: B<rake -f debian/dh_ruby.rake clean>
+
+=item build: B<rake -f debian/dh_ruby.rake>
+
+=item install: B<rake -f debian/dh_ruby.rake install>
+
+=back
+
+If you want the upstream Rakefile to be used, just make I<debian/dh_ruby.rake> a
+symlink to I<../Rakefile>.
+
 =back
 
 =head1 SEE ALSO
diff --git a/debian/changelog b/debian/changelog
index e0289ac..09bda51 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+gem2deb (0.12) UNRELEASED; urgency=medium
+
+  * dh_ruby: if debian/dh_ruby.{mk,rake} exists, call {make,rake} on it during
+    the build. See docs in dh_ruby(1)
+
+ -- Antonio Terceiro <terceiro at debian.org>  Sat, 21 Feb 2015 18:38:18 -0200
+
 gem2deb (0.11) experimental; urgency=medium
 
   * dh-make-ruby: generate 'Testsuite: autopkgtest-pkg-ruby' to not conflict
diff --git a/lib/gem2deb/dh_ruby.rb b/lib/gem2deb/dh_ruby.rb
index 31a8bab..4a20107 100644
--- a/lib/gem2deb/dh_ruby.rb
+++ b/lib/gem2deb/dh_ruby.rb
@@ -15,6 +15,7 @@
 
 require 'gem2deb'
 require 'gem2deb/installer'
+require 'gem2deb/make'
 require 'find'
 require 'fileutils'
 
@@ -36,6 +37,8 @@ module Gem2Deb
     def clean
       puts "   dh_ruby --clean" if @verbose
 
+      make.clean
+
       installers.each do |installer|
         installer.run_make_clean_on_extensions
       end
@@ -46,7 +49,9 @@ module Gem2Deb
     end
 
     def build
-      # puts "   dh_ruby --build" if @verbose
+      puts "   dh_ruby --build" if @verbose
+
+      make.build
     end
 
     def test
@@ -62,6 +67,10 @@ module Gem2Deb
     def install(argv)
       puts "   dh_ruby --install" if @verbose
 
+      dh_auto_install_destdir = argv.first
+
+      make.install(destdir_for(packages.first[:binary_package], dh_auto_install_destdir))
+
       ruby_versions.each do |version|
         if !SUPPORTED_RUBY_VERSIONS.include?(version)
           puts "E: #{version} is not supported by gem2deb anymore"
@@ -70,7 +79,7 @@ module Gem2Deb
       end
 
       installers.each do |installer|
-        installer.dh_auto_install_destdir = argv.first
+        installer.destdir_base = destdir_for(installer.binary_package, dh_auto_install_destdir)
         installer.install_files_and_build_extensions
         installer.update_shebangs
       end
@@ -84,7 +93,8 @@ module Gem2Deb
       end
     end
 
-    protected
+    protected # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 
     def check_rubygems(installer)
       if skip_checks?
@@ -219,5 +229,17 @@ module Gem2Deb
         end
     end
 
+    def make
+      @make ||= Gem2Deb::Make.new
+    end
+
+    def destdir_for(binary_package, dh_auto_install_destdir)
+      if ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR']
+        dh_auto_install_destdir
+      else
+        File.join('debian', binary_package.to_s)
+      end
+    end
+
   end
 end
diff --git a/lib/gem2deb/installer.rb b/lib/gem2deb/installer.rb
index 4614c40..ecf18d8 100644
--- a/lib/gem2deb/installer.rb
+++ b/lib/gem2deb/installer.rb
@@ -16,7 +16,7 @@ module Gem2Deb
 
     attr_reader :ruby_versions
     attr_accessor :verbose
-    attr_accessor :dh_auto_install_destdir
+    attr_accessor :destdir_base
 
     def initialize(binary_package, root, ruby_versions = SUPPORTED_RUBY_VERSIONS.keys)
       @binary_package = binary_package
@@ -169,14 +169,6 @@ module Gem2Deb
       end
     end
 
-    def destdir_base
-      if ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR']
-        self.dh_auto_install_destdir
-      else
-        File.join('debian', binary_package)
-      end
-    end
-
     JUNK_FILES = %w( RCSLOG tags TAGS .make.state .nse_depinfo )
     HOOK_FILES = %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt|
       %w( config setup install clean ).map {|t| sprintf(fmt, t) }
diff --git a/lib/gem2deb/make.rb b/lib/gem2deb/make.rb
new file mode 100644
index 0000000..ac21e3d
--- /dev/null
+++ b/lib/gem2deb/make.rb
@@ -0,0 +1,49 @@
+module Gem2Deb
+
+  class Make
+
+    include Gem2Deb
+
+    def initialize
+      init_builders
+    end
+
+    def clean
+      run_builders(:clean, true)
+    end
+
+    def build
+      run_builders
+    end
+
+    def install(destdir)
+      run_builders([:install, "DESTDIR=#{destdir}"])
+    end
+
+    protected # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+    def init_builders
+      @builders = []
+      if File.exists?('debian/dh_ruby.mk')
+        @builders << ['make', '-f', 'debian/dh_ruby.mk']
+      end
+      if File.exists?('debian/dh_ruby.rake')
+        @builders << ['rake', '-f', 'debian/dh_ruby.rake']
+      end
+    end
+
+    def run_builders(target=nil, ignore_failure=false)
+      @builders.each do |builder|
+        begin
+          cmdline = (builder + Array(target).map(&:to_s)).compact
+          run(*cmdline)
+        rescue Gem2Deb::CommandFailed
+          raise unless ignore_failure
+        end
+      end
+    end
+
+  end
+
+
+end
diff --git a/lib/gem2deb/version.rb b/lib/gem2deb/version.rb
index 48ebdf0..8e4ef1c 100644
--- a/lib/gem2deb/version.rb
+++ b/lib/gem2deb/version.rb
@@ -1,3 +1,3 @@
 module Gem2Deb
-  VERSION = '0.11'
+  VERSION = '0.12'
 end
diff --git a/test/unit/dh_ruby_test.rb b/test/unit/dh_ruby_test.rb
index 36caa94..3d45b05 100644
--- a/test/unit/dh_ruby_test.rb
+++ b/test/unit/dh_ruby_test.rb
@@ -145,6 +145,23 @@ class DhRubyTest < Gem2DebTestCase
 
   end
 
+  context 'DESTDIR' do
+    setup do
+      @dh_ruby = Gem2Deb::DhRuby.new
+    end
+    should 'be debian/${binary_package} by default' do
+      assert_match /debian\/ruby-foo$/, @dh_ruby.send(:destdir_for, 'ruby-foo', 'debian/tmp')
+    end
+    should 'install to debian/tmp when DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR is set' do
+      saved_env = ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR']
+      ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] = 'yes'
+
+      assert_equal 'debian/tmp', @dh_ruby.send(:destdir_for, 'ruby-foo', 'debian/tmp')
+
+      ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] = saved_env
+    end
+  end
+
   protected
 
   def read_installed_file(gem_dirname, package, path)
diff --git a/test/unit/installer_test.rb b/test/unit/installer_test.rb
index 7466567..f92c1e6 100644
--- a/test/unit/installer_test.rb
+++ b/test/unit/installer_test.rb
@@ -143,24 +143,6 @@ class InstallerTest < Gem2DebTestCase
 
   end
 
-  context 'DESTDIR' do
-    setup do
-      @installer = Gem2Deb::Installer.new('ruby-foo', FOO)
-      @installer.dh_auto_install_destdir = '/path/to/source-package/debian/tmp'
-    end
-    should 'be debian/${binary_package} by default' do
-      assert_match /\/debian\/ruby-foo$/, @installer.send(:destdir, :root)
-    end
-    should 'install to debian/tmp when DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR is set' do
-      saved_env = ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR']
-      ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] = 'yes'
-
-      assert_equal '/path/to/source-package/debian/tmp', @installer.send(:destdir, :root)
-
-      ENV['DH_RUBY_USE_DH_AUTO_INSTALL_DESTDIR'] = saved_env
-    end
-  end
-
   context "Ruby versions supported" do
     setup do
       @installer = Gem2Deb::Installer.new('ruby-foo', FOO)

-- 
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