Просмотр исходного кода

Dpkg::BuildOptions: Parse all options in DEB_BUILD_OPTIONS

This will preserve unrecognized options when calling dpkg-buildpackage
with -j.
Guillem Jover лет назад: 18
Родитель
Сommit
47cfe52122
4 измененных файлов с 33 добавлено и 8 удалено
  1. 8 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 17 5
      scripts/Dpkg/BuildOptions.pm
  4. 6 3
      scripts/t/300_Dpkg_BuildOptions.t

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-01-07  Guillem Jover  <guillem@debian.org>
+
+	* 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  <hertzog@debian.org>
 
 	* scripts/Dpkg/Shlibs/Objdump.pm: Also retrieve dynamic relocation

+ 2 - 0
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

+ 17 - 5
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;

+ 6 - 3
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 => '',
 	   );