diff options
author | David Kalnischkies <david@kalnischkies.de> | 2020-04-27 13:48:33 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2020-04-27 13:48:33 +0200 |
commit | 347ea3f76ab263c729468e07b910ae027b66c9d8 (patch) | |
tree | f673c005729edb6bde575b430b95e62abb0b634f /apt-pkg/depcache.cc | |
parent | 76498d46855c88b90316e4369ac32050db9a9d23 (diff) |
Fail earlier on impossible Conflicts in MarkInstall
MarkDelete is not recursive as MarkInstall is and we can not conflict
with ourselves anyhow, so we can move the unavoidable deletes before
changing the state of the package in question avoiding the need for the
state update in case of conflicts we can not deal with (e.g. the package
conflicts with an explicit user request).
Diffstat (limited to 'apt-pkg/depcache.cc')
-rw-r--r-- | apt-pkg/depcache.cc | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index b88e9ceb8..4b2da4b4b 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1137,7 +1137,7 @@ bool pkgDepCache::MarkInstall_CollectDependencies(pkgCache::VerIterator const &P return true; } /*}}}*/ -bool pkgDepCache::MarkInstall_RemoveConflictsIfNotUpgradeable(unsigned long Depth, std::vector<pkgCache::DepIterator> &toRemove, APT::PackageVector &toUpgrade) /*{{{*/ +bool pkgDepCache::MarkInstall_RemoveConflictsIfNotUpgradeable(pkgCache::VerIterator const &PV, unsigned long Depth, std::vector<pkgCache::DepIterator> &toRemove, APT::PackageVector &toUpgrade) /*{{{*/ { /* Negative dependencies have no or-group If the dependency isn't versioned, we try if an upgrade might solve the problem. @@ -1167,7 +1167,7 @@ bool pkgDepCache::MarkInstall_RemoveConflictsIfNotUpgradeable(unsigned long Dept else { if(DebugAutoInstall == true) - std::clog << OutputInDepth(Depth) << " Removing: " << Pkg.Name() << " as upgrade is not an option\n"; + std::clog << OutputInDepth(Depth) << " Removing: " << Pkg.Name() << " as upgrade is not an option for " << PV.ParentPkg().FullName() << "(" << PV.VerStr() << ")\n"; if (not MarkDelete(Pkg, false, Depth + 1, false)) return false; } @@ -1340,32 +1340,39 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg, bool AutoInst, if (not IsInstallOk(Pkg, AutoInst, Depth, FromUser)) return false; + bool const AutoSolve = AutoInst && _config->Find("APT::Solver", "internal") == "internal"; + + std::vector<pkgCache::DepIterator> toInstall, toRemove; + APT::PackageVector toUpgrade; + if (AutoSolve) + { + VerIterator const PV = P.CandidateVerIter(*this); + if (unlikely(PV.end())) + return false; + if (not MarkInstall_CollectDependencies(PV, toInstall, toRemove)) + return false; + + if (not MarkInstall_RemoveConflictsIfNotUpgradeable(PV, Depth, toRemove, toUpgrade)) + return false; + } + ActionGroup group(*this); if (not MarkInstall_StateChange(Pkg, AutoInst, FromUser)) return false; - if (not AutoInst || _config->Find("APT::Solver", "internal") != "internal") + if (not AutoSolve) return true; if (DebugMarker) - std::clog << OutputInDepth(Depth) << "MarkInstall " << APT::PrettyPkg(this, Pkg) << " FU=" << FromUser << std::endl; - - VerIterator const PV = P.InstVerIter(*this); - if (unlikely(PV.end())) - return false; - - std::vector<pkgCache::DepIterator> toInstall, toRemove; - if (not MarkInstall_CollectDependencies(PV, toInstall, toRemove)) - return false; - - APT::PackageVector toUpgrade; - if (not MarkInstall_RemoveConflictsIfNotUpgradeable(Depth, toRemove, toUpgrade)) - return false; + std::clog << OutputInDepth(Depth) << "MarkInstall " << APT::PrettyPkg(this, Pkg) << " FU=" << FromUser << '\n'; if (not MarkInstall_UpgradeOrRemoveConflicts(Depth, ForceImportantDeps, toUpgrade)) return false; bool const MoveAutoBitToDependencies = [&]() { + VerIterator const PV = P.InstVerIter(*this); + if (unlikely(PV.end())) + return false; if (PV->Section == 0 || (P.Flags & Flag::Auto) == Flag::Auto) return false; VerIterator const CurVer = Pkg.CurrentVer(); |