diff options
| author | Julian Andres Klode <jak@debian.org> | 2026-02-17 09:58:46 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2026-02-17 09:58:46 +0000 |
| commit | f6adace8d302fb72ab92646cbd49f9560fa1ad6a (patch) | |
| tree | 9b82dec92f02559b91a2cf307044ecedcde4ab34 | |
| parent | 1275e2e0ec45e9cdbfeedfa2c069274d80499fa8 (diff) | |
| parent | 9f3ecca2b32e4fe56a05811392e01416092f85fa (diff) | |
Merge branch 'solver3-upgrade-by-source' into 'main'
solver3: Upgrade by source package
See merge request apt-team/apt!553
| -rw-r--r-- | apt-pkg/solver3.cc | 19 | ||||
| -rw-r--r-- | apt-pkg/solver3.h | 1 | ||||
| -rw-r--r-- | test/integration/solver3.broken | 1 | ||||
| -rwxr-xr-x | test/integration/test-apt-get-upgrade-by-source | 52 | ||||
| -rwxr-xr-x | test/integration/test-solver3-evaluation | 31 |
5 files changed, 70 insertions, 34 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index 6d818ed67..bfc187ea6 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -972,6 +972,25 @@ void DependencySolver::Discover(Var var) RegisterClause(std::move(clause)); } + if (UpgradeBySourcePackage && Ver != Ver.ParentPkg().CurrentVer()) + { + // For this version selection, if I have other binaries in the source package that are currently installed, + // mark them for upgrade using an eager optional dependency (which is executed soon, but can be skipped) + for (auto sibling = Ver.SourceVersion().Group().VersionsInSource(); not sibling.end(); sibling = sibling.NextInSource()) + { + // Package is the same; not installed or at right version, don't need to upgrade + if (sibling->ParentPkg == Ver->ParentPkg || not sibling.ParentPkg()->CurrentVer || sibling.ParentPkg().CurrentVer() == sibling) + continue; + // Package has a different source version than us, so it's not relevant + if (strcmp(sibling.SourceVersion().VerStr(), Ver.SourceVersion().VerStr()) != 0) + continue; + Clause clause{Var(Ver), Group::SelectVersion, true /* optional */}; + clause.eager = true; + clause.solutions = {Var(sibling)}; + RegisterClause(std::move(clause)); + } + } + for (auto dep = Ver.DependsList(); not dep.end();) { // Compute a single dependency element (glob or) diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h index 380aa3ad6..9af580b86 100644 --- a/apt-pkg/solver3.h +++ b/apt-pkg/solver3.h @@ -445,6 +445,7 @@ class DependencySolver final : public Solver bool DeferVersionSelection{_config->FindB("APT::Solver::Defer-Version-Selection", true)}; bool KeepRecommends{_config->FindB("APT::AutoRemove::RecommendsImportant", true)}; bool KeepSuggests{_config->FindB("APT::AutoRemove::SuggestsImportant", true)}; + bool UpgradeBySourcePackage{_config->FindB("APT::Get::Upgrade-By-Source-Package", true)}; // Helper functions for detecting obsolete packages mutable FastContiguousCacheMap<pkgCache::Package, LiftedBool> pkgObsolete; diff --git a/test/integration/solver3.broken b/test/integration/solver3.broken index 0e2005d60..671e49dd8 100644 --- a/test/integration/solver3.broken +++ b/test/integration/solver3.broken @@ -1,5 +1,4 @@ test-allow-scores-for-all-dependency-types # TBD: We are lacking single-sided conflicts preferences -test-apt-get-upgrade-by-source # TBD: Upgrading by source is not supported yet, mostly same issue as above test-apt-install-order-matters-a-bit # Wontfix: Cannot fix, the order is not recorded in the depcache test-bug-470115-new-and-tighten-recommends # TBD: Calculation of what is already satisfied Recommends is broken test-prevent-markinstall-multiarch-same-versionscrew # TBD: We consider the skewed ones obsolete and remove them... diff --git a/test/integration/test-apt-get-upgrade-by-source b/test/integration/test-apt-get-upgrade-by-source index bac91f04a..8118ac1c3 100755 --- a/test/integration/test-apt-get-upgrade-by-source +++ b/test/integration/test-apt-get-upgrade-by-source @@ -22,6 +22,54 @@ noprogress() { testsuccessequal "Reading package lists... Building dependency tree... +Solving dependencies...Install pkg:arm64 () +[0] Install:pkg:arm64=2 () +Install pkg-bar:arm64 () +Install pkg-foo:arm64 () +[0] Reject:pkg:arm64=1 (pkg:arm64=2) +[0] Install:pkg:arm64 (pkg:arm64=2) +[1] Install:pkg-bar:arm64 () +[2] Install:pkg-foo:arm64 () +[3] Install:pkg-bar:arm64=2 (pkg:arm64=2) +[3] Reject:pkg-bar:arm64=1 (pkg:arm64=2 -> pkg-bar:arm64=2) +[4] Install:pkg-foo:arm64=2 (pkg:arm64=2) +[4] Reject:pkg-foo:arm64=1 (pkg:arm64=2 -> pkg-foo:arm64=2) + +The following additional packages will be installed: + pkg-bar pkg-foo +The following packages will be upgraded: + pkg pkg-bar pkg-foo +3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. +Inst pkg [1] (2 unstable [all]) +Inst pkg-bar [1] (2 unstable [all]) +Inst pkg-foo [1] (2 unstable [all]) +Conf pkg (2 unstable [all]) +Conf pkg-bar (2 unstable [all]) +Conf pkg-foo (2 unstable [all])" aptget install pkg -o debug::apt::solver=1 --solver 3.0 -s + +testsuccessequal "Reading package lists... +Building dependency tree... +Solving dependencies...Install pkg:arm64 () +[0] Install:pkg:arm64=2 () +Install pkg-bar:arm64 () +Install pkg-foo:arm64 () +[0] Reject:pkg:arm64=1 (pkg:arm64=2) +[0] Install:pkg:arm64 (pkg:arm64=2) +[1] Install:pkg-bar:arm64 () +[2] Install:pkg-foo:arm64 () +[3] Install:pkg-bar:arm64=1 (pkg-bar:arm64) +[3] Reject:pkg-bar:arm64=2 (pkg-bar:arm64 -> pkg-bar:arm64=1) +[4] Install:pkg-foo:arm64=1 (pkg-foo:arm64) +[4] Reject:pkg-foo:arm64=2 (pkg-foo:arm64 -> pkg-foo:arm64=1) + +The following packages will be upgraded: + pkg +1 upgraded, 0 newly installed, 0 to remove and 2 not upgraded. +Inst pkg [1] (2 unstable [all]) +Conf pkg (2 unstable [all])" aptget install pkg -o debug::apt::solver=1 -o APT::Get::Upgrade-By-Source-Package=0 --solver 3.0 -s + +testsuccessequal "Reading package lists... +Building dependency tree... MarkInstall pkg:arm64 < 1 -> 2 @ii pumU > FU=1 Upgrading pkg-bar:arm64 < 1 | 2 @ii umH > due to pkg:arm64 Upgrading pkg-foo:arm64 < 1 | 2 @ii umH > due to pkg:arm64 @@ -38,7 +86,7 @@ Inst pkg-bar [1] (2 unstable [all]) Inst pkg-foo [1] (2 unstable [all]) Conf pkg (2 unstable [all]) Conf pkg-bar (2 unstable [all]) -Conf pkg-foo (2 unstable [all])" aptget install pkg -o debug::pkgdepcache::marker=1 -o Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::AutoInstall=1 -s +Conf pkg-foo (2 unstable [all])" aptget install pkg -o debug::pkgdepcache::marker=1 -o Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::AutoInstall=1 -s --solver internal testsuccessequal "Reading package lists... Building dependency tree... @@ -50,4 +98,4 @@ The following packages will be upgraded: pkg 1 upgraded, 0 newly installed, 0 to remove and 2 not upgraded. Inst pkg [1] (2 unstable [all]) -Conf pkg (2 unstable [all])" aptget install pkg -o debug::pkgdepcache::marker=1 -o Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::AutoInstall=1 -o APT::Get::Upgrade-By-Source-Package=0 -s +Conf pkg (2 unstable [all])" aptget install pkg -o debug::pkgdepcache::marker=1 -o Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::AutoInstall=1 -o APT::Get::Upgrade-By-Source-Package=0 -s --solver internal diff --git a/test/integration/test-solver3-evaluation b/test/integration/test-solver3-evaluation index 06edb4962..b750b9245 100755 --- a/test/integration/test-solver3-evaluation +++ b/test/integration/test-solver3-evaluation @@ -185,34 +185,3 @@ ErrorMessage: AptSolverDump: $(cat rootdir/var/log/apt/edsp.log.zst | base64 | sed 's#^# #')" cat rootdir/var/crash/apt-edsp.$(id -u).crash -msgmsg "Test that more upgrades are not better in installs" -# FIXME: This will fail once 3.0 solver tries upgrading by source package. -insertinstalledpackage 'b' 'all' '2' 'Source: src' -insertinstalledpackage 'c' 'all' '2' 'Source: src' - -# No "Writing error report..." -testsuccess rm rootdir/var/crash/apt-edsp.$(id -u).crash -testsuccessequal "Reading package lists... -Building dependency tree... -Solving dependencies... -The following additional packages will be installed: - c -The following packages will be upgraded: - b c -2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. -Inst b [2] (3 unstable [all]) -Inst c [2] (3 unstable [all]) -Conf b (3 unstable [all]) -Conf c (3 unstable [all])" apt install --solver internal b -s - -testfailure test -e rootdir/var/crash/apt-edsp.$(id -u).crash - -# Safety check to check that the 3.0 result actually looks worse -testsuccessequal "Reading package lists... -Building dependency tree... -Solving dependencies... -The following packages will be upgraded: - b -1 upgraded, 0 newly installed, 0 to remove and 1 not upgraded. -Inst b [2] (3 unstable [all]) -Conf b (3 unstable [all])" apt install --solver 3.0 b -s |
