[dpkg] 134/192: dpkg-buildflags: Add new --query command

Ximin Luo infinity0 at debian.org
Tue Oct 17 11:04:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit 04f99e25b9d4fa3f3d63b89ae4d702364d407c26
Author: Guillem Jover <guillem at debian.org>
Date:   Fri Mar 6 23:38:05 2015 +0100

    dpkg-buildflags: Add new --query command
    
    This command is equivalent to --status but in deb822 format.
---
 debian/changelog           |  2 ++
 man/dpkg-buildflags.man    | 30 ++++++++++++++++++++++++++++++
 scripts/dpkg-buildflags.pl | 42 +++++++++++++++++++++++++++++++++++++-----
 3 files changed, 69 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 078ad00..6bba86b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -23,6 +23,8 @@ dpkg (1.19.0) UNRELEASED; urgency=medium
     --rules-target.
   * Add support for rootless builds in dpkg-buildpackage by honoring the
     Rules-Requires-Root (R³) field.
+  * Add new dpkg-buildflags --query command, which is like --status but in
+    deb822 format.
   * Perl modules:
     - Switch from Dpkg::Util to List::Util, now that the module in the
       new required Perl contains the needed functions.
diff --git a/man/dpkg-buildflags.man b/man/dpkg-buildflags.man
index 3b5d5ba..6bfd059 100644
--- a/man/dpkg-buildflags.man
+++ b/man/dpkg-buildflags.man
@@ -134,6 +134,36 @@ the flag is set/modified by a user-specific configuration;
 the flag is set/modified by an environment-specific configuration.
 .RE
 .TP
+.BI \-\-query
+Print any information that can be useful to explain the behaviour of the
+program: current vendor, relevant environment variables, feature areas,
+state of all feature flags, and the compiler flags with their origin
+(since dpkg 1.19.0).
+.IP
+For example:
+.nf
+  Vendor: Debian
+  Environment:
+   DEB_CFLAGS_SET=-O0 -Wall
+
+  Area: qa
+  Features:
+   bug=no
+   canary=no
+
+  Area: reproducible
+  Features:
+   timeless=no
+
+  Flag: CFLAGS
+  Value: -O0 -Wall
+  Origin: env
+
+  Flag: CPPFLAGS
+  Value: -D_FORTIFY_SOURCE=2
+  Origin: vendor
+.fi
+.TP
 .BI \-\-query\-features " area"
 Print the features enabled for a given area (since dpkg 1.16.2).
 The only currently recognized
diff --git a/scripts/dpkg-buildflags.pl b/scripts/dpkg-buildflags.pl
index b696b08..825e92b 100755
--- a/scripts/dpkg-buildflags.pl
+++ b/scripts/dpkg-buildflags.pl
@@ -47,16 +47,16 @@ sub usage {
   --get <flag>       output the requested flag to stdout.
   --origin <flag>    output the origin of the flag to stdout:
                      value is one of vendor, system, user, env.
+  --status           output a synopsis with all parameters affecting the
+                     program behaviour, the resulting flags and their origin.
+  --query            like --status, but in deb822 format.
   --query-features <area>
                      output the status of features for the given area.
   --list             output a list of the flags supported by the current vendor.
   --export=(sh|make|cmdline|configure)
                      output something convenient to import the compilation
                      flags in a shell script, in make, or in a 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.
+  --dump             output all compilation flags with their values.
   --help             show this help message.
   --version          show the version.
 '), $Dpkg::PROGNAME;
@@ -80,7 +80,7 @@ while (@ARGV) {
         # Map legacy aliases.
         $type = 'cmdline' if $type eq 'configure';
         $action = "export-$type";
-    } elsif (m/^--(list|status|dump)$/) {
+    } elsif (m/^--(list|status|dump|query)$/) {
         usageerr(g_('two commands specified: --%s and --%s'), $1, $action)
             if defined($action);
         $action = $1;
@@ -144,6 +144,38 @@ if ($action eq 'list') {
 	my $value = $build_flags->get($flag);
 	print "$flag=$value\n";
     }
+} elsif ($action eq 'query') {
+    # 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).
+    printf "Vendor: %s\n", Dpkg::Vendor::get_current_vendor() || 'undefined';
+    print "Environment:\n";
+    for my $envvar (Dpkg::Build::Env::list_accessed()) {
+        print " $envvar=$ENV{$envvar}\n" if exists $ENV{$envvar};
+    }
+
+    # Then the resulting features:
+    foreach my $area (sort $build_flags->get_feature_areas()) {
+        print "\n";
+        print "Area: $area\n";
+        print "Features:\n";
+        my %features = $build_flags->get_features($area);
+        foreach my $feature (sort keys %features) {
+            printf " %s=%s\n", $feature, $features{$feature} ? 'yes' : 'no';
+        }
+    }
+
+    # Then the resulting values (with their origin):
+    foreach my $flag ($build_flags->list()) {
+        print "\n";
+        print "Flag: $flag\n";
+        printf "Value: %s\n", $build_flags->get($flag);
+        my $origin = $build_flags->get_origin($flag);
+        if ($build_flags->is_maintainer_modified($flag)) {
+            $origin .= '+maintainer';
+        }
+        print "Origin: $origin\n";
+    }
 } 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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list