summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-05-12 16:21:10 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2016-05-12 16:21:10 +0200
commit90e7fba4ac16fc764bf6aac7b59c17c3be551b60 (patch)
tree5a4f43c83cbfe0b11a872e8efbc813ac9c0f070a /apt-pkg
parentd67db03c2ab853eba7b67c8870af41796eea387c (diff)
edsp: warn if unexpected stanzas appear in the solution
Unexpected are for examples removal requests for versions which aren't installed, installations of already installed versions & requests to install and remove a package at the same time.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/edsp.cc36
1 files changed, 24 insertions, 12 deletions
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index e54f0d1df..8414c6a23 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -320,6 +320,7 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres
pkgTagFile response(&in, 100);
pkgTagSection section;
+ std::set<decltype(Cache.PkgBegin()->ID)> seenOnce;
while (response.Step(section) == true) {
std::string type;
if (section.Exists("Install") == true)
@@ -362,18 +363,29 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres
}
pkgCache::VerIterator Ver(Cache.GetCache(), Cache.GetCache().VerP + VerIdx[id]);
- Cache.SetCandidateVersion(Ver);
- if (type == "Install")
- {
- pkgCache::PkgIterator const P = Ver.ParentPkg();
- if (Cache[P].Mode != pkgDepCache::ModeInstall)
- Cache.MarkInstall(P, false, 0, false);
- }
- else if (type == "Remove")
- Cache.MarkDelete(Ver.ParentPkg(), false);
- else if (type == "Autoremove") {
- Cache[Ver.ParentPkg()].Marked = false;
- Cache[Ver.ParentPkg()].Garbage = true;
+ auto const Pkg = Ver.ParentPkg();
+ if (type == "Autoremove") {
+ Cache[Pkg].Marked = false;
+ Cache[Pkg].Garbage = true;
+ } else if (seenOnce.emplace(Pkg->ID).second == false) {
+ _error->Warning("Ignoring %s stanza received for package %s which already had a previous stanza effecting it!", type.c_str(), Pkg.FullName(false).c_str());
+ } else if (type == "Install") {
+ if (Pkg.CurrentVer() == Ver) {
+ _error->Warning("Ignoring Install stanza received for version %s of package %s which is already installed!",
+ Ver.VerStr(), Pkg.FullName(false).c_str());
+ } else {
+ Cache.SetCandidateVersion(Ver);
+ Cache.MarkInstall(Pkg, false, 0, false);
+ }
+ } else if (type == "Remove") {
+ if (Pkg->CurrentVer == 0)
+ _error->Warning("Ignoring Remove stanza received for version %s of package %s which isn't installed!",
+ Ver.VerStr(), Pkg.FullName(false).c_str());
+ else if (Pkg.CurrentVer() != Ver)
+ _error->Warning("Ignoring Remove stanza received for version %s of package %s which isn't the installed version %s!",
+ Ver.VerStr(), Pkg.FullName(false).c_str(), Pkg.CurrentVer().VerStr());
+ else
+ Cache.MarkDelete(Ver.ParentPkg(), false);
}
}
return true;