Parcourir la source

dpkg-buildpackage: Add config file support

The new configuration file is buildpackage.conf under either the dpkg
system or user configuration directories.

Closes: #539692, #765494
Guillem Jover il y a 11 ans
Parent
commit
fc55edbf31
3 fichiers modifiés avec 27 ajouts et 0 suppressions
  1. 3 0
      debian/changelog
  2. 16 0
      man/dpkg-buildpackage.1
  3. 8 0
      scripts/dpkg-buildpackage.pl

+ 3 - 0
debian/changelog

@@ -5,6 +5,9 @@ dpkg (1.18.8) UNRELEASED; urgency=medium
     Thanks to Steven Chamberlain <steven@pyro.eu.org>.
   * Add new long options in dpkg-buildpackage for any short option that is
     a useful configurable candidate.
+  * Add configuration file support to dpkg-buildpackage, as buildpackage.conf
+    under either the dpkg system or user configuration directories.
+    Closes: #539692, #765494
   * Perl modules:
     - Use warnings::warnif() instead of carp() for deprecated warnings.
     - Add new format_range() method and deprecate dpkg() and rfc822() methods

+ 16 - 0
man/dpkg-buildpackage.1

@@ -85,6 +85,12 @@ UNRELEASED builds).
 It runs the \fBdone\fP hook.
 .
 .SH OPTIONS
+All long options can be specified both on the command line and in the
+\fBdpkg\-buildpackage\fP system and user configuration files.
+Each line in the configuration file is either an option (exactly the same
+as the command line option but without leading hyphens) or a comment (if
+it starts with a \(oq\fB#\fP\(cq).
+
 .TP
 .BI \-\-build= type
 Specifies the build \fItype\fP from a comma-separated list of components
@@ -465,6 +471,16 @@ standalone should be supported.
 parameters forwarded. Any variable that is output by its \fB\-s\fP
 option is integrated in the build environment.
 .
+.SH FILES
+.TP
+.I /etc/dpkg/buildpackage.conf
+System wide configuration file
+.TP
+.IR $XDG_CONFIG_HOME/dpkg/buildflags.conf " or"
+.TQ
+.I $HOME/.config/dpkg/buildflags.conf
+User configuration file.
+.
 .SH NOTES
 .SS Compiler flags are no longer exported
 Between dpkg 1.14.17 and 1.16.1, \fBdpkg\-buildpackage\fP

+ 8 - 0
scripts/dpkg-buildpackage.pl

@@ -35,6 +35,7 @@ use Dpkg::ErrorHandling;
 use Dpkg::Build::Types;
 use Dpkg::BuildOptions;
 use Dpkg::BuildProfiles qw(set_build_profiles);
+use Dpkg::Conf;
 use Dpkg::Compression;
 use Dpkg::Checksums;
 use Dpkg::Version;
@@ -173,6 +174,13 @@ my @hook_names = qw(
 my %hook;
 $hook{$_} = undef foreach @hook_names;
 
+
+my $conf = Dpkg::Conf->new();
+$conf->load_config('buildpackage.conf');
+
+# Inject config options for command-line parser.
+unshift @ARGV, @{$conf};
+
 my $build_opts = Dpkg::BuildOptions->new();
 
 if ($build_opts->has('nocheck')) {