瀏覽代碼

dpkg-gencontrol: don't accept arch-specific dependencies in arch: all packages

Since an architecture all package is shared on all architectures, its
dependency lines can't be simplified with the knowledge of the current host
architecture.
Raphaël Hertzog 16 年之前
父節點
當前提交
063f0565dc
共有 3 個文件被更改,包括 35 次插入2 次删除
  1. 2 0
      debian/changelog
  2. 25 0
      scripts/Dpkg/Deps.pm
  3. 8 2
      scripts/dpkg-gencontrol.pl

+ 2 - 0
debian/changelog

@@ -36,6 +36,8 @@ dpkg (1.15.6) UNRELEASED; urgency=low
   * While parsing diff's output, accept any sentence that contains the word
     differ (as specified by POSIX) to identify that binary files could not be
     compared. Closes: #570008
+  * dpkg-gencontrol does no longer accept arch-specific dependencies in
+    arch: all packages. Closes: #560071
 
   [ Guillem Jover ]
   * Handle argument parsing in dpkg-checkbuilddeps and dpkg-scanpackages

+ 25 - 0
scripts/Dpkg/Deps.pm

@@ -430,6 +430,12 @@ Simplify the dependency as much as possible given the list of facts (see
 object Dpkg::Deps::KnownFacts) and a list of other dependencies that we
 know to be true.
 
+=item $dep->has_arch_restriction()
+
+For a simple dependency, returns the package name if the dependency
+applies only to a subset of architectures.  For multiple dependencies, it
+returns the list of package names that have such a restriction.
+
 =back
 
 =head2 Dpkg::Deps::Simple
@@ -666,6 +672,15 @@ sub reduce_arch {
     }
 }
 
+sub has_arch_restriction {
+    my ($self) = @_;
+    if (defined $self->{arches}) {
+	return $self->{package};
+    } else {
+	return ();
+    }
+}
+
 sub get_evaluation {
     my ($self, $facts) = @_;
     return undef if not defined $self->{package};
@@ -815,6 +830,16 @@ sub reduce_arch {
     $self->{list} = [ @new ];
 }
 
+sub has_arch_restriction {
+    my ($self) = @_;
+    my @res;
+    foreach my $dep (@{$self->{list}}) {
+	push @res, $dep->has_arch_restriction();
+    }
+    return @res;
+}
+
+
 sub is_empty {
     my $self = shift;
     return scalar @{$self->{list}} == 0;

+ 8 - 2
scripts/dpkg-gencontrol.pl

@@ -235,11 +235,14 @@ if (exists $pkg->{"Provides"}) {
 
 my (@seen_deps);
 foreach my $field (field_list_pkg_dep()) {
+    # Arch: all can't be simplified as the host architecture is not known
+    my $reduce_arch = debarch_eq('all', $pkg->{Architecture} || "all") ? 0 : 1;
     if (exists $pkg->{$field}) {
 	my $dep;
 	my $field_value = $substvars->substvars($pkg->{$field});
 	if (field_get_dep_type($field) eq 'normal') {
-	    $dep = deps_parse($field_value, use_arch => 1, reduce_arch => 1);
+	    $dep = deps_parse($field_value, use_arch => 1,
+			      reduce_arch => $reduce_arch);
 	    error(_g("error occurred while parsing %s field: %s"), $field,
                   $field_value) unless defined $dep;
 	    $dep->simplify_deps($facts, @seen_deps);
@@ -247,12 +250,15 @@ foreach my $field (field_list_pkg_dep()) {
 	    push @seen_deps, $dep;
 	} else {
 	    $dep = deps_parse($field_value, use_arch => 1,
-                              reduce_arch => 1, union => 1);
+                              reduce_arch => $reduce_arch, union => 1);
 	    error(_g("error occurred while parsing %s field: %s"), $field,
                   $field_value) unless defined $dep;
 	    $dep->simplify_deps($facts);
             $dep->sort();
 	}
+	error(_g("the %s field contains an arch-specific dependency but the " .
+	         "package is architecture all"), $field)
+	    if $dep->has_arch_restriction();
 	$fields->{$field} = $dep->output();
 	delete $fields->{$field} unless $fields->{$field}; # Delete empty field
     }