]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/algorithms.cc
doesn't execute autoremove marker setting if an external solver is called
[apt.git] / apt-pkg / algorithms.cc
index 0b4366e5ebe758a8e0cee36e3fa0f5b2d38c02aa..fea9e92e15d71958f1ad713d5e563a95b6d2ea1c 100644 (file)
 #include <apt-pkg/version.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/acquire-item.h>
-    
+#include <apt-pkg/edsp.h>
+
 #include <apti18n.h>
 #include <sys/types.h>
 #include <cstdlib>
 #include <algorithm>
 #include <iostream>
+
+#include <stdio.h>
                                                                        /*}}}*/
 using namespace std;
 
@@ -731,7 +734,35 @@ 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")
+   {
+      int solver_in, solver_out;
+      if (EDSP::ExecuteSolver(solver.c_str(), &solver_in, &solver_out) == false)
+        return false;
+
+      FILE* output = fdopen(solver_in, "w");
+      if (output == NULL)
+         return _error->Errno("Resolve", "fdopen on solver stdin failed");
+      EDSP::WriteRequest(Cache, output);
+      EDSP::WriteScenario(Cache, output);
+      fclose(output);
+
+      if (EDSP::ReadResponse(solver_out, Cache) == false)
+        return _error->Error("Reading solver response failed");
+
+      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 +776,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 +809,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