The following commit has been merged in the master branch: commit ae4319936099f377f9786dd7b33468d32238eb11 Author: Bernhard R. Link <brl...@debian.org> Date: Thu Mar 15 11:25:39 2012 +0100
dpkg-buildflags: Add --status action to describe the flag settings It's hard to see from a build log file what values should have been used and why. The new --status action added by this patch tries to output all meaningful information in a way useful for human consumption and for automatic log parsers. [guil...@debian.org: - Mark dpkg-buildflags as bold in man page and escape dash. - Use report("status", string). ] Closes: #664058 Signed-off-by: Bernhard R. Link <brl...@debian.org> Signed-off-by: Guillem Jover <guil...@debian.org> diff --git a/debian/changelog b/debian/changelog index 86f39d0..83c1bf7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,10 @@ dpkg (1.16.5) UNRELEASED; urgency=low patches to be kept applied after build (used by formats "2.0" and "3.0 (quilt)"). Closes: #643043 + [ Guillem Jover ] + * Add a dpkg-buildflags --status action to describe the flag settings. + Thanks to Bernhard R. Link <brl...@debian.org>. Closes: #664058 + [ Updated dpkg translations ] * Swedish (Peter Krefting). diff --git a/man/dpkg-buildflags.1 b/man/dpkg-buildflags.1 index abfd143..ea61306 100644 --- a/man/dpkg-buildflags.1 +++ b/man/dpkg-buildflags.1 @@ -72,6 +72,16 @@ Print the list of flags supported by the current vendor (one per line). See the \fBSUPPORTED FLAGS\fP section for more information about them. .TP +.BI \-\-status +Display any information that can be useful to explain the behaviour of +\fBdpkg\-buildflags\fP: relevant environment variables, current vendor, +state of all feature flags. Also print the resulting compiler flags with +their origin. + +This is intended to be run from \fBdebian/rules\fP, so that the build log +keeps a clear trace of the build flags used. This can be useful to diagnose +problems related to them. +.TP .BI \-\-export= format Print to standard output shell (if \fIformat\fP is \fBsh\fP) or make (if \fIformat\fP is \fBmake\fP) commands that can be used to export diff --git a/scripts/dpkg-buildflags.pl b/scripts/dpkg-buildflags.pl index c273615..da9aa28 100755 --- a/scripts/dpkg-buildflags.pl +++ b/scripts/dpkg-buildflags.pl @@ -22,8 +22,9 @@ use warnings; use Dpkg; use Dpkg::Gettext; -use Dpkg::ErrorHandling; +use Dpkg::ErrorHandling qw(report); use Dpkg::BuildFlags; +use Dpkg::Vendor qw(get_current_vendor); textdomain("dpkg-dev"); @@ -52,6 +53,9 @@ sub usage { compilation flags in a shell script, in make, or on a ./configure command line. --dump output all compilation flags with their values + --status print a synopsis with all parameters affecting the + behaviour of dpkg-buildflags and the resulting flags + and their origin. --help show this help message. --version show the version. "), $progname; @@ -72,7 +76,7 @@ while (@ARGV) { if defined($action); my $type = $1 || "sh"; $action = "export-$type"; - } elsif (m/^--(list|dump)$/) { + } elsif (m/^--(list|status|dump)$/) { usageerr(_g("two commands specified: --%s and --%s"), $1, $action) if defined($action); $action = $1; @@ -143,6 +147,40 @@ if ($action eq "get") { print "$flag=$value\n"; } exit(0); +} elsif ($action eq "status") { + # Prefix everything with "dpkg-buildflags: status: " to allow easy + # extraction from a build log. Thus we use report with a non-translated + # type string. + + # First print all environment variables that might have changed the + # results (only existing ones, might make sense to add an option to + # also show which ones could have set to modify it). + my @envvars = Dpkg::BuildEnv::list_accessed(); + for my $envvar (@envvars) { + if (exists $ENV{$envvar}) { + printf report("status", "environment variable %s=%s", + $envvar, $ENV{$envvar}); + } + } + my $vendor = Dpkg::Vendor::get_current_vendor() || "undefined"; + print report("status", "vendor is $vendor"); + # Then the resulting features: + foreach my $area (sort $build_flags->get_feature_areas()) { + my $fs; + my %features = $build_flags->get_features($area); + foreach my $feature (sort keys %features) { + $fs .= sprintf(" %s=%s", $feature, $features{$feature} ? "yes" : "no"); + } + print report("status", "$area features:$fs"); + } + # Then the resulting values (with their origin): + foreach my $flag ($build_flags->list()) { + my $value = $build_flags->get($flag); + my $origin = $build_flags->get_origin($flag); + my $maintainer = $build_flags->is_maintainer_modified($flag) ? "+maintainer" : ""; + print report("status", "$flag [$origin$maintainer]: $value"); + } + exit(0); } exit(1); -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org