]> 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 66c182b235ed91392fb745e9c463c21ed2b06a7d..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;
 
@@ -90,21 +93,6 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/)
    Describe(Pkg,cout,true,true);
    Sim.MarkInstall(Pkg,false);
 
-   if (strcmp(Pkg.Arch(),"all") == 0)
-   {
-      pkgCache::GrpIterator G = Pkg.Group();
-      pkgCache::GrpIterator iG = iPkg.Group();
-      for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
-      {
-        if (strcmp(P.Arch(), "all") == 0)
-           continue;
-        if (iG.FindPkg(P.Arch())->CurrentVer == 0)
-           continue;
-        Flags[P->ID] = 1;
-        Sim.MarkInstall(P, false);
-      }
-   }
-
    // Look for broken conflicts+predepends.
    for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++)
    {
@@ -150,40 +138,6 @@ bool pkgSimulate::Configure(PkgIterator iPkg)
    
    Flags[Pkg->ID] = 2;
 
-   if (strcmp(Pkg.Arch(),"all") == 0)
-   {
-      pkgCache::GrpIterator G = Pkg.Group();
-      for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
-      {
-        if (strcmp(P.Arch(), "all") == 0)
-           continue;
-        if (Flags[P->ID] == 1)
-           Flags[P->ID] = 2;
-      }
-   }
-
-   if (Sim[Pkg].InstBroken() == true)
-   {
-      /* We don't call Configure for Pseudo packages and if the 'all' is already installed
-         the simulation will think the pseudo package is not installed, so if something is
-         broken we walk over the dependencies and search for not installed pseudo packages */
-      for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; D++)
-      {
-        if (Sim.IsImportantDep(D) == false || 
-            (Sim[D] & pkgDepCache::DepInstall) != 0)
-           continue;
-        pkgCache::PkgIterator T = D.TargetPkg();
-        if (T.end() == true || T->CurrentVer != 0 || Flags[T->ID] != 0)
-           continue;
-        pkgCache::PkgIterator A = T.Group().FindPkg("all");
-        if (A.end() == true || A->VersionList == 0 || A->CurrentVer == 0 ||
-            Cache.VS().CheckDep(A.CurVersion(), pkgCache::Dep::Equals, T.CandVersion()) == false)
-           continue;
-        Sim.MarkInstall(T, false);
-        Flags[T->ID] = 2;
-      }
-   }
-
    if (Sim[Pkg].InstBroken() == true)
    {
       cout << "Conf " << Pkg.FullName(false) << " broken" << endl;
@@ -235,21 +189,6 @@ bool pkgSimulate::Remove(PkgIterator iPkg,bool Purge)
    Flags[Pkg->ID] = 3;
    Sim.MarkDelete(Pkg);
 
-   if (strcmp(Pkg.Arch(),"all") == 0)
-   {
-      pkgCache::GrpIterator G = Pkg.Group();
-      pkgCache::GrpIterator iG = iPkg.Group();
-      for (pkgCache::PkgIterator P = G.FindPkg("any"); P.end() != true; P = G.NextPkg(P))
-      {
-        if (strcmp(P.Arch(), "all") == 0)
-           continue;
-        if (iG.FindPkg(P.Arch())->CurrentVer == 0)
-           continue;
-        Flags[P->ID] = 3;
-        Sim.MarkDelete(P);
-      }
-   }
-
    if (Purge == true)
       cout << "Purg ";
    else
@@ -795,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 
@@ -809,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
@@ -844,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