From 8fd30b60465acd90ffea6aab19ce15eea94a122a Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 28 Jul 2018 22:10:55 +0200 Subject: Dpkg::Deps: Clarify arch-qualified dependency simplification Dependency simplification can only really be done for metadata for which we have all its context and information during the simplification process. Anything that relies on the state of the dependencies cannot be simplified. This means that any dependency that might change the satisfiability due to the value of Multi-Arch field of the depended on package cannot be simplified. Clarify this in the function commends, and add new test cases to cover this. Prompted-by: Stuart Prescott --- debian/changelog | 2 ++ scripts/Dpkg/Deps.pm | 3 +++ scripts/t/Dpkg_Deps.t | 22 +++++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 688c70b53..b76062154 100644 --- a/debian/changelog +++ b/debian/changelog @@ -151,6 +151,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Update test suite requirements in README. - Document textdomain() and ngettext() replacement functions in Dpkg::Gettext POD. + - Clarify arch-qualified dependency simplification in Dpkg::Deps POD. * Code internals: - Do not use stringy eval to define different sub implementations, just assign an anonymous sub to the typeglob. @@ -189,6 +190,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Infer automatically the unit test data directory. - Infer automatically the unit test temp directory. - Add new po author test case (use i18nspector if available). + - Add new test cases to clarify arch-qualified dependency simplification. [ Updated programs translations ] * Dutch (Frans Spiesschaert). Closes: #881401 diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index 885a6c2e1..88cb98eca 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -758,6 +758,9 @@ sub _arch_is_superset { # 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. +# +# For example dependencies with different arch-qualifiers cannot be simplified +# as these depend on the state of Multi-Arch field in the package depended on. sub _arch_qualifier_implies { my ($p, $q) = @_; diff --git a/scripts/t/Dpkg_Deps.t b/scripts/t/Dpkg_Deps.t index 71a3cf16a..a519f8166 100644 --- a/scripts/t/Dpkg_Deps.t +++ b/scripts/t/Dpkg_Deps.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 70; +use Test::More tests => 74; use Dpkg::Arch qw(get_host_arch); use Dpkg::Version; @@ -233,6 +233,26 @@ is($dep_profiles->output(), 'libfoo-dev:native , libfoo-dev ', 'Simplification respects archqualifiers and profiles'); +my $dep_archqual = deps_parse('pkg, pkg:any'); +$dep_archqual->simplify_deps($facts); +is($dep_archqual->output(), 'pkg, pkg:any', + 'Simplify respect arch-qualified ANDed dependencies 1/2'); + +$dep_archqual = deps_parse('pkg:amd64, pkg:any, pkg:i386'); +$dep_archqual->simplify_deps($facts); +is($dep_archqual->output(), 'pkg:amd64, pkg:any, pkg:i386', + 'Simplify respects arch-qualified ANDed dependencies 2/2'); + +$dep_archqual = deps_parse('pkg | pkg:any'); +$dep_archqual->simplify_deps($facts); +is($dep_archqual->output(), 'pkg | pkg:any', + 'Simplify respect arch-qualified ORed dependencies 1/2'); + +$dep_archqual = deps_parse('pkg:amd64 | pkg:i386 | pkg:any'); +$dep_archqual->simplify_deps($facts); +is($dep_archqual->output(), 'pkg:amd64 | pkg:i386 | pkg:any', + 'Simplify respect arch-qualified ORed dependencies 2/2'); + my $dep_version = deps_parse('pkg, pkg (= 1.0)'); $dep_version->simplify_deps($facts); is($dep_version->output(), 'pkg (= 1.0)', 'Simplification merges versions'); -- cgit v1.2.3