Browse Source

dpkg-genbuildinfo: Add initial support for DEB_BUILD_OPTIONS

This will make it possible to enable or disable specific features that
should be recorded in the .buildinfo file. For now only “all” and “path”
are supported.

Closes: #848705
Guillem Jover 7 years ago
parent
commit
feab90e61d
3 changed files with 27 additions and 3 deletions
  1. 4 0
      debian/changelog
  2. 14 0
      man/dpkg-genbuildinfo.man
  3. 9 3
      scripts/dpkg-genbuildinfo.pl

+ 4 - 0
debian/changelog

@@ -20,6 +20,10 @@ dpkg (1.18.19) UNRELEASED; urgency=medium
     hurd-i386 will still match), it will filter lots of previously matching
     objects that should have been ignored, and will work even when objdump
     does not know about the specific object details. Closes: #849913
+  * Add initial support for DEB_BUILD_OPTIONS to dpkg-genbuildinfo. This will
+    make it possible to enable or disable specific features that should be
+    recorded in the .buildinfo file. For now only “all” and “path” are
+    supported. Closes: #848705
   * Portability:
     - On GNU/Hurd try to use the new process executable name attribute from
       libps, to properly match on start-stop-daemon --exec.

+ 14 - 0
man/dpkg-genbuildinfo.man

@@ -130,6 +130,20 @@ Show the usage message and exit.
 .BR \-\-version
 Show the version and exit.
 .
+.SH ENVIRONMENT
+.TP
+.B DEB_BUILD_OPTIONS
+This variable can be used to enable or disable various features that affect
+the information included in the .buildinfo file, via the \fBbuildinfo\fP
+option (since dpkg 1.18.19).
+This option contains a comma-separated list of features, prefixed with the
+‘\fB+\fP’ or ‘\fB\-\fP’ modifiers, to denote whether to enable or disable
+them.
+The special feature “\fBall\fP” can be used to enable or disable all other
+features.
+The feature “\fBpath\fP” controls whether to unconditionally include the
+\fBBuild\-Path\fP field.
+.
 .SH FILES
 .TP
 .B debian/files

+ 9 - 3
scripts/dpkg-genbuildinfo.pl

@@ -36,6 +36,7 @@ use Dpkg::ErrorHandling;
 use Dpkg::Arch qw(get_build_arch get_host_arch);
 use Dpkg::Build::Types;
 use Dpkg::Build::Info qw(get_build_env_whitelist);
+use Dpkg::BuildOptions;
 use Dpkg::BuildFlags;
 use Dpkg::BuildProfiles qw(get_build_profiles);
 use Dpkg::Control::Info;
@@ -59,7 +60,9 @@ my $uploadfilesdir = '..';
 my $outputfile;
 my $stdout = 0;
 my $admindir = $Dpkg::ADMINDIR;
-my $always_include_path = 0;
+my %use_feature = (
+    path => 0,
+);
 my @build_profiles = get_build_profiles();
 my $buildinfo_format = '0.2';
 my $buildinfo;
@@ -295,6 +298,9 @@ sub usage {
 "), $Dpkg::PROGNAME;
 }
 
+my $build_opts = Dpkg::BuildOptions->new();
+$build_opts->parse_features('buildinfo', \%use_feature);
+
 while (@ARGV) {
     $_ = shift @ARGV ;
     if (m/^--build=(.*)$/) {
@@ -317,7 +323,7 @@ while (@ARGV) {
         # Deprecated option
         warning('--buildinfo-id is deprecated, it is without effect');
     } elsif (m/^--always-include-path$/) {
-        $always_include_path = 1;
+        $use_feature{path} = 1;
     } elsif (m/^--admindir=(.*)$/) {
         $admindir = $1;
     } elsif (m/^-(?:\?|-help)$/) {
@@ -407,7 +413,7 @@ $fields->{'Build-Architecture'} = get_build_arch();
 $fields->{'Build-Date'} = get_build_date();
 
 my $cwd = cwd();
-if ($always_include_path) {
+if ($use_feature{path}) {
     $fields->{'Build-Path'} = $cwd;
 } else {
     # Only include the build path if its root path is considered acceptable