diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2025-03-12 20:21:42 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2025-03-13 21:59:09 +0100 |
| commit | 8ae73d1e037a6b9cb258b1ca505abce5681d9931 (patch) | |
| tree | 181d99da8c0dbde0304ca57bd072143bbb97ef56 | |
| parent | 1bc3055b737f2e9732a009026f4fe2a322ef7607 (diff) | |
solver3: Only hide ver->pkg clauses, not pkg->ver version selection ones
Particularly as Helmut pointed out we need to show which version we
selected for install if there is only one but there is a versioned
conflicts.
Reported-By: Helmut Grohne <helmut@subdivi.de> on IRC
| -rw-r--r-- | apt-pkg/solver3.cc | 18 | ||||
| -rwxr-xr-x | test/integration/test-bug-612557-garbage-upgrade | 5 | ||||
| -rwxr-xr-x | test/integration/test-solver3-show-version-selection | 28 |
3 files changed, 45 insertions, 6 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index cebface27..4030b9de1 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -249,8 +249,17 @@ std::string APT::Solver::Clause::toString(pkgCache &cache, bool pretty) const out.append(" | "); } } - else if (group == Group::SelectVersion && negative) + else if (pretty && group == Group::SelectVersion && negative) out.append(" conflicts with other versions of itself"); + else if (pretty && group == Group::SelectVersion && reason.Pkg()) { + out.append(solutions.size() > 1 ? " is available in versions " : " is available in version "); + for (auto var : solutions) { + assert(var.Ver()); + if (var != solutions.front()) + out.append(", "); + out.append(var.Ver(cache).VerStr()); + } + } else { out.append(" -> "); @@ -349,8 +358,9 @@ std::string APT::Solver::LongWhyStr(Var var, bool decision, const Clause *rclaus } }; - // Version selection clauses like pkg=ver -> pkg or pkg -> pkg=ver are irrelevant for the user, skip them - if (decision && rclause && rclause->group == Group::SelectVersion) + // Inverse version selection clauses that select the package if the version is selected, + // such as pkg=ver -> pkg, are irrelevant for the user, skip them + if (var.Pkg() && decision && rclause && rclause->group == Group::SelectVersion) { var = rclause->reason; rclause = (*this)[var].reason; @@ -398,7 +408,7 @@ std::string APT::Solver::LongWhyStr(Var var, bool decision, const Clause *rclaus { auto const &state = (*this)[*it]; // Don't print version selection clauses - if (state.reason && state.reason->group == Group::SelectVersion) + if (it->Pkg() && state.reason && state.reason->group == Group::SelectVersion) { --i; continue; diff --git a/test/integration/test-bug-612557-garbage-upgrade b/test/integration/test-bug-612557-garbage-upgrade index a001c4385..00bc9ac2d 100755 --- a/test/integration/test-bug-612557-garbage-upgrade +++ b/test/integration/test-bug-612557-garbage-upgrade @@ -23,9 +23,10 @@ testfailuremsg "E: Unable to satisfy dependencies. Reached two conflicting decis 1. python-uno:i386=1:3.3.0-2 is selected as an upgrade 2. python-uno:i386=1:3.3.0-2 Depends libreoffice-common 3. libreoffice-common:i386 Conflicts openoffice.org-common - 2. openoffice.org-common:i386 is selected for install because: + 2. openoffice.org-common:i386=1:3.2.1-11+squeeze2 is selected for install because: 1. openoffice.org-emailmerge:i386 is selected for install - 2. openoffice.org-emailmerge:i386 PreDepends openoffice.org-common" aptget --trivial-only install python-uno --solver 3.0 + 2. openoffice.org-emailmerge:i386 PreDepends openoffice.org-common + 3. openoffice.org-common:i386 is available in version 1:3.2.1-11+squeeze2" aptget --trivial-only install python-uno --solver 3.0 testfailureequal 'Reading package lists... Building dependency tree... Reading state information... diff --git a/test/integration/test-solver3-show-version-selection b/test/integration/test-solver3-show-version-selection new file mode 100755 index 000000000..c4d23eccf --- /dev/null +++ b/test/integration/test-solver3-show-version-selection @@ -0,0 +1,28 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" +setupenvironment +configarchitecture 'amd64' 's390x' + +insertpackage 'unstable' 'sbuild-build-depends-main-dummy' 's390x' '0.invalid.0' 'Depends: libgstreamer1.0-dev' +insertpackage 'unstable' 'libgstreamer1.0-dev' 's390x' '1.25.90-2' 'Depends: libc6 (>= 2.34)' +insertpackage 'unstable' 'libc6' 's390x' '14.2.0-17' 'Depends: libgcc-s1' +insertpackage 'unstable' 'libgcc-s1' 's390x' '14.2.0-17' 'Multi-Arch: same' +insertpackage 'installed,unstable' 'libgcc-s1' 'amd64' '14.2.0-18' 'Multi-Arch: same' + +setupaptarchive + +testfailuremsg "E: Unable to satisfy dependencies. Reached two conflicting decisions: + 1. libc6:s390x is selected for install because: + 1. sbuild-build-depends-main-dummy:s390x=0.invalid.0 is selected for install + 2. sbuild-build-depends-main-dummy:s390x Depends libgstreamer1.0-dev:s390x + 3. libgstreamer1.0-dev:s390x Depends libc6:s390x (>= 2.34) + 2. libc6:s390x Depends libgcc-s1:s390x + but none of the choices are installable: + - libgcc-s1:s390x is not selected for install because: + 1. libgcc-s1:amd64 is selected for install + 2. libgcc-s1:amd64 is available in version 14.2.0-18 + 3. libgcc-s1:s390x Breaks libgcc-s1 (!= 14.2.0-17)" apt install sbuild-build-depends-main-dummy --solver 3.0 + |
