summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2020-04-27 13:48:33 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2020-04-27 13:48:33 +0200
commit347ea3f76ab263c729468e07b910ae027b66c9d8 (patch)
treef673c005729edb6bde575b430b95e62abb0b634f
parent76498d46855c88b90316e4369ac32050db9a9d23 (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).
-rw-r--r--apt-pkg/depcache.cc39
-rw-r--r--apt-pkg/depcache.h2
2 files changed, 24 insertions, 17 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();
diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h
index 9f2fc3477..669514e3f 100644
--- a/apt-pkg/depcache.h
+++ b/apt-pkg/depcache.h
@@ -520,7 +520,7 @@ class APT_PUBLIC pkgDepCache : protected pkgCache::Namespace
APT_HIDDEN bool MarkInstall_StateChange(PkgIterator const &Pkg, bool AutoInst, bool FromUser);
APT_HIDDEN bool MarkInstall_CollectDependencies(pkgCache::VerIterator const &PV, std::vector<pkgCache::DepIterator> &toInstall, std::vector<pkgCache::DepIterator> &toRemove);
- APT_HIDDEN bool MarkInstall_RemoveConflictsIfNotUpgradeable(unsigned long Depth, std::vector<pkgCache::DepIterator> &toRemove, APT::PackageVector &toUpgrade);
+ APT_HIDDEN bool MarkInstall_RemoveConflictsIfNotUpgradeable(pkgCache::VerIterator const &PV, unsigned long Depth, std::vector<pkgCache::DepIterator> &toRemove, APT::PackageVector &toUpgrade);
APT_HIDDEN bool MarkInstall_UpgradeOrRemoveConflicts(unsigned long Depth, bool const ForceImportantDeps, APT::PackageVector &toUpgrade);
APT_HIDDEN bool MarkInstall_InstallDependencies(PkgIterator const &Pkg, unsigned long Depth, bool const ForceImportantDeps, std::vector<pkgCache::DepIterator> &toInstall, APT::PackageVector *const toMoveAuto);
};