Hi!
On Sat, 2016-06-18 at 23:04:13 +0100, Ben Hutchings wrote:
> Package: libdpkg-perl
> Version: 1.18.7
> Severity: important
> 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 which is that the restrictions are not being
> compared.)
Hmm, right, this is just wrong.
> From: Ben Hutchings <[email protected]>
> Date: Sat, 18 Jun 2016 22:49:06 +0100
> Subject: _arch_qualifier_allows_implication: Unqualified does not imply
> :native
>
> A missing architecture qualification means the host architecture,
> whereas :native means the build architecture. Neither implies the
> other.
> ---
> scripts/Dpkg/Deps.pm | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm
> index cdd2587c56f4..42019254cca3 100644
> --- a/scripts/Dpkg/Deps.pm
> +++ b/scripts/Dpkg/Deps.pm
> @@ -759,7 +759,7 @@ sub _arch_qualifier_allows_implication {
> return 1 if defined $q and ($p eq $q or $q eq 'any');
> return 0;
> } else {
> - return 0 if defined $q and $q ne 'any' and $q ne 'native';
> + return 0 if defined $q and $q ne 'any';
> return 1;
> }
> }
But I don't think this fix is enough, checking the function it is all
wrong, because the information it is trying to infer is only fully know
when doing actual dependency resolution, which we cannot do when simply
looking at the dependencies w/o context.
I think the correct fix is the attached patch. Which should also cover
bug #745366! I'll be fixing and expanding the test suite to cover these.
Thanks,
Guillem
diff --git i/scripts/Dpkg/Deps.pm w/scripts/Dpkg/Deps.pm
index 0238fd4..e711fe0 100644
--- i/scripts/Dpkg/Deps.pm
+++ w/scripts/Dpkg/Deps.pm
@@ -742,26 +742,21 @@ sub _arch_is_superset {
return 1;
}
-# _arch_qualifier_allows_implication($p, $q)
+# _arch_qualifier_implies($p, $q)
#
# Returns true if the arch qualifier $p and $q are compatible with the
-# implication $p -> $q, false otherwise. $p/$q can be
-# undef/"any"/"native" or an architecture string.
-sub _arch_qualifier_allows_implication {
+# implication $p -> $q, false otherwise. $p/$q can be undef/"any"/"native"
+# or an architecture string.
+#
+# Because we are handling dependencies in isolation, and the full context
+# of the implications are only known when doing dependency resolution at
+# run-time, we can only assert that they are implied if they are equal.
+sub _arch_qualifier_implies {
my ($p, $q) = @_;
- if (defined $p and $p eq 'any') {
- return 1 if defined $q and $q eq 'any';
- return 0;
- } elsif (defined $p and $p eq 'native') {
- return 1 if defined $q and ($q eq 'any' or $q eq 'native');
- return 0;
- } elsif (defined $p) {
- return 1 if defined $q and ($p eq $q or $q eq 'any');
- return 0;
- } else {
- return 0 if defined $q and $q ne 'any' and $q ne 'native';
- return 1;
- }
+
+ return $p eq $q if defined $p and defined $q;
+ return 1 if not defined $p and not defined $q;
+ return 0;
}
# Returns true if the dependency in parameter can deduced from the current
@@ -778,8 +773,8 @@ sub implies {
return unless _arch_is_superset($self->{arches}, $o->{arches});
# The arch qualifier must not forbid an implication
- return unless _arch_qualifier_allows_implication($self->{archqual},
- $o->{archqual});
+ return unless _arch_qualifier_implies($self->{archqual},
+ $o->{archqual});
# If o has no version clause, then our dependency is stronger
return 1 if not defined $o->{relation};