From 93794bc92e8d2fd84c6e596e3238c31d0832c271 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 31 Mar 2011 15:32:55 +0200 Subject: [PATCH] WriteRequest according to current EDSP draft --- apt-pkg/edsp.cc | 24 +++++++++++++++++------- apt-pkg/edsp.h | 5 ++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 1af5aed53..db0e2466c 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -102,28 +102,38 @@ bool EDSP::WriteScenario(pkgDepCache &Cache, FILE* output) } /*}}}*/ // EDSP::WriteRequest - to the given file descriptor /*{{{*/ -bool EDSP::WriteRequest(pkgDepCache &Cache, FILE* output) +bool EDSP::WriteRequest(pkgDepCache &Cache, FILE* output, bool const Upgrade, + bool const DistUpgrade, bool const AutoRemove) { - string del, inst, upgrade; + string del, inst; for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg) { string* req; if (Cache[Pkg].Delete() == true) req = &del; - else if (Cache[Pkg].NewInstall() == true) + else if (Cache[Pkg].NewInstall() == true || Cache[Pkg].Upgrade() == true) req = &inst; - else if (Cache[Pkg].Upgrade() == true) - req = &upgrade; else continue; req->append(", ").append(Pkg.FullName()); } + fprintf(output, "Request: EDSP 0.2\n"); if (del.empty() == false) fprintf(output, "Remove: %s\n", del.c_str()+2); if (inst.empty() == false) fprintf(output, "Install: %s\n", inst.c_str()+2); - if (upgrade.empty() == false) - fprintf(output, "Upgrade: %s\n", upgrade.c_str()+2); + if (Upgrade == true) + fprintf(output, "Upgrade: yes\n"); + if (DistUpgrade == true) + fprintf(output, "Dist-Upgrade: yes\n"); + if (AutoRemove == true) + fprintf(output, "Autoremove: yes\n"); + if (_config->FindB("APT::Solver::Strict-Pinning", true) == false) + fprintf(output, "Strict-Pinning: no\n"); + string solverpref("APT::Solver::"); + solverpref.append(_config->Find("APT::Solver::Name", "internal")).append("::Preferences"); + if (_config->Exists(solverpref) == false) + fprintf(output, "Preferences: %s\n", _config->Find(solverpref,"").c_str()); return true; } diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h index ef137b8f6..04d8c255f 100644 --- a/apt-pkg/edsp.h +++ b/apt-pkg/edsp.h @@ -14,7 +14,10 @@ class EDSP /*{{{*/ { public: - bool static WriteRequest(pkgDepCache &Cache, FILE* output); + bool static WriteRequest(pkgDepCache &Cache, FILE* output, + bool const Upgrade = false, + bool const DistUpgrade = false, + bool const AutoRemove = false); bool static WriteScenario(pkgDepCache &Cache, FILE* output); bool static ReadResponse(FILE* input, pkgDepCache &Cache); -- 2.45.2