diff options
| -rw-r--r-- | apt-pkg/solver3.cc | 10 | ||||
| -rwxr-xr-x | test/integration/test-solver3-break-recommends | 29 |
2 files changed, 39 insertions, 0 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index 052142658..c2877946c 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -964,6 +964,16 @@ APT::Solver::Clause APT::Solver::TranslateOrGroup(pkgCache::DepIterator start, p std::cerr << "Promoting new clause to hard dependency: " << clause.toString(cache) << std::endl; clause.optional = false; } + else if (not existing.end() && importantToKeep(start) && satisfied) + { + if (unlikely(debug >= 3)) + std::cerr << "Restricting existing Recommends to installed packages: " << clause.toString(cache, true) << std::endl; + // Erase the non-installed solutions. We will process this last and try to keep the previously installed + // "best" solution installed. + clause.solutions.erase(std::remove_if(clause.solutions.begin(), clause.solutions.end(), [this](auto var) + { return var.CastPkg(cache)->CurrentVer == nullptr; }), + clause.solutions.end()); + } } return clause; diff --git a/test/integration/test-solver3-break-recommends b/test/integration/test-solver3-break-recommends new file mode 100755 index 000000000..88051f5de --- /dev/null +++ b/test/integration/test-solver3-break-recommends @@ -0,0 +1,29 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" +setupenvironment +configarchitecture 'amd64' + +insertpackage 'installed' 'root' 'all' '1' 'Recommends: a | b' +insertpackage 'installed,unstable' 'a' 'all' '1' +insertpackage 'unstable' 'b' 'all' '1' + +setupaptarchive + +msgmsg "b should not be installed" + +testsuccessequal "Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + a +0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv a [1]" aptget remove a -s + +testsuccessequal "Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + a +0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. +Remv a [1]" apt remove a -s |
