From 47cfe52122ea796356d3b3d9353c4605ae50bdf4 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 7 Jan 2008 09:20:18 +0200 Subject: [PATCH] Dpkg::BuildOptions: Parse all options in DEB_BUILD_OPTIONS This will preserve unrecognized options when calling dpkg-buildpackage with -j. --- ChangeLog | 8 ++++++++ debian/changelog | 2 ++ scripts/Dpkg/BuildOptions.pm | 22 +++++++++++++++++----- scripts/t/300_Dpkg_BuildOptions.t | 9 ++++++--- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index f17e20f1..eeb174bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-01-07 Guillem Jover + + * scripts/Dpkg/BuildOptions.pm (set): Parse all options separated + by spaces or comma, do not lowercase the option names, do not match + on name substrings, and on recognized options with invalid values + discard the value or the entire option. + * scripts/t/300_Dpkg_BuildOptions.t: Adjust test suite. + 2008-01-06 Raphael Hertzog * scripts/Dpkg/Shlibs/Objdump.pm: Also retrieve dynamic relocation diff --git a/debian/changelog b/debian/changelog index ae3f8b32..07533821 100644 --- a/debian/changelog +++ b/debian/changelog @@ -45,6 +45,8 @@ dpkg (1.14.15) UNRELEASED; urgency=low * Add lzma to dpkg-dev Depends. * Do not automatically enable -j if DEB_BUILD_OPTIONS contains parallel=n, and allow overriding its value from the environment. Closes: #458589 + * Fix Dpkg::BuildOptions to parse all options in DEB_BUILD_OPTIONS, so + that dpkg-buildpackage called with -j preserves unrecognized options. [ Updated dpkg translations ] * Norwegian Bokmål (Hans Fredrik Nordhaug). Closes: #457918, #458732 diff --git a/scripts/Dpkg/BuildOptions.pm b/scripts/Dpkg/BuildOptions.pm index 39f10997..1068248f 100644 --- a/scripts/Dpkg/BuildOptions.pm +++ b/scripts/Dpkg/BuildOptions.pm @@ -11,11 +11,23 @@ sub parse { unless ($env) { return {}; } my %opts; - while ($env =~ s/(noopt|nostrip|nocheck),?//i) { - $opts{lc $1} = ''; - } - while ($env =~ s/(parallel)=(-?\d+),?//i) { - $opts{lc $1} = $2; + + foreach (split(/[\s,]+/, $env)) { + # FIXME: This is pending resolution of Debian bug #430649 + /^([a-z][a-z0-9_-]*)(=(\w*))?$/; + + my ($k, $v) = ($1, $3 || ''); + + # Sanity checks + if (!$k) { + next; + } elsif ($k =~ /^(noopt|nostrip|nocheck)$/ && length($v)) { + $v = ''; + } elsif ($k eq 'parallel' && $v !~ /^-?\d+$/) { + next; + } + + $opts{$k} = $v; } return \%opts; diff --git a/scripts/t/300_Dpkg_BuildOptions.t b/scripts/t/300_Dpkg_BuildOptions.t index 9a5baf37..7dc8394f 100644 --- a/scripts/t/300_Dpkg_BuildOptions.t +++ b/scripts/t/300_Dpkg_BuildOptions.t @@ -7,16 +7,19 @@ use warnings; use_ok('Dpkg::BuildOptions'); -$ENV{DEB_BUILD_OPTIONS} = 'foonostripbar,parallel=3,bazNOCHECK'; +$ENV{DEB_BUILD_OPTIONS} = 'noopt,foonostripbar,parallel=3,bazNOCHECK'; my $dbo = Dpkg::BuildOptions::parse(); my %dbo = ( - nostrip => '', - nocheck => '', + noopt => '', + foonostripbar => '', parallel => 3, ); my %dbo2 = ( + no => '', + opt => '', + 'no-strip' => '', nocheck => '', ); -- 2.39.5