diff options
author | Julian Andres Klode <jak@debian.org> | 2022-07-24 13:05:48 +0000 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2022-07-24 13:05:48 +0000 |
commit | b141ce0d355e667885536790ea5caa2d4d86d333 (patch) | |
tree | 30180c4bf9fdb4c1578e7a61699f2d152da71c09 /apt-pkg | |
parent | e064f27f9af86bc2ad4456ddbfc28deacb043474 (diff) | |
parent | 07fe16bcc62fc84571ff90e8ec6d033226ce431a (diff) |
Merge branch 'pu/upgrade-broken-depends' into 'main'
Mark broken reverse depends for upgrade
See merge request apt-team/apt!248
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/depcache.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index a5b586f5b..82b2fda99 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1445,6 +1445,34 @@ static bool MarkInstall_RemoveConflictsIfNotUpgradeable(pkgDepCache &Cache, bool return not failedToRemoveSomething; } /*}}}*/ +static bool MarkInstall_CollectReverseDepends(pkgDepCache &Cache, bool const DebugAutoInstall, pkgCache::VerIterator const &PV, unsigned long Depth, APT::PackageVector &toUpgrade) /*{{{*/ +{ + auto CurrentVer = PV.ParentPkg().CurrentVer(); + if (CurrentVer.end()) + return true; + for (pkgCache::DepIterator D = PV.ParentPkg().RevDependsList(); D.end() == false; ++D) + { + auto ParentPkg = D.ParentPkg(); + // Skip non-installed versions and packages already marked for upgrade + if (ParentPkg.CurrentVer() != D.ParentVer() || Cache[ParentPkg].Install()) + continue; + // We only handle important positive dependencies, RemoveConflictsIfNotUpgradeable handles negative + if (not Cache.IsImportantDep(D) || D.IsNegative()) + continue; + // The dependency was previously not satisfied (e.g. part of an or group) or will be satisfied, so it's OK + if (not D.IsSatisfied(CurrentVer) || D.IsSatisfied(PV)) + continue; + if (std::find(toUpgrade.begin(), toUpgrade.end(), ParentPkg) != toUpgrade.end()) + continue; + + if (DebugAutoInstall) + std::clog << OutputInDepth(Depth) << " Upgrading: " << APT::PrettyPkg(&Cache, ParentPkg) << " due to " << APT::PrettyDep(&Cache, D) << "\n"; + + toUpgrade.push_back(ParentPkg); + } + return true; +} + /*}}}*/ static bool MarkInstall_UpgradeOrRemoveConflicts(pkgDepCache &Cache, bool const DebugAutoInstall, unsigned long Depth, bool const ForceImportantDeps, APT::PackageVector &toUpgrade, bool const propagateProtected, bool const FromUser) /*{{{*/ { bool failedToRemoveSomething = false; @@ -1641,6 +1669,12 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg, bool AutoInst, return false; hasFailed = true; } + if (not MarkInstall_CollectReverseDepends(*this, DebugAutoInstall, PV, Depth, toUpgrade)) + { + if (failEarly) + return false; + hasFailed = true; + } } if (not FromUser && not MarkInstall_StateChange(Pkg, AutoInst, FromUser)) |