From: Raphael Hertzog Date: Mon, 9 Jun 2008 17:42:28 +0000 (+0200) Subject: dpkg-buildpackage: use space as separator in DEB_BUILD_OPTIONS X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9866c4bafdf147ad764f31e2747f5c1012802b1d;p=dpkg dpkg-buildpackage: use space as separator in DEB_BUILD_OPTIONS * scripts/Dpkg/BuildOptions.pm (parse, set): Use space as the official separator in DEB_BUILD_OPTIONS. Check for validity of flags and print a warning if a bad option is detected. Rewrote the logic of set() to avoid adding options twice in non-overwrite mode. --- diff --git a/ChangeLog b/ChangeLog index 7dbade8b..6a692a95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-06-09 Guillem Jover + + * scripts/Dpkg/BuildOptions.pm (parse, set): Use space as the + official separator in DEB_BUILD_OPTIONS. Check for validity of + flags and print a warning if a bad option is detected. Rewrote + the logic of set() to avoid adding options twice in non-overwrite + mode. + 2008-06-09 Guillem Jover * scripts/Dpkg/Source/Package.pm ($diff_ignore_default_regexp): Add diff --git a/debian/changelog b/debian/changelog index cc6233ea..aeb3a531 100644 --- a/debian/changelog +++ b/debian/changelog @@ -33,6 +33,9 @@ dpkg (1.15.0) UNRELEASED; urgency=low Thanks to Daniel Hahler for the patch. Closes: #457135 * dpkg-gencontrol can now again read the control file from its standard input with "-c-". Closes: #465340 + * Modified Dpkg::BuildOptions to recognize and use spaces as separator + in DEB_BUILD_OPTIONS (in order to conform with the Debian policy + ruling estasblished in #430649). [ Pierre Habouzit ] * Add a --query option to update-alternatives. Closes: #336091, #441904 diff --git a/scripts/Dpkg/BuildOptions.pm b/scripts/Dpkg/BuildOptions.pm index 1068248f..cdb9c65e 100644 --- a/scripts/Dpkg/BuildOptions.pm +++ b/scripts/Dpkg/BuildOptions.pm @@ -12,16 +12,16 @@ sub parse { my %opts; - foreach (split(/[\s,]+/, $env)) { - # FIXME: This is pending resolution of Debian bug #430649 - /^([a-z][a-z0-9_-]*)(=(\w*))?$/; + foreach (split(/\s+/, $env)) { + unless (/^([a-z][a-z0-9_-]*)(=(\S*))?$/) { + warning(_g("invalid flag in DEB_BUILD_OPTIONS: %s"), $_); + next; + } my ($k, $v) = ($1, $3 || ''); # Sanity checks - if (!$k) { - next; - } elsif ($k =~ /^(noopt|nostrip|nocheck)$/ && length($v)) { + if ($k =~ /^(noopt|nostrip|nocheck)$/ && length($v)) { $v = ''; } elsif ($k eq 'parallel' && $v !~ /^-?\d+$/) { next; @@ -37,18 +37,15 @@ sub set { my ($opts, $overwrite) = @_; $overwrite = 1 if not defined($overwrite); - my $env = $overwrite ? '' : $ENV{DEB_BUILD_OPTIONS}||''; - if ($env) { $env .= ',' } - + my $new = {}; + $new = parse() unless $overwrite; while (my ($k, $v) = each %$opts) { - if ($v) { - $env .= "$k=$v,"; - } else { - $env .= "$k,"; - } + $new->{$k} = $v; } - $ENV{DEB_BUILD_OPTIONS} = $env if $env; + my $env = join(" ", map { $new->{$_} ? $_ . "=" . $new->{$_} : $_ } keys %$new); + + $ENV{DEB_BUILD_OPTIONS} = $env; return $env; }