]> git.donarmstrong.com Git - debhelper.git/commitdiff
dh addon interface 7.0.8
authorJoey Hess <joey@kodama.kitenet.net>
Sun, 4 May 2008 20:12:55 +0000 (16:12 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Sun, 4 May 2008 20:12:55 +0000 (16:12 -0400)
* dh: Add an interface that third-party packages providing debhelper commands
  can use to insert them into a command sequence.
  (See dh(1), "SEQUENCE ADDONS".)
* dh: --with=foo can be used to include such third-party commands.
  So, for example, --with=cli could add the dh_cli* commands from
  cli-common.
* Moved python-support special case out of dh and into a python-support
  sequence addon. --with=python-support is enabled by default to avoid
  breaking backwards compatability.

Debian/Debhelper/Dh_Getopt.pm
Debian/Debhelper/Sequence/python_support.pm [new file with mode: 0644]
Makefile
debian/changelog
dh

index 55e37fd22a86ec42bd7fb974306308139a3a5d30..77e4a7236e7320c87004077baa931036eb08e3d5 100644 (file)
@@ -68,6 +68,11 @@ sub AddIgnore { my($option,$file)=@_;
        $options{IGNORE}->{$file}=1;
 }
 
+# Add an item to the with list.
+sub AddWith { my($option,$value)=@_;
+       push @{$options{WITH}},$value;
+}
+
 # This collects non-options values.
 sub NonOption {
        push @{$options{ARGV}}, @_;
@@ -180,6 +185,7 @@ sub parseopts {
                "after=s" => \$options{AFTER},
                "before=s" => \$options{BEFORE},
                "remaining" => \$options{REMAINING},
+               "with=s" => \&AddWith,
 
                "<>" => \&NonOption,
        );
diff --git a/Debian/Debhelper/Sequence/python_support.pm b/Debian/Debhelper/Sequence/python_support.pm
new file mode 100644 (file)
index 0000000..3d03ebb
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+# debhelper sequence file for python-support
+
+use warnings;
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+# Test if dh_pysupport is available before inserting it.
+# (This would not be needed if this file was contained in the python-support
+# package.)
+if (-x "/usr/bin/dh_pysupport") {
+       insert_after("dh_perl", "dh_pysupport");
+}
+
+1
index 5d64ab950ae34b7bbbc8dedc6daf007bd6fe25fe..6cf714cdf712c3d29cbbb971d073df780aa7bd9d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -63,10 +63,11 @@ clean:
 install:
        install -d $(DESTDIR)/usr/bin \
                $(DESTDIR)/usr/share/debhelper/autoscripts \
-               $(DESTDIR)$(PERLLIBDIR)
+               $(DESTDIR)$(PERLLIBDIR)/Sequence
        install $(shell find -maxdepth 1 -mindepth 1 -name dh\* |grep -v \.1\$$) $(DESTDIR)/usr/bin
        install -m 0644 autoscripts/* $(DESTDIR)/usr/share/debhelper/autoscripts
        install -m 0644 Debian/Debhelper/*.pm $(DESTDIR)$(PERLLIBDIR)
+       install -m 0644 Debian/Debhelper/Sequence/*.pm $(DESTDIR)$(PERLLIBDIR)/Sequence
 
 test: version
        ./run perl -MTest::Harness -e 'runtests grep { ! /CVS/ && ! /\.svn/ } @ARGV' t/*
index e16b8a30f1c065879a6d4e3c1256c7ca6b9e296d..c18bb7e01a18632f9c7c3eec688373c798cc588e 100644 (file)
@@ -1,3 +1,17 @@
+debhelper (7.0.8) unstable; urgency=low
+
+  * dh: Add an interface that third-party packages providing debhelper commands
+    can use to insert them into a command sequence. 
+    (See dh(1), "SEQUENCE ADDONS".)
+  * dh: --with=foo can be used to include such third-party commands.
+    So, for example, --with=cli could add the dh_cli* commands from
+    cli-common.
+  * Moved python-support special case out of dh and into a python-support
+    sequence addon. --with=python-support is enabled by default to avoid
+    breaking backwards compatability.
+
+ -- Joey Hess <joeyh@debian.org>  Sun, 04 May 2008 16:10:54 -0400
+
 debhelper (7.0.7) unstable; urgency=low
 
   * dh_installxfonts: Fix precidence problem that exposes a new warning
diff --git a/dh b/dh
index df5bccd84c07a62c6c02855a2ba1d6e8a639d2e7..fec1debba93d7fd1fc996bcc59b31bd2281bcf48 100755 (executable)
--- a/dh
+++ b/dh
@@ -11,7 +11,7 @@ use Debian::Debhelper::Dh_Lib;
 
 =head1 SYNOPSIS
 
-B<dh> sequence [B<--until> I<cmd>] [B<--before> I<cmd>] [B<--after> I<cmd>] [B<--remaining>] [S<I<debhelper options>>]
+B<dh> sequence [B<--until> I<cmd>] [B<--before> I<cmd>] [B<--after> I<cmd>] [B<--remaining>] [B<--with> I<addon>] [S<I<debhelper options>>]
 
 =head1 DESCRIPTION
 
@@ -54,6 +54,14 @@ Run commands in the sequence that come after I<cmd>.
 
 Run all commands in the sequence that have yet to be run.
 
+=item B<--with> I<addon>
+
+Add the debhelper commands specified by the given addon to appropriate places
+in the sequence of commands that is run. This option can be repeated more
+than once, and is used when there is a third-party package that provides
+debhelper commands. See "SEQUENCE ADDONS" below for documentation about what
+such packages should do to be supported by --with.
+
 =back
 
 All other options passed to dh are passed on to each command it runs. This
@@ -67,6 +75,22 @@ search for a command in the sequence exactly matching the name, to avoid any
 ambiguity. If there are multiple substring matches, the last one in the
 sequence will be used.
 
+=head1 SEQUENCE ADDONS
+
+When B<--with> I<addon> is used, dh loads the perl module
+Debian::Debhelper::Sequence::I<addon>. Two functions are provided to let
+the module add its commands to sequences:
+
+=over 4
+
+=item Debian::Debhelper::Dh_Lib::insert_before(existing_command, new_command)
+
+Insert I<new_command> in sequences before I<existing_command>.
+
+=item Debian::Debhelper::Dh_Lib::insert_after(existing_command, new_command)
+
+Insert I<new_command> in sequences after I<existing_command>.
+
 =cut
 
 sub command_pos {
@@ -230,7 +254,6 @@ $sequences{install} = [@{$sequences{build}}, qw{
        dh_gconf
        dh_icons
        dh_perl
-       dh_pysupport
        dh_scrollkeeper
        dh_usrlocal
 
@@ -252,12 +275,45 @@ $sequences{binary} = [@{$sequences{install}}, qw{
 }, @b];
 $sequences{'binary-arch'} = [@{$sequences{binary}}];
 
-# Third-party commands can be listed in the sequences, but should be
-# listed here as well. They will not be run if not present.
-my %thirdparty=map { $_ => 1 } qw{
-       dh_pycentral
-       dh_pysupport
-};
+# --with python-support is enabled by default, at least for now
+push @{$dh{WITH}}, "python-support";
+
+# sequence addon interface
+sub _insert {
+       my $offset=shift;
+       my $existing=shift;
+       my $new=shift;
+       foreach my $sequence (keys %sequences) {
+               my @list=@{$sequences{$sequence}};
+               next unless grep $existing, @list;
+               my @new;
+               foreach my $command (@list) {
+                       if ($command eq $existing) {
+                               push @new, $new if $offset < 0;
+                               push @new, $command;
+                               push @new, $new if $offset > 0;
+                       }
+                       else {
+                               push @new, $command;
+                       }
+               }
+               $sequences{$sequence}=\@new;
+       }
+}
+sub insert_before {
+       _insert(-1, @_);
+}
+sub insert_after {
+       _insert(1, @_);
+}
+foreach my $addon (@{$dh{WITH}}) {
+       my $mod="Debian::Debhelper::Sequence::$addon";
+       $mod=~s/-/_/g;
+       eval "use $mod";
+       if ($@) {
+               error("--with $addon not supported or failed to load module $mod");
+       }
+}
 
 # Get the sequence of commands to run.
 if (! @ARGV) {
@@ -378,11 +434,6 @@ sub run {
        my $command=shift;
        my @options=@_;
        
-       # If a third party command is not in /usr/bin, don't try to run it.
-       if ($thirdparty{$command} && ! -x "/usr/bin/$command") {
-               return;
-       }
-
        # 3 space indent lines the command being run up under the 
        # sequence name after "dh ".
        print "   ".escape_shell($command, @options)."\n";