]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/algorithms.cc
Perl glitch in the problem resolver
[apt.git] / apt-pkg / algorithms.cc
index 43593e71b884b566bb0acb62e569dabb572807fa..60da32d783f338ae900a3f7771694c65e30ff53c 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: algorithms.cc,v 1.15 1999/01/30 02:12:53 jgg Exp $
+// $Id: algorithms.cc,v 1.19 1999/06/28 03:11:24 jgg Exp $
 /* ######################################################################
 
    Algorithms - A set of misc algorithms
@@ -169,16 +169,37 @@ bool pkgApplyStatus(pkgDepCache &Cache)
       if (I->InstState == pkgCache::State::ReInstReq ||
          I->InstState == pkgCache::State::HoldReInstReq)
       {
-        Cache.MarkKeep(I);
+        if (I.CurrentVer().Downloadable() == true)
+           Cache.MarkKeep(I);
+        else
+        {
+           // Is this right? Will dpkg choke on an upgrade?
+           if (Cache[I].CandidateVerIter(Cache).Downloadable() == true)
+              Cache.MarkInstall(I);
+           else
+              return _error->Error("The package %s needs to be reinstalled, "
+                                   "but I can't find an archive for it.",I.Name());
+        }
+        
         continue;
       }
       
       switch (I->CurrentState)
       {
-        // This means installation failed somehow
+        /* This means installation failed somehow - it does not need to be
+           re-unpacked (probably) */
         case pkgCache::State::UnPacked:
         case pkgCache::State::HalfConfigured:
-        Cache.MarkKeep(I);
+        if (I.CurrentVer().Downloadable() == true || 
+            I.State() != pkgCache::PkgIterator::NeedsUnpack)
+           Cache.MarkKeep(I);
+        else
+        {
+           if (Cache[I].CandidateVerIter(Cache).Downloadable() == true)
+              Cache.MarkInstall(I);
+           else
+              Cache.MarkDelete(I);
+        }
         break;
 
         // This means removal failed
@@ -700,7 +721,8 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
            {
               if (Debug == true)
                  clog << "Note, a broken or group was found in " << I.Name() << "." << endl;
-              Cache.MarkDelete(I);
+              if ((Flags[I->ID] & Protected) != Protected)
+                 Cache.MarkDelete(I);
               break;
            }
                    
@@ -733,10 +755,16 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
                   ((Cache[End] & pkgDepCache::DepGNow) == 0 &&
                    End->Type != pkgCache::Dep::Conflicts))
               {
+                 // Try a little harder to fix protected packages..
                  if ((Flags[I->ID] & Protected) == Protected)
+                 {
+                    if (DoUpgrade(Pkg) == true)
+                       Scores[Pkg->ID] = Scores[I->ID];
                     continue;
-
-                 // See if a keep will do
+                 }
+                 
+                 /* See if a keep will do, unless the package is protected,
+                    then installing it will be necessary */    
                  Cache.MarkKeep(I);
                  if (Cache[I].InstBroken() == false)
                  {
@@ -754,7 +782,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
                           Scores[I->ID] = Scores[Pkg->ID];
                     }
                  }
-
+                                 
                  Change = true;
                  Done = true;
                  break;
@@ -834,8 +862,19 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
    delete [] PList;
    
    if (Cache.BrokenCount() != 0)
-      return _error->Error("Internal error, pkgProblemResolver::Resolve generated breaks.");
-
+   {
+      // See if this is the result of a hold
+      pkgCache::PkgIterator I = Cache.PkgBegin();
+      for (;I.end() != true; I++)
+      {
+        if (Cache[I].InstBroken() == false)
+           continue;
+        if ((Flags[I->ID] & Protected) != Protected)
+           return _error->Error("Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.");
+      }
+      return _error->Error("Unable to correct problems, you have held broken packages.");
+   }
+   
    return true;
 }
                                                                        /*}}}*/