summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog4
-rw-r--r--man/dpkg-buildflags.110
-rw-r--r--scripts/Dpkg/BuildFlags.pm29
3 files changed, 41 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index 70043ce..f6b52cb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -65,6 +65,10 @@ dpkg (1.16.1) UNRELEASED; urgency=low
* dpkg-buildflags parses a supplementary configuration file under the
control of the package maintainer: debian/buildflags (or the corresponding
architecture/os specific variants).
+ * dpkg-buildflags supports a prepend command to modify the build
+ flags. Particularly useful for package maintainers who don't want
+ their supplementary flags to take precedence over user submitted
+ 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 fcb58db..ff4267f 100644
--- a/man/dpkg-buildflags.1
+++ b/man/dpkg-buildflags.1
@@ -32,8 +32,12 @@ The configuration files can contain two types of directives:
Override the flag named \fIflag\fP to have the value \fIvalue\fP.
.TP
.BI APPEND " flag value"
-Extend the flag named \fIflag\fP with the options given in \fIvalue\fP.
+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.
+.TP
+.BI PREPEND " flag value"
+Extend the flag named \fIflag\fP by prepending the options given in \fIvalue\fP.
+A space is appended to the prepended value if the flag's current value is non-empty.
.P
The configuration files can contain comments on lines starting with a hash
(#). Empty lines are also ignored.
@@ -128,6 +132,10 @@ This variable can be used to force the value returned for the given
.BI DEB_ flag _APPEND
This variable can be used to append supplementary options to the value
returned for the given \fIflag\fP.
+.TP
+.BI DEB_ flag _PREPEND
+This variable can be used to prepend supplementary options to the value
+returned for the given \fIflag\fP.
.
.SH AUTHOR
Copyright \(co 2010-2011 Rapha\[:e]l Hertzog
diff --git a/scripts/Dpkg/BuildFlags.pm b/scripts/Dpkg/BuildFlags.pm
index 5c9355f..d48611d 100644
--- a/scripts/Dpkg/BuildFlags.pm
+++ b/scripts/Dpkg/BuildFlags.pm
@@ -132,6 +132,10 @@ sub load_environment_config {
if (exists $ENV{$envvar}) {
$self->append($flag, $ENV{$envvar}, "env");
}
+ $envvar = "DEB_" . $flag . "_PREPEND";
+ if (exists $ENV{$envvar}) {
+ $self->prepend($flag, $ENV{$envvar}, "env");
+ }
}
}
@@ -196,6 +200,24 @@ sub append {
$self->{origin}->{$flag} = $src if defined $src;
}
+=item $bf->prepend($flag, $value, $source)
+
+Prepend the options listed in $value to the current value of the flag $flag.
+Record its origin as $source (if defined).
+
+=cut
+
+sub prepend {
+ my ($self, $flag, $value, $src) = @_;
+ if (length($self->{flags}->{$flag})) {
+ $self->{flags}->{$flag} = "$value " . $self->{flags}->{$flag};
+ } else {
+ $self->{flags}->{$flag} = $value;
+ }
+ $self->{origin}->{$flag} = $src if defined $src;
+}
+
+
=item $bf->update_from_conffile($file, $source)
Update the current build flags based on the configuration directives
@@ -213,7 +235,7 @@ sub update_from_conffile {
chomp;
next if /^\s*#/; # Skip comments
next if /^\s*$/; # Skip empty lines
- if (/^(append|set)\s+(\S+)\s+(\S.*\S)\s*$/i) {
+ if (/^(append|prepend|set)\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);
@@ -223,6 +245,8 @@ sub update_from_conffile {
$self->set($flag, $value, $src);
} elsif (lc($op) eq "append") {
$self->append($flag, $value, $src);
+ } elsif (lc($op) eq "prepend") {
+ $self->prepend($flag, $value, $src);
}
} else {
warning(_g("line %d of %s is invalid, it has been ignored."), $., $file);
@@ -286,6 +310,9 @@ sub list {
New method: $bf->load_package_config(). This method is called last as part
of load_config().
+New method: $bf->prepend() very similar to append(). Implement support of
+the prepend operation everywhere.
+
=head1 AUTHOR
Raphaƫl Hertzog <hertzog@debian.org>