Parcourir la source

WriteRequest according to current EDSP draft

David Kalnischkies il y a 15 ans
Parent
commit
93794bc92e
2 fichiers modifiés avec 21 ajouts et 8 suppressions
  1. 17 7
      apt-pkg/edsp.cc
  2. 4 1
      apt-pkg/edsp.h

+ 17 - 7
apt-pkg/edsp.cc

@@ -102,28 +102,38 @@ bool EDSP::WriteScenario(pkgDepCache &Cache, FILE* output)
 }
 }
 									/*}}}*/
 									/*}}}*/
 // EDSP::WriteRequest - to the given file descriptor			/*{{{*/
 // 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)
    for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg)
    {
    {
       string* req;
       string* req;
       if (Cache[Pkg].Delete() == true)
       if (Cache[Pkg].Delete() == true)
 	 req = &del;
 	 req = &del;
-      else if (Cache[Pkg].NewInstall() == true)
+      else if (Cache[Pkg].NewInstall() == true || Cache[Pkg].Upgrade() == true)
 	 req = &inst;
 	 req = &inst;
-      else if (Cache[Pkg].Upgrade() == true)
-	 req = &upgrade;
       else
       else
 	 continue;
 	 continue;
       req->append(", ").append(Pkg.FullName());
       req->append(", ").append(Pkg.FullName());
    }
    }
+   fprintf(output, "Request: EDSP 0.2\n");
    if (del.empty() == false)
    if (del.empty() == false)
       fprintf(output, "Remove: %s\n", del.c_str()+2);
       fprintf(output, "Remove: %s\n", del.c_str()+2);
    if (inst.empty() == false)
    if (inst.empty() == false)
       fprintf(output, "Install: %s\n", inst.c_str()+2);
       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;
    return true;
 }
 }

+ 4 - 1
apt-pkg/edsp.h

@@ -14,7 +14,10 @@
 class EDSP								/*{{{*/
 class EDSP								/*{{{*/
 {
 {
 public:
 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 WriteScenario(pkgDepCache &Cache, FILE* output);
 	bool static ReadResponse(FILE* input, pkgDepCache &Cache);
 	bool static ReadResponse(FILE* input, pkgDepCache &Cache);