]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/algorithms.cc
Merge remote-tracking branch 'upstream/debian/experimental' into feature/acq-trans
[apt.git] / apt-pkg / algorithms.cc
index 4d86e5ff8488e4cd6005af77a5049305e5559860..71b5ac2c1607087668229fe49678bed00cfbde91 100644 (file)
 #include <apt-pkg/algorithms.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/algorithms.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
-#include <apt-pkg/version.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/sptr.h>
-#include <apt-pkg/acquire-item.h>
 #include <apt-pkg/edsp.h>
 #include <apt-pkg/edsp.h>
-#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/fileutl.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/progress.h>
+#include <apt-pkg/depcache.h>
+#include <apt-pkg/packagemanager.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/cacheiterators.h>
 
 
-#include <sys/types.h>
+#include <string.h>
+#include <string>
 #include <cstdlib>
 #include <cstdlib>
-#include <algorithm>
 #include <iostream>
 #include <iostream>
-#include <stdio.h>
 
 #include <apti18n.h>
                                                                        /*}}}*/
 
 #include <apti18n.h>
                                                                        /*}}}*/
@@ -446,20 +445,34 @@ void pkgProblemResolver::MakeScores()
          || (I->Flags & pkgCache::Flag::Important) == pkgCache::Flag::Important)
         Score += PrioEssentials;
 
          || (I->Flags & pkgCache::Flag::Important) == pkgCache::Flag::Important)
         Score += PrioEssentials;
 
-      // We transform the priority
-      if (Cache[I].InstVerIter(Cache)->Priority <= 5)
-        Score += PrioMap[Cache[I].InstVerIter(Cache)->Priority];
-      
+      pkgCache::VerIterator const InstVer = Cache[I].InstVerIter(Cache);
+      // We apply priorities only to downloadable packages, all others are prio:extra
+      // as an obsolete prio:standard package can't be that standard anymore…
+      if (InstVer->Priority <= pkgCache::State::Extra && InstVer.Downloadable() == true)
+        Score += PrioMap[InstVer->Priority];
+      else
+        Score += PrioMap[pkgCache::State::Extra];
+
       /* This helps to fix oddball problems with conflicting packages
       /* This helps to fix oddball problems with conflicting packages
-         on the same level. We enhance the score of installed packages 
-        if those are not obsolete
-      */
+        on the same level. We enhance the score of installed packages
+        if those are not obsolete */
       if (I->CurrentVer != 0 && Cache[I].CandidateVer != 0 && Cache[I].CandidateVerIter(Cache).Downloadable())
         Score += PrioInstalledAndNotObsolete;
 
       // propagate score points along dependencies
       if (I->CurrentVer != 0 && Cache[I].CandidateVer != 0 && Cache[I].CandidateVerIter(Cache).Downloadable())
         Score += PrioInstalledAndNotObsolete;
 
       // propagate score points along dependencies
-      for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D)
-        Scores[D.TargetPkg()->ID] += DepMap[D->Type];
+      for (pkgCache::DepIterator D = InstVer.DependsList(); D.end() == false; ++D)
+      {
+        if (DepMap[D->Type] == 0)
+           continue;
+        pkgCache::PkgIterator const T = D.TargetPkg();
+        if (D->Version != 0)
+        {
+           pkgCache::VerIterator const IV = Cache[T].InstVerIter(Cache);
+           if (IV.end() == true || D.IsSatisfied(IV) != D.IsNegative())
+              continue;
+        }
+        Scores[T->ID] += DepMap[D->Type];
+      }
    }
 
    // Copy the scores to advoid additive looping
    }
 
    // Copy the scores to advoid additive looping
@@ -627,13 +640,11 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
 // ProblemResolver::Resolve - calls a resolver to fix the situation    /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 // ProblemResolver::Resolve - calls a resolver to fix the situation    /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-bool pkgProblemResolver::Resolve(bool BrokenFix)
+bool pkgProblemResolver::Resolve(bool BrokenFix, OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "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);
-   }
+   if (solver != "internal")
+      return EDSP::ResolveExternal(solver.c_str(), Cache, false, false, false, Progress);
    return ResolveInternal(BrokenFix);
 }
                                                                        /*}}}*/
    return ResolveInternal(BrokenFix);
 }
                                                                        /*}}}*/
@@ -874,8 +885,8 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
                }
 
               if (Debug == true)
                }
 
               if (Debug == true)
-                 clog << "  Considering " << Pkg.FullName(false) << ' ' << (int)Scores[Pkg->ID] <<
-                 " as a solution to " << I.FullName(false) << ' ' << (int)Scores[I->ID] << endl;
+                 clog << "  Considering " << Pkg.FullName(false) << ' ' << Scores[Pkg->ID] <<
+                 " as a solution to " << I.FullName(false) << ' ' << Scores[I->ID] << endl;
 
               /* Try to fix the package under consideration rather than
                  fiddle with the VList package */
 
               /* Try to fix the package under consideration rather than
                  fiddle with the VList package */
@@ -1127,13 +1138,11 @@ bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I)
 /* This is the work horse of the soft upgrade routine. It is very gental 
    in that it does not install or remove any packages. It is assumed that the
    system was non-broken previously. */
 /* This is the work horse of the soft upgrade routine. It is very gental 
    in that it does not install or remove any packages. It is assumed that the
    system was non-broken previously. */
-bool pkgProblemResolver::ResolveByKeep()
+bool pkgProblemResolver::ResolveByKeep(OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "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);
-   }
+   if (solver != "internal")
+      return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, Progress);
    return ResolveByKeepInternal();
 }
                                                                        /*}}}*/
    return ResolveByKeepInternal();
 }
                                                                        /*}}}*/