summaryrefslogtreecommitdiff
path: root/Debian/Debhelper/Dh_Lib.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-02-10 19:56:44 -0400
committerJoey Hess <joey@kitenet.net>2011-02-10 19:56:51 -0400
commit7fa165faff3df27694cbe9e24830eefd517cc8a6 (patch)
treef5f16049fa6ff3627fec24a139b1b656dfbd17dc /Debian/Debhelper/Dh_Lib.pm
parent14e02173f2eb2ceeffa719c284fd77f25e03576b (diff)
Improve handling of logging in override targets
Changes in 76ef1cbd64829ee4a5156a5fc4b887bcba6b974f broke --remaining-packages in override target. Now all debhelper commands run in the override target are marked as running as part of the override, and when the whole target is run, the log is updated to indicate that commands run during the override have finished. So, inside the override target, --remaining-packages will see the commands run as part of the target as having been run. Outside, if the target fails, dh won't see the commands run it it as having been run. Closes: #612828
Diffstat (limited to 'Debian/Debhelper/Dh_Lib.pm')
-rw-r--r--Debian/Debhelper/Dh_Lib.pm51
1 files changed, 40 insertions, 11 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 9b6118e..0177721 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -15,8 +15,8 @@ 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 &load_log &write_log &dpkg_architecture_value
- &sourcepackage
+ &inhibit_log &load_log &write_log &commit_override_log
+ &dpkg_architecture_value &sourcepackage
&is_make_jobserver_unavailable &clean_jobserver_makeflags
&cross_command);
@@ -107,16 +107,36 @@ sub END {
}
}
+sub logfile {
+ my $package=shift;
+ my $ext=pkgext($package);
+ return "debian/${ext}debhelper.log"
+}
+
+sub add_override {
+ my $line=shift;
+ $line="override_$ENV{DH_INTERNAL_OVERRIDE} $line"
+ if defined $ENV{DH_INTERNAL_OVERRIDE};
+ return $line;
+}
+
+sub remove_override {
+ my $line=shift;
+ $line=~s/^\Qoverride_$ENV{DH_INTERNAL_OVERRIDE}\E\s+//
+ if defined $ENV{DH_INTERNAL_OVERRIDE};
+ return $line;
+}
+
sub load_log {
my ($package, $db)=@_;
- my $ext=pkgext($package);
my @log;
- open(LOG, "<", "debian/${ext}debhelper.log") || return;
+ open(LOG, "<", logfile($package)) || return;
while (<LOG>) {
chomp;
- push @log, $_;
- $db->{$package}{$_}=1 if defined $db;
+ my $command=remove_override($_);
+ push @log, $command;
+ $db->{$package}{$command}=1 if defined $db;
}
close LOG;
return @log;
@@ -126,13 +146,22 @@ sub write_log {
my $cmd=shift;
my @packages=@_;
- return if defined $ENV{DH_INHIBIT_LOG} && $cmd eq $ENV{DH_INHIBIT_LOG};
-
foreach my $package (@packages) {
- my $ext=pkgext($package);
- my $log="debian/${ext}debhelper.log";
+ my $log=logfile($package);
open(LOG, ">>", $log) || error("failed to write to ${log}: $!");
- print LOG $cmd."\n";
+ print LOG add_override($cmd)."\n";
+ close LOG;
+ }
+}
+
+sub commit_override_log {
+ my @packages=@_;
+
+ foreach my $package (@packages) {
+ my @log=map { remove_override($_) } load_log($package);
+ my $log=logfile($package);
+ open(LOG, ">", $log) || error("failed to write to ${log}: $!");
+ print LOG $_."\n" foreach @log;
close LOG;
}
}