summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/depcache.cc34
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))