]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/depcache.cc
Fixed a problem where the loop flag would be removed prematurely.
[apt.git] / apt-pkg / depcache.cc
index 18b6d160a133865cb7e7f27330028e291fccf733..e9fa097aaf11e8aa32fdfc274059daf46c9a9eea 100644 (file)
@@ -1078,61 +1078,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
       */
       if (IsImportantDep(Start) == false)
         continue;
-      
-      /* Check if any ImportantDep() (but not Critical) were added
-       * since we installed the package.  Also check for deps that
-       * were satisfied in the past: for instance, if a version
-       * restriction in a Recommends was tightened, upgrading the
-       * package should follow that Recommends rather than causing the
-       * dependency to be removed. (bug #470115)
-       */
-      bool isNewImportantDep = false;
-      bool isPreviouslySatisfiedImportantDep = false;
-      if(!ForceImportantDeps && !Start.IsCritical())
-      {
-        bool found=false;
-        VerIterator instVer = Pkg.CurrentVer();
-        if(!instVer.end())
-        {
-          for (DepIterator D = instVer.DependsList(); D.end() != true; D++)
-            {
-              //FIXME: deal better with or-groups(?)
-              if(IsImportantDep(D) && !D.IsCritical() &&
-                 Start.TargetPkg() == D.TargetPkg())
-                {
-                  if(!isPreviouslySatisfiedImportantDep)
-                    {
-                      DepIterator D2 = D;
-                      while((D2->CompareOp & Dep::Or) != 0)
-                        ++D2;
-
-                      isPreviouslySatisfiedImportantDep =
-                        (((*this)[D2] & DepGNow) != 0);
-                    }
-
-                  found=true;
-                }
-            }
-           // this is a new dep if it was not found to be already
-           // a important dep of the installed pacakge
-           isNewImportantDep = !found;
-        }
-      }
-      if(isNewImportantDep)
-        if(DebugAutoInstall == true)
-           std::clog << OutputInDepth(Depth) << "new important dependency: "
-                     << Start.TargetPkg().Name() << std::endl;
-      if(isPreviouslySatisfiedImportantDep)
-       if(DebugAutoInstall == true)
-         std::clog << OutputInDepth(Depth) << "previously satisfied important dependency on "
-                   << Start.TargetPkg().Name() << std::endl;
-
-      // skip important deps if the package is already installed
-      if (Pkg->CurrentVer != 0 && Start.IsCritical() == false 
-         && !isNewImportantDep && !isPreviouslySatisfiedImportantDep
-         && !ForceImportantDeps)
-        continue;
-      
+
       /* If we are in an or group locate the first or that can 
          succeed. We have already cached this.. */
       for (; Ors > 1 && (DepState[Start->ID] & DepCVer) != DepCVer; --Ors)
@@ -1148,6 +1094,57 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
         return;
       }
 
+      /* Check if any ImportantDep() (but not Critical) were added
+       * since we installed the package.  Also check for deps that
+       * were satisfied in the past: for instance, if a version
+       * restriction in a Recommends was tightened, upgrading the
+       * package should follow that Recommends rather than causing the
+       * dependency to be removed. (bug #470115)
+       */
+      if (Pkg->CurrentVer != 0 && ForceImportantDeps == false && Start.IsCritical() == false)
+      {
+        bool isNewImportantDep = true;
+        bool isPreviouslySatisfiedImportantDep = false;
+        for (DepIterator D = Pkg.CurrentVer().DependsList(); D.end() != true; ++D)
+        {
+           //FIXME: Should we handle or-group better here?
+           // We do not check if the package we look for is part of the same or-group
+           // we might find while searching, but could that really be a problem?
+           if (D.IsCritical() == true || IsImportantDep(D) == false ||
+               Start.TargetPkg() != D.TargetPkg())
+              continue;
+
+           isNewImportantDep = false;
+
+           while ((D->CompareOp & Dep::Or) != 0)
+              ++D;
+
+           isPreviouslySatisfiedImportantDep = (((*this)[D] & DepGNow) != 0);
+           if (isPreviouslySatisfiedImportantDep == true)
+              break;
+        }
+
+        if(isNewImportantDep == true)
+        {
+           if (DebugAutoInstall == true)
+              std::clog << OutputInDepth(Depth) << "new important dependency: "
+                        << Start.TargetPkg().FullName() << std::endl;
+        }
+        else if(isPreviouslySatisfiedImportantDep == true)
+        {
+           if (DebugAutoInstall == true)
+              std::clog << OutputInDepth(Depth) << "previously satisfied important dependency on "
+                        << Start.TargetPkg().FullName() << std::endl;
+        }
+        else
+        {
+           if (DebugAutoInstall == true)
+              std::clog << OutputInDepth(Depth) << "ignore old unsatisfied important dependency on "
+                        << Start.TargetPkg().FullName() << std::endl;
+           continue;
+        }
+      }
+
       /* This bit is for processing the possibilty of an install/upgrade
          fixing the problem */
       SPtrArray<Version *> List = Start.AllTargets();