summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-03-30 22:15:40 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-03-30 22:15:40 +0200
commite3674d91d27a7290d2b01e14eb2540e10be9d883 (patch)
tree04490a287865c4ffa8dc3ef087618eda8cf4f3f9
parent6d38011bb93451dd9da3294614d821c77ac91687 (diff)
be able to write solutions, too
-rw-r--r--apt-pkg/algorithms.cc6
-rw-r--r--apt-pkg/edsp/edspwriter.cc20
-rw-r--r--apt-pkg/edsp/edspwriter.h1
3 files changed, 27 insertions, 0 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 2ca3404a0..35752a5c4 100644
--- a/apt-pkg/algorithms.cc
+++ b/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);
}
diff --git a/apt-pkg/edsp/edspwriter.cc b/apt-pkg/edsp/edspwriter.cc
index 38d0d82c5..ea46065c2 100644
--- a/apt-pkg/edsp/edspwriter.cc
+++ b/apt-pkg/edsp/edspwriter.cc
@@ -128,3 +128,23 @@ bool edspWriter::WriteRequest(pkgDepCache &Cache, FILE* output)
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;
+}
+ /*}}}*/
diff --git a/apt-pkg/edsp/edspwriter.h b/apt-pkg/edsp/edspwriter.h
index 52923ff73..c42dfd398 100644
--- a/apt-pkg/edsp/edspwriter.h
+++ b/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