summaryrefslogtreecommitdiff
path: root/apt-pkg/edsp.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-06-04 19:53:54 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2016-06-04 19:53:54 +0200
commit71608330b9b2bd95a0481ca53cd58b584fd61e42 (patch)
tree0faa250dcda0ff2f47f02e75b88b7f070d3c8daf /apt-pkg/edsp.cc
parent307d9eb2d13ee59191b86ffec2f36ba3fffc5c20 (diff)
edsp: use a stanza based interface for solution writing
EDSP had a WriteSolution method to write out the entire solution based on the inspection of a given pkgDepCache, but that is rather inflexible both for EDSP itself and for other EDSP like-protocols. It seems better to use a smaller scope in printing just a single stanza based on a given version as there is more reuse potential.
Diffstat (limited to 'apt-pkg/edsp.cc')
-rw-r--r--apt-pkg/edsp.cc33
1 files changed, 6 insertions, 27 deletions
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index f8925072e..dfd64ca82 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -871,7 +871,7 @@ bool EDSP::ApplyRequest(std::list<std::string> const &install,
return true;
}
/*}}}*/
-// EDSP::WriteSolution - to the given file descriptor /*{{{*/
+// EDSP::WriteSolutionStanza - to the given file descriptor /*{{{*/
bool EDSP::WriteSolution(pkgDepCache &Cache, FILE* output)
{
bool const Debug = _config->FindB("Debug::EDSP::WriteSolution", false);
@@ -903,34 +903,13 @@ bool EDSP::WriteSolution(pkgDepCache &Cache, FILE* output)
return true;
}
-bool EDSP::WriteSolution(pkgDepCache &Cache, FileFd &output)
+bool EDSP::WriteSolutionStanza(FileFd &output, char const * const Type, pkgCache::VerIterator const &Ver)
{
- bool const Debug = _config->FindB("Debug::EDSP::WriteSolution", false);
bool Okay = output.Failed() == false;
- for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false && likely(Okay); ++Pkg)
- {
- std::string action;
- if (Cache[Pkg].Delete() == true)
- WriteOkay(Okay, output, "Remove: ", _system->GetVersionMapping(Pkg.CurrentVer()->ID), "\n");
- else if (Cache[Pkg].NewInstall() == true || Cache[Pkg].Upgrade() == true)
- WriteOkay(Okay, output, "Install: ", _system->GetVersionMapping(Cache.GetCandidateVersion(Pkg)->ID), "\n");
- else if (Cache[Pkg].Garbage == true)
- WriteOkay(Okay, output, "Autoremove: ", _system->GetVersionMapping(Pkg.CurrentVer()->ID), "\n");
- else
- continue;
-
- if (Debug)
- {
- WriteOkay(Okay, output, "Package: ", Pkg.FullName(), "\nVersion: ");
- if (Cache[Pkg].Delete() == true || Cache[Pkg].Garbage == true)
- WriteOkay(Okay, output, Pkg.CurrentVer().VerStr(), "\n\n");
- else
- WriteOkay(Okay, output, Cache.GetCandidateVersion(Pkg).VerStr(), "\n\n");
- }
- else
- WriteOkay(Okay, output, "\n");
- }
- return Okay;
+ WriteOkay(Okay, output, Type, ": ", _system->GetVersionMapping(Ver->ID));
+ if (_config->FindB("Debug::EDSP::WriteSolution", false) == true)
+ WriteOkay(Okay, output, "\nPackage: ", Ver.ParentPkg().FullName(), "\nVersion: ", Ver.VerStr());
+ return WriteOkay(Okay, output, "\n\n");
}
/*}}}*/
// EDSP::WriteProgess - pulse to the given file descriptor /*{{{*/