Просмотр исходного кода

be able to write solutions, too

David Kalnischkies лет назад: 15
Родитель
Сommit
e3674d91d2
3 измененных файлов с 27 добавлено и 0 удалено
  1. 6 0
      apt-pkg/algorithms.cc
  2. 20 0
      apt-pkg/edsp/edspwriter.cc
  3. 1 0
      apt-pkg/edsp/edspwriter.h

+ 6 - 0
apt-pkg/algorithms.cc

@@ -748,6 +748,12 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
       output = fopen("/tmp/request.log", "w");
       edspWriter::WriteRequest(Cache, output);
       fclose(output);
+      if (ResolveInternal(BrokenFix) == false)
+	 return false;
+      output = fopen("/tmp/solution.log", "w");
+      edspWriter::WriteSolution(Cache, output);
+      fclose(output);
+      return true;
    }
    return ResolveInternal(BrokenFix);
 }

+ 20 - 0
apt-pkg/edsp/edspwriter.cc

@@ -125,6 +125,26 @@ bool edspWriter::WriteRequest(pkgDepCache &Cache, FILE* output)
    if (upgrade.empty() == false)
       fprintf(output, "Upgrade: %s\n", upgrade.c_str()+2);
 
+   return true;
+}
+									/*}}}*/
+// edspWriter::WriteSolution - to the given file descriptor		/*{{{*/
+bool edspWriter::WriteSolution(pkgDepCache &Cache, FILE* output)
+{
+   bool const Debug = _config->FindB("Debug::EDSPWriter::WriteSolution", false);
+   for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg)
+   {
+      if (Cache[Pkg].Delete() == true)
+	 fprintf(output, "Remove: %d\n", Cache.GetCandidateVer(Pkg)->ID);
+      else if (Cache[Pkg].NewInstall() == true || Cache[Pkg].Upgrade() == true)
+	 fprintf(output, "Install: %d\n", Cache.GetCandidateVer(Pkg)->ID);
+      else
+	 continue;
+      if (Debug == true)
+	 fprintf(output, "Package: %s\nVersion: %s\n", Pkg.FullName().c_str(), Cache.GetCandidateVer(Pkg).VerStr());
+      fprintf(output, "\n");
+   }
+
    return true;
 }
 									/*}}}*/

+ 1 - 0
apt-pkg/edsp/edspwriter.h

@@ -14,6 +14,7 @@ class edspWriter								/*{{{*/
 public:
 	bool static WriteUniverse(pkgDepCache &Cache, FILE* output);
 	bool static WriteRequest(pkgDepCache &Cache, FILE* output);
+	bool static WriteSolution(pkgDepCache &Cache, FILE* output);
 };
 									/*}}}*/
 #endif