Hello,

fixed patch is attached.

-- 
Modestas Vainius <[email protected]>
From 830d6634ed3525cf2e3e816880971f8d5ff29dc6 Mon Sep 17 00:00:00 2001
From: Modestas Vainius <[email protected]>
Date: Sat, 21 Mar 2009 18:43:28 +0200
Subject: [PATCH] Add a global --remaining-packages option.

Add a global --remaining-packages option which allows to skip the command on
the packages which it has already been run on (i.e. if the command helper is
already present in the package debhelper log).

Signed-off-by: Modestas Vainius <[email protected]>
---
 Debian/Debhelper/Dh_Getopt.pm |    5 +++++
 Debian/Debhelper/Dh_Lib.pm    |   28 ++++++++++++++++++++++++++--
 debhelper.pod                 |    8 ++++++++
 dh                            |   12 +-----------
 4 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm
index ef94e94..3af3c5b 100644
--- a/Debian/Debhelper/Dh_Getopt.pm
+++ b/Debian/Debhelper/Dh_Getopt.pm
@@ -91,6 +91,8 @@ sub getoptions {
 		"N=s" => \&ExcludePackage,
 		"no-package=s" => \&ExcludePackage,
 	
+		"remaining-packages" => \$dh{EXCLUDE_LOGGED},
+	
 		"dbg-package=s" => \&AddDebugPackage,
 		
 		"s" => \&AddPackage,
@@ -222,6 +224,9 @@ sub parseopts {
 	my $package;
 	my %packages_seen;
 	foreach $package (@{$dh{DOPACKAGES}}) {
+		if (defined($dh{EXCLUDE_LOGGED}) && is_in_log($package)) {
+			$exclude_package{$package}=1;
+		}
 		if (! $exclude_package{$package}) {
 			if (! exists $packages_seen{$package}) {
 				$packages_seen{$package}=1;
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index d481128..fd96b77 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -15,7 +15,7 @@ use vars qw(@ISA @EXPORT %dh);
 	    &filedoublearray &getpackages &basename &dirname &xargs %dh
 	    &compat &addsubstvar &delsubstvar &excludefile &package_arch
 	    &is_udeb &udeb_filename &debhelper_script_subst &escape_shell
-	    &inhibit_log);
+	    &inhibit_log &is_in_log);
 
 my $max_compat=7;
 
@@ -102,7 +102,22 @@ sub END {
 	if ($? == 0 && $write_log) {
 		write_log(basename($0), @{$dh{DOPACKAGES}});
 	}
-}	
+}
+
+sub load_log {
+	my ($package, $db)=...@_;
+	my $ext=pkgext($package) || return;
+
+	my @log;
+	open(LOG, "<", "debian/${ext}debhelper.log") || return;
+	while (<LOG>) {
+		chomp;
+		push @log, $_;
+		$db->{$package}{$_}=1 if (defined $db);
+	}
+	close LOG;
+	return @log;
+}
 
 sub write_log {
 	my $cmd=shift;
@@ -121,6 +136,15 @@ sub inhibit_log {
 	$write_log=0;
 }
 
+sub is_in_log {
+	my $package=shift;
+	my %db;
+	my $cmd=basename($0);
+
+	load_log($package, \%db);
+	return exists $db{$package}{$cmd};
+}
+
 # Pass it an array containing the arguments of a shell command like would
 # be run by exec(). It turns that into a line like you might enter at the
 # shell, escaping metacharacters and quoting arguments that contain spaces.
diff --git a/debhelper.pod b/debhelper.pod
index 77ace5c..dad286e 100644
--- a/debhelper.pod
+++ b/debhelper.pod
@@ -118,6 +118,14 @@ are not architecture independent.
 Do not act on the specified package even if an -a, -i, or -p option lists
 the package as one that should be acted on.
 
+=item B<--remaining-packages>
+
+Do not act on the packages which have already been acted on by this debhelper
+command earlier (i.e. if the command is present in the package debhelper log).
+For example, if you need to call the command with special options only for a
+couple of binary packages, pass this option to the last call of the command to
+process the rest of packages with default settings. 
+
 =item B<--ignore=>I<file>
 
 Ignore the specified file. This can be used if debian/ contains a debhelper
diff --git a/dh b/dh
index 8639ed0..542eb12 100755
--- a/dh
+++ b/dh
@@ -486,17 +486,7 @@ sub run {
 
 sub loadlog {
 	my $package=shift;
-	my $ext=pkgext($package);
-	
-	my @log;
-	open(LOG, "<", "debian/${ext}debhelper.log") || return;
-	while (<LOG>) {
-		chomp;
-		push @log, $_;
-		$logged{$package}{$_}=1;
-	}
-	close LOG;
-	return @log;
+	return Debian::Debhelper::Dh_Lib::load_log($package, \%logged);
 }
 
 sub writelog {
-- 
1.6.2.1

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to