diff options
| author | Julian Andres Klode <jak@debian.org> | 2022-07-24 15:00:47 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2022-07-24 15:00:47 +0000 |
| commit | b31829210ef344517e2ea5702a008ccf4663212d (patch) | |
| tree | a25b5b63d2295a50c19ada111102c98d7dff2bfa /apt-pkg | |
| parent | b141ce0d355e667885536790ea5caa2d4d86d333 (diff) | |
| parent | c28fc7366c6645cb6d1010a44ce494b5ae1b9a9f (diff) | |
Merge branch 'pu/upgrade-other-binaries' into 'main'
Upgrade all binaries in a source package
See merge request apt-team/apt!247
Diffstat (limited to 'apt-pkg')
| -rw-r--r-- | apt-pkg/depcache.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 82b2fda99..bc5843153 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1494,6 +1494,41 @@ static bool MarkInstall_UpgradeOrRemoveConflicts(pkgDepCache &Cache, bool const return not failedToRemoveSomething; } /*}}}*/ +static bool MarkInstall_UpgradeOtherBinaries(pkgDepCache &Cache, bool const DebugAutoInstall, unsigned long Depth, bool const ForceImportantDeps, pkgCache::PkgIterator Pkg, pkgCache::VerIterator Ver) /*{{{*/ +{ + APT::PackageSet toUpgrade; + + if (not _config->FindB("APT::Get::Upgrade-By-Source-Package", true)) + return true; + + auto SrcGrp = Cache.FindGrp(Ver.SourcePkgName()); + for (auto OtherBinary = SrcGrp.VersionsInSource(); not OtherBinary.end(); OtherBinary = OtherBinary.NextInSource()) + { + auto OtherPkg = OtherBinary.ParentPkg(); + auto OtherState = Cache[OtherPkg]; + if (OtherPkg == Pkg) + continue; + // Package is not installed or at right version, don't need to upgrade + if (OtherPkg->CurrentVer == 0 || OtherPkg.CurrentVer() == OtherBinary) + continue; + // Package is to be installed at right version, don't need to upgrade + if (OtherState.Install() && OtherState.InstallVer == OtherBinary) + continue; + // Package has a different source version than us, so it's not relevant + if (strcmp(OtherBinary.SourceVerStr(), Ver.SourceVerStr()) != 0 || OtherState.CandidateVer != OtherBinary) + continue; + if (DebugAutoInstall) + std::clog << OutputInDepth(Depth) << "Upgrading " << APT::PrettyPkg(&Cache, OtherPkg) << " due to " << Pkg.FullName() << '\n'; + + toUpgrade.insert(OtherPkg); + } + for (auto &OtherPkg : toUpgrade) + Cache.MarkInstall(OtherPkg, false, Depth + 1, false, ForceImportantDeps); + for (auto &OtherPkg : toUpgrade) + Cache.MarkInstall(OtherPkg, true, Depth + 1, false, ForceImportantDeps); + return true; +} + /*}}}*/ static bool MarkInstall_InstallDependencies(pkgDepCache &Cache, bool const DebugAutoInstall, bool const DebugMarker, pkgCache::PkgIterator const &Pkg, unsigned long Depth, bool const ForceImportantDeps, std::vector<pkgCache::DepIterator> &toInstall, APT::PackageVector *const toMoveAuto, bool const propagateProtected, bool const FromUser) /*{{{*/ { auto const IsSatisfiedByInstalled = [&](auto &D) { return (Cache[pkgCache::DepIterator{Cache, &D}] & pkgDepCache::DepInstall) == pkgDepCache::DepInstall; }; @@ -1705,6 +1740,8 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg, bool AutoInst, operator bool() noexcept { return already; } } propagateProtected{PkgState[Pkg->ID]}; + if (not MarkInstall_UpgradeOtherBinaries(*this, DebugAutoInstall, Depth, ForceImportantDeps, Pkg, P.CandidateVerIter(*this))) + return false; if (not MarkInstall_UpgradeOrRemoveConflicts(*this, DebugAutoInstall, Depth, ForceImportantDeps, toUpgrade, propagateProtected, FromUser)) { if (failEarly) |
