]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/algorithms.cc
Vietnamese translation update
[apt.git] / apt-pkg / algorithms.cc
index f50c52a3297842910d60b45a661b3b00adf54583..158f9c258f4b1c6c973a6c2d2d29fc5c569f6c0e 100644 (file)
@@ -14,9 +14,6 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/algorithms.h"
-#endif 
 #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>
@@ -26,6 +23,8 @@
     
 #include <apti18n.h>
 #include <sys/types.h>
     
 #include <apti18n.h>
 #include <sys/types.h>
+#include <cstdlib>
+#include <algorithm>
 #include <iostream>
                                                                        /*}}}*/
 using namespace std;
 #include <iostream>
                                                                        /*}}}*/
 using namespace std;
@@ -258,6 +257,8 @@ bool pkgApplyStatus(pkgDepCache &Cache)
            re-unpacked (probably) */
         case pkgCache::State::UnPacked:
         case pkgCache::State::HalfConfigured:
            re-unpacked (probably) */
         case pkgCache::State::UnPacked:
         case pkgCache::State::HalfConfigured:
+        case pkgCache::State::TriggersAwaited:
+        case pkgCache::State::TriggersPending:
         if ((I->CurrentVer != 0 && I.CurrentVer().Downloadable() == true) ||
             I.State() != pkgCache::PkgIterator::NeedsUnpack)
            Cache.MarkKeep(I, false, false);
         if ((I->CurrentVer != 0 && I.CurrentVer().Downloadable() == true) ||
             I.State() != pkgCache::PkgIterator::NeedsUnpack)
            Cache.MarkKeep(I, false, false);
@@ -509,8 +510,10 @@ void pkgProblemResolver::MakeScores()
         Score += PrioMap[Cache[I].InstVerIter(Cache)->Priority];
       
       /* This helps to fix oddball problems with conflicting packages
         Score += PrioMap[Cache[I].InstVerIter(Cache)->Priority];
       
       /* This helps to fix oddball problems with conflicting packages
-         on the same level. We enhance the score of installed packages */
-      if (I->CurrentVer != 0)
+         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 += 1;
    }
 
         Score += 1;
    }
 
@@ -804,7 +807,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
            continue;
         
         if (Debug == true)
            continue;
         
         if (Debug == true)
-           cout << "Investigating " << I.Name() << endl;
+           clog << "Investigating " << I.Name() << endl;
         
         // Isolate the problem dependency
         PackageKill KillList[100];
         
         // Isolate the problem dependency
         PackageKill KillList[100];
@@ -859,7 +862,12 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
               OldEnd = LEnd;
            }
            else
               OldEnd = LEnd;
            }
            else
+            {
               Start++;
               Start++;
+              // We only worry about critical deps.
+              if (Start.IsCritical() != true)
+                  continue;
+            }
 
            // Dep is ok
            if ((Cache[End] & pkgDepCache::DepGInstall) == pkgDepCache::DepGInstall)
 
            // Dep is ok
            if ((Cache[End] & pkgDepCache::DepGInstall) == pkgDepCache::DepGInstall)
@@ -986,6 +994,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
                     }
                     if (Debug)
                        clog << "  Will not break " << Pkg.Name() << " as stated in Breaks field in " << I.Name() <<endl;
                     }
                     if (Debug)
                        clog << "  Will not break " << Pkg.Name() << " as stated in Breaks field in " << I.Name() <<endl;
+                    Cache.MarkKeep(I, false, false);
                     continue;
                  }
 
                     continue;
                  }
 
@@ -1250,8 +1259,13 @@ void pkgProblemResolver::InstallProtect()
       {
         if ((Flags[I->ID] & ToRemove) == ToRemove)
            Cache.MarkDelete(I);
       {
         if ((Flags[I->ID] & ToRemove) == ToRemove)
            Cache.MarkDelete(I);
-        else
-           Cache.MarkInstall(I, false, 0, false);
+        else 
+        {
+           // preserve the information whether the package was auto
+           // or manually installed
+           bool autoInst = (Cache[I].Flags & pkgCache::Flag::Auto);
+           Cache.MarkInstall(I, false, 0, !autoInst);
+        }
       }
    }   
 }
       }
    }   
 }