Package: libdpkg-perl
Version: 1.18.7
Severity: important
Tags: patch

Here's a patch; let me know if you need further justification.
The practical impact for me was that build-dependency:

    libssl-dev:native <!stage1>, libssl-dev <!stage1 !pkg.linux.notools cross>

was simplified to:

    libssl-dev <!stage1 !pkg.linux.notools cross>

and thus native builds had not dependency on libssl-dev.  (Of course,
there is a second bug here to do with architecture implications.
That's bug #827628.)

Ben.

---
From: Ben Hutchings <b...@decadent.org.uk>
Date: Sat, 18 Jun 2016 22:49:06 +0100
Subject: Dpkg::Deps::Simple::implies: Check whether restrictions are implied

We need to check whether the restrictions on self imply the
restrictions on o, along with all the other tests.
---
 scripts/Dpkg/Deps.pm | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm
index 42019254cca3..6bd5c16780fb 100644
--- a/scripts/Dpkg/Deps.pm
+++ b/scripts/Dpkg/Deps.pm
@@ -764,6 +764,33 @@ sub _arch_qualifier_allows_implication {
     }
 }
 
+# _restrictions_imply($p, $q)
+#
+# Returns true if the restrictions $p and $q are compatible with the
+# implication $p -> $q, false otherwise.
+# NOTE: We don't try to be very clever here, so we may conservatively
+# return false when there is an implication.
+sub _restrictions_imply {
+    my ($p, $q) = @_;
+    if (!defined($p)) {
+       return 1;
+    } elsif (!defined($q)) {
+       return 0;
+    } else {
+       # Check whether set difference is empty
+       my %restr;
+       for my $restrlist (@{$q}) {
+           my $reststr = join(' ', sort(@{$restrlist}));
+           $restr{$reststr} = 1;
+       }
+       for my $restrlist (@{$p}) {
+           my $reststr = join(' ', sort(@{$restrlist}));
+           delete $restr{$reststr};
+       }
+       return keys %restr == 0;
+    }
+}
+
 # Returns true if the dependency in parameter can deduced from the current
 # dependency. Returns false if it can be negated. Returns undef if nothing
 # can be concluded.
@@ -781,6 +808,10 @@ sub implies {
        return unless _arch_qualifier_allows_implication($self->{archqual},
                                                         $o->{archqual});
 
+       # Our restrictions must imply the restrictions for o
+       return unless _restrictions_imply($self->{restrictions},
+                                         $o->{restrictions});
+
        # If o has no version clause, then our dependency is stronger
        return 1 if not defined $o->{relation};
        # If o has a version clause, we must also have one, otherwise there


-- System Information:
Debian Release: stretch/sid
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'unstable'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.6.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libdpkg-perl depends on:
ii  dpkg  1.18.7
ii  perl  5.22.2-1

Versions of packages libdpkg-perl recommends:
ii  bzip2                   1.0.6-8
ii  libfile-fcntllock-perl  0.22-3+b1
ii  xz-utils                5.1.1alpha+20120614-2.1

Versions of packages libdpkg-perl suggests:
ii  binutils              2.26-11
ii  debian-keyring        2016.04.22
ii  gcc [c-compiler]      4:5.3.1-3
ii  gcc-4.8 [c-compiler]  4.8.5-4
ii  gcc-5 [c-compiler]    5.4.0-4
ii  gnupg                 1.4.20-6
ii  gnupg2                2.1.11-7
ii  gpgv                  1.4.20-6
ii  patch                 2.7.5-1

-- no debconf information

-- debsums errors found:
debsums: changed file /usr/share/perl5/Dpkg/Deps.pm (from libdpkg-perl package)

Reply via email to