Kaynağa Gözat

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.
Raphael Hertzog 18 yıl önce
ebeveyn
işleme
9866c4bafd
3 değiştirilmiş dosya ile 23 ekleme ve 15 silme
  1. 8 0
      ChangeLog
  2. 3 0
      debian/changelog
  3. 12 15
      scripts/Dpkg/BuildOptions.pm

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-06-09  Guillem Jover  <guillem@debian.org>
+
+	* 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  <guillem@debian.org>
 
 	* scripts/Dpkg/Source/Package.pm ($diff_ignore_default_regexp): Add

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

+ 12 - 15
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;
 }