Package: debhelper Version: 9.20140613ubuntu2 Severity: normal
Dear Maintainer, dh currently offers a '--no-act' option that will show the commands that would be run. It also displays the name of the command that failed in the event of error. This patch adds a '--show-progress' option (along with "DH_SHOW_PROGRESS" environment variable) that: 1) Displays the list (or plan) of commands that are going to be run (like '--no-act'). 2) Adds two output tags for each dh_* command called, one is emitted before the command is run and the other is emitted after the command has completed successfully. For example, if 'dh build --show-progress' is called for a program whose tests fail, a 'grep ^dh build.log' will show: dh plan: dh_testdir dh plan: dh_auto_configure dh plan: dh_auto_build dh plan: dh_auto_test dh -> dh_testdir dh <- dh_testdir dh -> dh_auto_configure dh <- dh_auto_configure dh -> dh_auto_build dh <- dh_auto_build dh -> dh_auto_test dh_auto_test: make -j1 check returned exit code 2 This makes it clear which commands dh was planning to run ('dh plan:') and which command failed (du_auto_test). The '->' ("about to call") and '<-' ("called") output is not strictly necessary to determine the failing step but are useful to watch build progress. They could also be used by other tools to create expandable "twisties" for example for a web version of a build log. This idea was inspired by perusing the excellent FTBFS page at [1]. Currently, we can see easily which packages FTBFS, but the build comprises multiple steps and having the ability to display and summarise the precise stage of the build that is failing would be highly desirable. [1] - http://people.ubuntuwire.org/~wgrant/rebuild-ftbfs-test/test-rebuild-20140914-utopic.html -- System Information: Debian Release: jessie/sid APT prefers utopic-updates APT policy: (500, 'utopic-updates'), (500, 'utopic-security'), (500, 'utopic'), (100, 'utopic-backports') Architecture: amd64 (x86_64) Foreign Architectures: i386 armhf Kernel: Linux 3.16.0-20-generic (SMP w/4 CPU cores) Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages debhelper depends on: ii binutils 2.24.51.20141001-1ubuntu2 ii dh-apparmor 2.8.96~2652-0ubuntu7 ii dpkg 1.17.13ubuntu1 ii dpkg-dev 1.17.13ubuntu1 ii file 1:5.19-1ubuntu1.1 ii man-db 2.7.0.2-1 ii perl 5.20.0-6 ii po-debconf 1.0.16+nmu3 debhelper recommends no packages. Versions of packages debhelper suggests: ii dh-make 1.20140617 -- no debconf information -- Kind regards, James -- James Hunt
From c25e8750c4b1fc9335376063efcbf0b3dc6797a8 Mon Sep 17 00:00:00 2001 From: James Hunt <james.h...@ubuntu.com> Date: Wed, 8 Oct 2014 11:30:42 +0100 Subject: [PATCH] Add '--show-progress' option. Signed-off-by: James Hunt <james.h...@ubuntu.com> --- Debian/Debhelper/Dh_Getopt.pm | 2 ++ Debian/Debhelper/Dh_Lib.pm | 4 +++ debhelper.pod | 4 +++ dh | 63 +++++++++++++++++++++++++++++++++++++++---- 4 files changed, 68 insertions(+), 5 deletions(-) diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm index e4f3e47..c236ce9 100644 --- a/Debian/Debhelper/Dh_Getopt.pm +++ b/Debian/Debhelper/Dh_Getopt.pm @@ -80,6 +80,8 @@ sub getoptions { "verbose" => \$dh{VERBOSE}, "no-act" => \$dh{NO_ACT}, + + "show-progress" => \$dh{SHOW_PROGRESS}, "i" => \&AddPackage, "indep" => \&AddPackage, diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm index 6a79c9c..8b9607e 100644 --- a/Debian/Debhelper/Dh_Lib.pm +++ b/Debian/Debhelper/Dh_Lib.pm @@ -70,6 +70,10 @@ sub init { $dh{NO_ACT}=1; } + if (defined $ENV{SHOW_PROGRESS} && $ENV{SHOW_PROGRESS} ne "") { + $dh{SHOW_PROGRESS}=1; + } + # Get the name of the main binary package (first one listed in # debian/control). Only if the main package was not set on the # command line. diff --git a/debhelper.pod b/debhelper.pod index 659c4a3..e23de14 100644 --- a/debhelper.pod +++ b/debhelper.pod @@ -663,6 +663,10 @@ overriding any value in F<debian/compat>. Set to B<1> to enable no-act mode. +=item B<DH_SHOW_PROGRESS> + +Set to B<1> to enable show-progress mode. + =item B<DH_OPTIONS> Anything in this variable will be prepended to the command line arguments diff --git a/dh b/dh index f3bd321..f11f64e 100755 --- a/dh +++ b/dh @@ -68,6 +68,15 @@ Prints commands that would run for a given sequence, but does not run them. Note that dh normally skips running commands that it knows will do nothing. With --no-act, the full list of commands in a sequence is printed. +=item B<--show-progress> + +Displays commands that are about to be run ("the plan", same output as B<--no-act>) +and then proceeds to run the commands as usual, printing a start and end tag for +every command run. + +This can be useful for scripts that parse the output to determine more easily which +step failed, and how far through the build process the failing step was. + =back Other options passed to B<dh> are passed on to each command it runs. This @@ -440,6 +449,9 @@ else { # Additional command options my %command_opts; +# array of commands to run +my @commands; + # sequence addon interface sub _insert { my $offset=shift; @@ -524,6 +536,26 @@ sub list_addons { exit 0; } +# If show_plan is set, show commands that would be run (NO_ACT), +# else run the commands. +sub run_commands { + my $commands=shift; + my $show_plan=shift; + + foreach (@{$commands}) { + + my $command = @{$_}{command}; + my $options = @{$_}{options}; + + if ($show_plan) { + print "dh plan: ".escape_shell($command, @{$options})."\n"; + next; + } + + run($command, @{$options}); + } +} + # Load addons, which can modify sequences. foreach my $addon (@{$dh{WITH}}) { my $mod="Debian::Debhelper::Sequence::$addon"; @@ -570,7 +602,7 @@ while (@ARGV_orig) { shift @ARGV_orig; next; } - elsif ($opt =~ /^--?(no-act|remaining|(after|until|before|with|without)=)/) { + elsif ($opt =~ /^--?(no-act|show-progress|remaining|(after|until|before|with|without)=)/) { next; } elsif ($opt=~/^-/) { @@ -700,9 +732,17 @@ foreach my $i (0..$stoppoint) { } } - run($command, @opts); + # Save commands to run + push @commands, {command => $command, options => \@opts}; +} + +if ($dh{SHOW_PROGRESS}) { + # show the commands before we actually start + run_commands (\@commands, 1); } +run_commands (\@commands, 0); + sub run { my $command=shift; my @options=@_; @@ -713,10 +753,19 @@ sub run { # 3 space indent lines the command being run up under the # sequence name after "dh ". - print " ".escape_shell($command, @options)."\n"; + if ($dh{SHOW_PROGRESS}) { + print "dh -> ".escape_shell($command, @options)."\n"; + } else { + print " ".escape_shell($command, @options)."\n"; + } + + if ($dh{NO_ACT}) { + print "dh <- ".escape_shell($command, @options)."\n" + if $dh{SHOW_PROGRESS}; + + return; + } - return if $dh{NO_ACT}; - my $ret=system($command, @options); if ($ret >> 8 != 0) { exit $ret >> 8; @@ -724,6 +773,10 @@ sub run { elsif ($ret) { exit 1; } + + if ($dh{SHOW_PROGRESS}) { + print "dh <- ".escape_shell($command, @options)."\n"; + } } # Tries to run an override target for a command. Returns the list of -- 2.1.0
signature.asc
Description: Digital signature