[DRE-commits] [SCM] gem2deb.git branch, master, updated. ef9f896019a7b3d962a858234b168ce4b2b52cf7

Vincent Fourmond fourmond at debian.org
Wed May 11 16:12:34 UTC 2011


The following commit has been merged in the master branch:
commit ef9f896019a7b3d962a858234b168ce4b2b52cf7
Author: Vincent Fourmond <fourmond at debian.org>
Date:   Wed May 11 18:06:44 2011 +0200

    Move the setuprb code into a subclass of DhRuby (thanks Antonio for the suggestion)

diff --git a/bin/dh_ruby b/bin/dh_ruby
index 97d97f7..eafcd1f 100755
--- a/bin/dh_ruby
+++ b/bin/dh_ruby
@@ -20,7 +20,8 @@ require 'gem2deb/dh_ruby'
 require 'optparse'
 include Gem2Deb
 
-setuprb = false
+cls = DhRuby
+
 
 optparse = OptionParser.new do |opts|
   opts.on('-h', '--help', 'show help') do
@@ -29,7 +30,7 @@ optparse = OptionParser.new do |opts|
   end
 
   opts.on('', '--setuprb', 'use setup.rb for installation') do
-    setuprb = true
+    cls = DhRubySetupRb
   end
 
   opts.on('-v', '--version', 'show dh_ruby version') do
@@ -38,27 +39,27 @@ optparse = OptionParser.new do |opts|
   end
 
   opts.on('', '--clean', 'debhelper clean helper') do
-    DhRuby::new(setuprb).clean
+    cls.new.clean
     exit(0)
   end
 
   opts.on('', '--configure', 'debhelper configure helper') do
-    DhRuby::new(setuprb).configure
+    cls.new.configure
     exit(0)
   end
 
   opts.on('', '--build', 'debhelper build helper') do
-    DhRuby::new(setuprb).build
+    cls.new.build
     exit(0)
   end
 
   opts.on('', '--test', 'debhelper test helper') do
-    DhRuby::new(setuprb).test
+    cls.new.test
     exit(0)
   end
 
   opts.on('', '--install', 'debhelper install helper') do
-    DhRuby::new(setuprb).install(ARGV)
+    cls.new.install(ARGV)
     exit(0)
   end
 end
diff --git a/lib/gem2deb/dh_ruby.rb b/lib/gem2deb/dh_ruby.rb
index 0102c81..4a78452 100644
--- a/lib/gem2deb/dh_ruby.rb
+++ b/lib/gem2deb/dh_ruby.rb
@@ -59,15 +59,11 @@ module Gem2Deb
 
     attr_reader :metadata
 
-    # Whether we run the standard dh_ruby build or the setuprb one
-    attr_reader :setuprb
-
-    def initialize(setuprb = false)
+    def initialize
       @verbose = true
       @bindir = '/usr/bin'
       @skip_checks = nil
       @metadata = Gem2Deb::Metadata.new('.')
-      @setuprb = setuprb
     end
     
     def clean
@@ -107,12 +103,7 @@ module Gem2Deb
 
       package = packages.first
 
-      if setuprb
-        setuprb_install(package, supported_versions)
-      else
-        traditional_install(package, supported_versions)
-      end
-        
+      internal_install(package, supported_versions)
 
       File::open("debian/#{package}.substvars", "a") do |fd|
         fd.puts "ruby:Versions=#{supported_versions.join(' ')}"
@@ -150,42 +141,9 @@ module Gem2Deb
       end
     end
 
-    def spawn(cmd)
-      puts cmd
-      if ! system(cmd)
-        puts " -> failed"
-        exit(1)
-      end
-    end
-    # Here comes the code for installation specific to the traditional
-    # installation scheme.
-    def setuprb_install(package, supported_versions)
-      for rubyver in supported_versions
-        ruby = SUPPORTED_RUBY_VERSIONS[rubyver]
-        siteruby = destdir(package, :libdir, rubyver)
-        bindir = destdir(package, :bindir, rubyver)
-        archdir = destdir(package, :archdir, rubyver)
-        prefix = destdir(package, :prefix, rubyver)
-
-        # First configure
-        spawn("#{ruby} setup.rb config --prefix=#{prefix} --bindir=#{bindir} --siteruby=#{siteruby} --siterubyver=#{siteruby} --siterubyverarch=#{archdir}")
-
-        # Then setup
-        spawn("#{ruby} setup.rb setup")
-
-        # Then install
-        spawn("#{ruby} setup.rb install")
-
-        # Then clean
-        spawn("#{ruby} setup.rb clean")
-        
-      end
-    end
-
-
     # Here comes the code for installation specific to the traditional
-    # installation scheme.
-    def traditional_install(package, supported_versions)
+    # build.
+    def internal_install(package, supported_versions)
       install_files('bin', find_files('bin'), destdir(package, :bindir), 755) if File::directory?('bin')
 
       install_files('lib', find_files('lib'), destdir(package, :libdir), 644) if File::directory?('lib')
@@ -471,4 +429,43 @@ module Gem2Deb
       end
     end
   end
+
+  class DhRubySetupRb < DhRuby
+
+    def spawn(cmd)
+      puts cmd
+      if ! system(cmd)
+        puts " -> failed"
+        exit(1)
+      end
+    end
+
+    # Here comes the code for installation specific to the setup.rb
+    # build.
+    def internal_install(package, supported_versions)
+      for rubyver in supported_versions
+        ruby = SUPPORTED_RUBY_VERSIONS[rubyver]
+        siteruby = destdir(package, :libdir, rubyver)
+        bindir = destdir(package, :bindir, rubyver)
+        archdir = destdir(package, :archdir, rubyver)
+        prefix = destdir(package, :prefix, rubyver)
+
+        # First configure
+        spawn("#{ruby} setup.rb config --prefix=#{prefix} --bindir=#{bindir} --siteruby=#{siteruby} --siterubyver=#{siteruby} --siterubyverarch=#{archdir}")
+
+        # Then setup
+        spawn("#{ruby} setup.rb setup")
+
+        # Then install
+        spawn("#{ruby} setup.rb install")
+
+        # Then clean
+        spawn("#{ruby} setup.rb clean")
+        
+      end
+    end
+
+
+  end
+
 end

-- 
gem2deb.git



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