]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/algorithms.cc
strip the Dir::state from the config name as it will never be there
[apt.git] / apt-pkg / algorithms.cc
index 0b4366e5ebe758a8e0cee36e3fa0f5b2d38c02aa..b55ff2897ad9df37c42f06bd21456228fa6c4985 100644 (file)
 #include <apt-pkg/version.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/acquire-item.h>
-    
+#include <apt-pkg/edspwriter.h>
+
 #include <apti18n.h>
 #include <sys/types.h>
 #include <cstdlib>
 #include <algorithm>
 #include <iostream>
+
+#include <stdio.h>
                                                                        /*}}}*/
 using namespace std;
 
@@ -731,7 +734,31 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
    return true;
 }
                                                                        /*}}}*/
-// ProblemResolver::Resolve - Run the resolution pass                  /*{{{*/
+// ProblemResolver::Resolve - calls a resolver to fix the situation    /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgProblemResolver::Resolve(bool BrokenFix)
+{
+   std::string const solver = _config->Find("APT::Solver::Name", "internal");
+   if (solver != "internal")
+   {
+      FILE* output = fopen("/tmp/scenario.log", "w");
+      edspWriter::WriteScenario(Cache, output);
+      fclose(output);
+      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);
+}
+                                                                       /*}}}*/
+// ProblemResolver::ResolveInternal - Run the resolution pass          /*{{{*/
 // ---------------------------------------------------------------------
 /* This routines works by calculating a score for each package. The score
    is derived by considering the package's priority and all reverse 
@@ -745,12 +772,10 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
  
    The BrokenFix flag enables a mode where the algorithm tries to 
    upgrade packages to advoid problems. */
-bool pkgProblemResolver::Resolve(bool BrokenFix)
+bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
 {
    pkgDepCache::ActionGroup group(Cache);
 
-   unsigned long Size = Cache.Head().PackageCount;
-
    // Record which packages are marked for install
    bool Again = false;
    do
@@ -780,7 +805,9 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
       clog << "Starting" << endl;
    
    MakeScores();
-   
+
+   unsigned long const Size = Cache.Head().PackageCount;
+
    /* We have to order the packages so that the broken fixing pass 
       operates from highest score to lowest. This prevents problems when
       high score packages cause the removal of lower score packages that