]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/algorithms.cc
reorder includes: add <config.h> if needed and include it at first
[apt.git] / apt-pkg / algorithms.cc
index 6f1f82d501c95af5ce73832021a1a848f6f91352..d5652791c1a1964fe0d0f14c56aa7f1ce2ea0dda 100644 (file)
@@ -14,6 +14,8 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include <config.h>
+
 #include <apt-pkg/algorithms.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.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>
+
+#include <apti18n.h>
                                                                        /*}}}*/
 using namespace std;
 
@@ -330,7 +332,7 @@ bool pkgFixBroken(pkgDepCache &Cache)
  */
 bool pkgDistUpgrade(pkgDepCache &Cache)
 {
-   std::string const solver = _config->Find("APT::Solver::Name", "internal");
+   std::string const solver = _config->Find("APT::Solver", "internal");
    if (solver != "internal") {
       OpTextProgress Prog(*_config);
       return EDSP::ResolveExternal(solver.c_str(), Cache, false, true, false, &Prog);
@@ -388,7 +390,7 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
    to install packages not marked for install */
 bool pkgAllUpgrade(pkgDepCache &Cache)
 {
-   std::string const solver = _config->Find("APT::Solver::Name", "internal");
+   std::string const solver = _config->Find("APT::Solver", "internal");
    if (solver != "internal") {
       OpTextProgress Prog(*_config);
       return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, &Prog);
@@ -745,7 +747,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
 /* */
 bool pkgProblemResolver::Resolve(bool BrokenFix)
 {
-   std::string const solver = _config->Find("APT::Solver::Name", "internal");
+   std::string const solver = _config->Find("APT::Solver", "internal");
    if (solver != "internal") {
       OpTextProgress Prog(*_config);
       return EDSP::ResolveExternal(solver.c_str(), Cache, false, false, false, &Prog);
@@ -1204,6 +1206,31 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
    return true;
 }
                                                                        /*}}}*/
+
+// ProblemResolver::BreaksInstOrPolicy - Check if the given pkg is broken/*{{{*/
+// ---------------------------------------------------------------------
+/* This checks if the given package is broken either by a hard dependency
+   (InstBroken()) or by introducing a new policy breakage e.g. new
+   unsatisfied recommends for a package that was in "policy-good" state
+
+   Note that this is not perfect as it will ignore further breakage
+   for already broken policy (recommends)
+*/
+bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I)
+{
+   
+   // a broken install is always a problem
+   if (Cache[I].InstBroken() == true)
+      return true;
+
+   // a newly broken policy (recommends/suggests) is a problem
+   if (Cache[I].NowPolicyBroken() == false &&
+       Cache[I].InstPolicyBroken() == true)
+      return true;
+       
+   return false;
+}
+
 // ProblemResolver::ResolveByKeep - Resolve problems using keep                /*{{{*/
 // ---------------------------------------------------------------------
 /* This is the work horse of the soft upgrade routine. It is very gental 
@@ -1211,7 +1238,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
    system was non-broken previously. */
 bool pkgProblemResolver::ResolveByKeep()
 {
-   std::string const solver = _config->Find("APT::Solver::Name", "internal");
+   std::string const solver = _config->Find("APT::Solver", "internal");
    if (solver != "internal") {
       OpTextProgress Prog(*_config);
       return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, &Prog);
@@ -1263,9 +1290,12 @@ bool pkgProblemResolver::ResolveByKeepInternal()
    {
       pkgCache::PkgIterator I(Cache,*K);
 
-      if (Cache[I].InstallVer == 0 || Cache[I].InstBroken() == false)
+      if (Cache[I].InstallVer == 0)
         continue;
 
+      if (InstOrNewPolicyBroken(I) == false)
+         continue;
+
       /* Keep the package. If this works then great, otherwise we have
                 to be significantly more agressive and manipulate its dependencies */
       if ((Flags[I->ID] & Protected) == 0)
@@ -1273,7 +1303,7 @@ bool pkgProblemResolver::ResolveByKeepInternal()
         if (Debug == true)
            clog << "Keeping package " << I.FullName(false) << endl;
         Cache.MarkKeep(I, false, false);
-        if (Cache[I].InstBroken() == false)
+        if (InstOrNewPolicyBroken(I) == false)
         {
            K = PList - 1;
            continue;
@@ -1323,11 +1353,11 @@ bool pkgProblemResolver::ResolveByKeepInternal()
                  Cache.MarkKeep(Pkg, false, false);
               }
               
-              if (Cache[I].InstBroken() == false)
+              if (InstOrNewPolicyBroken(I) == false)
                  break;
            }
            
-           if (Cache[I].InstBroken() == false)
+           if (InstOrNewPolicyBroken(I) == false)
               break;
 
            if (Start == End)
@@ -1335,11 +1365,11 @@ bool pkgProblemResolver::ResolveByKeepInternal()
            Start++;
         }
              
-        if (Cache[I].InstBroken() == false)
+        if (InstOrNewPolicyBroken(I) == false)
            break;
       }
 
-      if (Cache[I].InstBroken() == true)
+      if (InstOrNewPolicyBroken(I) == true)
         continue;
       
       // Restart again.