| author | Raphaël Hertzog <hertzog@debian.org> | |
| Thu, 7 Jul 2011 10:26:12 +0000 (12:26 +0200) | ||
| committer | Raphaël Hertzog <hertzog@debian.org> | |
| Mon, 11 Jul 2011 07:27:54 +0000 (09:27 +0200) |
This command is particularly useful for package maintainers who don't want
their supplementary flags to take precedence over user submitted flags.
their supplementary flags to take precedence over user submitted flags.
| debian/changelog | patch | blob | history | |
| man/dpkg-buildflags.1 | patch | blob | history | |
| scripts/Dpkg/BuildFlags.pm | patch | blob | history |
diff --git a/debian/changelog b/debian/changelog
--- a/debian/changelog
+++ b/debian/changelog
* 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
--- a/man/dpkg-buildflags.1
+++ b/man/dpkg-buildflags.1
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.
.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
if (exists $ENV{$envvar}) {
$self->append($flag, $ENV{$envvar}, "env");
}
+ $envvar = "DEB_" . $flag . "_PREPEND";
+ if (exists $ENV{$envvar}) {
+ $self->prepend($flag, $ENV{$envvar}, "env");
+ }
}
}
$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
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);
$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);
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>
