summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog3
-rw-r--r--man/dpkg-buildflags.110
-rw-r--r--scripts/Dpkg/BuildFlags.pm30
3 files changed, 41 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index af59f63..cc7716a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -93,7 +93,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
* dpkg-buildflags now supports "--export=configure" to output compilation
flags on a single line with double quotes as delimiter of the various
values. It also uses DEB_<flag>_MAINT_<op> to let the maintainer
- extend the build flags to use.
+ extend the build flags to use. Last but not least, it can now also strip
+ options from the returned build flags.
[ Guillem Jover ]
* Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520
diff --git a/man/dpkg-buildflags.1 b/man/dpkg-buildflags.1
index b885974..ad08b83 100644
--- a/man/dpkg-buildflags.1
+++ b/man/dpkg-buildflags.1
@@ -29,6 +29,9 @@ The configuration files can contain two types of directives:
.BI SET " flag value"
Override the flag named \fIflag\fP to have the value \fIvalue\fP.
.TP
+.BI STRIP " flag value"
+Strip from the flag named \fIflag\fP all the build flags listed in \fIvalue\fP.
+.TP
.BI APPEND " flag value"
Extend the flag named \fIflag\fP by appending the options given in \fIvalue\fP.
A space is prepended to the appended value if the flag's current value is non-empty.
@@ -136,6 +139,13 @@ by package maintainers to change the resulting build flags.
This variable can be used to force the value returned for the given
\fIflag\fP.
.TP
+.BI DEB_ flag _STRIP
+.TQ
+.BI DEB_ flag _MAINT_STRIP
+This variable can be used to provide a space separated list of options
+that will be stripped from the set of flags returned for the given
+\fIflag\fP.
+.TP
.BI DEB_ flag _APPEND
.TQ
.BI DEB_ flag _MAINT_APPEND
diff --git a/scripts/Dpkg/BuildFlags.pm b/scripts/Dpkg/BuildFlags.pm
index 81062f5..9bc473a 100644
--- a/scripts/Dpkg/BuildFlags.pm
+++ b/scripts/Dpkg/BuildFlags.pm
@@ -127,6 +127,10 @@ sub load_environment_config {
if (exists $ENV{$envvar}) {
$self->set($flag, $ENV{$envvar}, "env");
}
+ $envvar = "DEB_" . $flag . "_STRIP";
+ if (exists $ENV{$envvar}) {
+ $self->strip($flag, $ENV{$envvar}, "env");
+ }
$envvar = "DEB_" . $flag . "_APPEND";
if (exists $ENV{$envvar}) {
$self->append($flag, $ENV{$envvar}, "env");
@@ -152,6 +156,10 @@ sub load_maintainer_config {
if (exists $ENV{$envvar}) {
$self->set($flag, $ENV{$envvar}, undef);
}
+ $envvar = "DEB_" . $flag . "_MAINT_STRIP";
+ if (exists $ENV{$envvar}) {
+ $self->strip($flag, $ENV{$envvar}, undef);
+ }
$envvar = "DEB_" . $flag . "_MAINT_APPEND";
if (exists $ENV{$envvar}) {
$self->append($flag, $ENV{$envvar}, undef);
@@ -193,6 +201,24 @@ sub set {
$self->{origin}->{$flag} = $src if defined $src;
}
+=item $bf->strip($flag, $value, $source)
+
+Update the build flag $flag by stripping the flags listed in $value and
+record its origin as $source (if defined).
+
+=cut
+
+sub strip {
+ my ($self, $flag, $value, $src) = @_;
+ foreach my $tostrip (split(/\s+/, $value)) {
+ next unless length $tostrip;
+ $self->{flags}->{$flag} =~ s/(^|\s+)\Q$tostrip\E(\s+|$)/ /g;
+ }
+ $self->{flags}->{$flag} =~ s/^\s+//g;
+ $self->{flags}->{$flag} =~ s/\s+$//g;
+ $self->{origin}->{$flag} = $src if defined $src;
+}
+
=item $bf->append($flag, $value, $source)
Append the options listed in $value to the current value of the flag $flag.
@@ -245,7 +271,7 @@ sub update_from_conffile {
chomp;
next if /^\s*#/; # Skip comments
next if /^\s*$/; # Skip empty lines
- if (/^(append|prepend|set)\s+(\S+)\s+(\S.*\S)\s*$/i) {
+ if (/^(append|prepend|set|strip)\s+(\S+)\s+(\S.*\S)\s*$/i) {
my ($op, $flag, $value) = ($1, $2, $3);
unless (exists $self->{flags}->{$flag}) {
warning(_g("line %d of %s mentions unknown flag %s"), $., $file, $flag);
@@ -253,6 +279,8 @@ sub update_from_conffile {
}
if (lc($op) eq "set") {
$self->set($flag, $value, $src);
+ } elsif (lc($op) eq "strip") {
+ $self->strip($flag, $value, $src);
} elsif (lc($op) eq "append") {
$self->append($flag, $value, $src);
} elsif (lc($op) eq "prepend") {