浏览代码

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 9 年之前
父节点
当前提交
feab90e61d
共有 3 个文件被更改,包括 27 次插入3 次删除
  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
     hurd-i386 will still match), it will filter lots of previously matching
     objects that should have been ignored, and will work even when objdump
     objects that should have been ignored, and will work even when objdump
     does not know about the specific object details. Closes: #849913
     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:
   * Portability:
     - On GNU/Hurd try to use the new process executable name attribute from
     - On GNU/Hurd try to use the new process executable name attribute from
       libps, to properly match on start-stop-daemon --exec.
       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
 .BR \-\-version
 Show the version and exit.
 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
 .SH FILES
 .TP
 .TP
 .B debian/files
 .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::Arch qw(get_build_arch get_host_arch);
 use Dpkg::Build::Types;
 use Dpkg::Build::Types;
 use Dpkg::Build::Info qw(get_build_env_whitelist);
 use Dpkg::Build::Info qw(get_build_env_whitelist);
+use Dpkg::BuildOptions;
 use Dpkg::BuildFlags;
 use Dpkg::BuildFlags;
 use Dpkg::BuildProfiles qw(get_build_profiles);
 use Dpkg::BuildProfiles qw(get_build_profiles);
 use Dpkg::Control::Info;
 use Dpkg::Control::Info;
@@ -59,7 +60,9 @@ my $uploadfilesdir = '..';
 my $outputfile;
 my $outputfile;
 my $stdout = 0;
 my $stdout = 0;
 my $admindir = $Dpkg::ADMINDIR;
 my $admindir = $Dpkg::ADMINDIR;
-my $always_include_path = 0;
+my %use_feature = (
+    path => 0,
+);
 my @build_profiles = get_build_profiles();
 my @build_profiles = get_build_profiles();
 my $buildinfo_format = '0.2';
 my $buildinfo_format = '0.2';
 my $buildinfo;
 my $buildinfo;
@@ -295,6 +298,9 @@ sub usage {
 "), $Dpkg::PROGNAME;
 "), $Dpkg::PROGNAME;
 }
 }
 
 
+my $build_opts = Dpkg::BuildOptions->new();
+$build_opts->parse_features('buildinfo', \%use_feature);
+
 while (@ARGV) {
 while (@ARGV) {
     $_ = shift @ARGV ;
     $_ = shift @ARGV ;
     if (m/^--build=(.*)$/) {
     if (m/^--build=(.*)$/) {
@@ -317,7 +323,7 @@ while (@ARGV) {
         # Deprecated option
         # Deprecated option
         warning('--buildinfo-id is deprecated, it is without effect');
         warning('--buildinfo-id is deprecated, it is without effect');
     } elsif (m/^--always-include-path$/) {
     } elsif (m/^--always-include-path$/) {
-        $always_include_path = 1;
+        $use_feature{path} = 1;
     } elsif (m/^--admindir=(.*)$/) {
     } elsif (m/^--admindir=(.*)$/) {
         $admindir = $1;
         $admindir = $1;
     } elsif (m/^-(?:\?|-help)$/) {
     } elsif (m/^-(?:\?|-help)$/) {
@@ -407,7 +413,7 @@ $fields->{'Build-Architecture'} = get_build_arch();
 $fields->{'Build-Date'} = get_build_date();
 $fields->{'Build-Date'} = get_build_date();
 
 
 my $cwd = cwd();
 my $cwd = cwd();
-if ($always_include_path) {
+if ($use_feature{path}) {
     $fields->{'Build-Path'} = $cwd;
     $fields->{'Build-Path'} = $cwd;
 } else {
 } else {
     # Only include the build path if its root path is considered acceptable
     # Only include the build path if its root path is considered acceptable