summaryrefslogtreecommitdiff
path: root/Debian/Debhelper/Dh_Lib.pm
diff options
context:
space:
mode:
authorModestas Vainius <modax@debian.org>2011-06-18 23:02:42 +0300
committerJoey Hess <joey@kitenet.net>2011-06-19 14:20:26 -0400
commit9275ae457623ce14567866abaf434903cff12706 (patch)
treece88a31a5dea02707b83a80feda3582691e8ad71 /Debian/Debhelper/Dh_Lib.pm
parent114cecf6e739aa755504eb37eb9ed89e8cab0120 (diff)
Use Dpkg::BuildFlags module directly in set_buildflags().
Dpkg::BuildFlags API is declared stable. It should be safe to use it directly rather than dpkg-buildflags wrapper. In addition, do not do any DEB_BUILD_OPTIONS=noopt handling in debhelper. Dpkg::BuildFlags already does it for us.
Diffstat (limited to 'Debian/Debhelper/Dh_Lib.pm')
-rw-r--r--Debian/Debhelper/Dh_Lib.pm33
1 files changed, 12 insertions, 21 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 51f16a6..0c779d1 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -901,32 +901,23 @@ sub cross_command {
}
# Sets environment variables from dpkg-buildflags. Avoids changing
-# any existing environment variables. Supports DEB_BUILD_OPTIONS=noopt.
+# any existing environment variables.
sub set_buildflags {
# optimisation
return if $ENV{DH_INTERNAL_BUILDFLAGS};
$ENV{DH_INTERNAL_BUILDFLAGS}=1;
- my $noopt=$ENV{DEB_BUILD_OPTIONS}=~/noopt/;
-
- my @shell=`dpkg-buildflags --export`;
- foreach my $line (@shell) {
- chomp $line;
- if ($line=~/^export\s+([^=]+)=(["'])(.*)\2$/) {
- my $var=$1;
- my $val=$3;
- if ($noopt) {
- $val=$ENV{$var} if exists $ENV{$var};
- $val=~s/-O\d+/-O0/;
- $ENV{$var}=$val;
- next;
- }
- elsif (! exists $ENV{$var}) {
- $ENV{$var}=$val;
- }
- }
- else {
- warning "unparsable line from dpkg-buildflags: $line";
+ eval "use Dpkg::BuildFlags";
+ if ($@) {
+ warning "unable to load build flags: $@";
+ }
+
+ my $buildflags = Dpkg::BuildFlags->new();
+ $buildflags->load_config();
+ foreach my $flag ($buildflags->list()) {
+ next unless $flag =~ /^[A-Z]/; # Skip flags starting with lowercase
+ if (! exists $ENV{$flag}) {
+ $ENV{$flag} = $buildflags->get($flag);
}
}
}