From 48ca954737890ff4661fbf88a8d90102bc85a1ec Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 13 Aug 2009 09:03:34 +0100 Subject: [PATCH] dh: Add --list option to list available addons. --- debian/changelog | 6 ++++++ dh | 32 +++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index cf1bcd3..7df41d4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +debhelper (7.3.14) UNRELEASED; urgency=low + + * dh: Add --list option to list available addons. + + -- Colin Watson Thu, 13 Aug 2009 09:00:24 +0100 + debhelper (7.3.13) unstable; urgency=low [ Bernd Zeimetz ] diff --git a/dh b/dh index 2a6c0a3..2e7385f 100755 --- a/dh +++ b/dh @@ -8,10 +8,11 @@ dh - debhelper command sequencer use strict; use Debian::Debhelper::Dh_Lib; +use File::Spec; =head1 SYNOPSIS -B sequence [B<--with> I[,I,...]] [B<--until> I] [B<--before> I] [B<--after> I] [B<--remaining>] [S>] +B sequence [B<--with> I[,I,...]] [B<--list>] [B<--until> I] [B<--before> I] [B<--after> I] [B<--remaining>] [S>] =head1 DESCRIPTION @@ -58,6 +59,10 @@ the sequence addon interface. The inverse of --with, disables using the given addon. +=item B<--list>, B<-l> + +List all available addons. + =item B<--until> I Run commands in the sequence until and including I, then stop. @@ -216,6 +221,8 @@ init(options => { my ($option,$value)=@_; @{$dh{WITH}} = grep { $_ ne $value } @{$dh{WITH}}; }, + "l" => \$dh{LIST}, + "list" => \$dh{LIST}, }); inhibit_log(); @@ -327,6 +334,29 @@ sub add_command { my $sequence=shift; unshift @{$sequences{$sequence}}, $command; } + +if ($dh{LIST}) { + my %addons; + + for my $inc (@INC) { + my $path = File::Spec->catdir($inc, "Debian/Debhelper/Sequence"); + if (-d $path) { + for my $module_path (glob "$path/*.pm") { + my $name = basename($module_path); + $name =~ s/\.pm$//; + $name =~ s/_/-/g; + $addons{$name} = 1; + } + } + } + + for my $name (sort keys %addons) { + print "$name\n"; + } + + exit 0; +} + foreach my $addon (@{$dh{WITH}}) { my $mod="Debian::Debhelper::Sequence::$addon"; $mod=~s/-/_/g; -- 2.39.2