]> git.saurik.com Git - apt.git/commitdiff
cherry pick max-loop count patch
authorMichael Vogt <michael.vogt@ubuntu.com>
Fri, 20 Apr 2012 07:50:23 +0000 (09:50 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Fri, 20 Apr 2012 07:50:23 +0000 (09:50 +0200)
apt-pkg/packagemanager.cc
debian/changelog

index 9175cc3add5a613a5dd6509f5df325a287fe34eb..2a71d878ea3999414402d6ca935b3b0a28207ad3 100644 (file)
@@ -338,7 +338,10 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
       however if there is a loop (A depends on B, B depends on A) this will not 
       be the case, so check for dependencies before configuring. */
    bool Bad = false, Changed = false;
-   do {
+   const unsigned int max_loops = _config->FindI("APT::pkgPackageManager::MaxLoopCount", 100);
+   unsigned int i=0;
+   do
+   {
       Changed = false;
       for (DepIterator D = instVer.DependsList(); D.end() == false; )
       {
@@ -461,6 +464,8 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth)
         if (Bad == true && Changed == false && Debug == true)
            std::clog << OutputInDepth(Depth) << "Could not satisfy " << Start << std::endl;
       }
+      if (i++ > max_loops)
+         return _error->Error("Internal error: MaxLoopCount reached in SmartUnPack for %s, aborting", Pkg.FullName().c_str());
    } while (Changed == true);
    
    if (Bad) {
@@ -595,7 +600,10 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
       This will be either dealt with if the package is configured as a dependency of Pkg (if and when Pkg is configured),
       or by the ConfigureAll call at the end of the for loop in OrderInstall. */
    bool Changed = false;
-   do {
+   const unsigned int max_loops = _config->FindI("APT::pkgPackageManager::MaxLoopCount", 100);
+   unsigned int i=0;
+   do 
+   {
       Changed = false;
       for (DepIterator D = instVer.DependsList(); D.end() == false; )
       {
@@ -820,6 +828,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
            }
         }
       }
+      if (i++ > max_loops)
+         return _error->Error("Internal error: MaxLoopCount reached in SmartConfigure for %s, aborting", Pkg.FullName().c_str());
    } while (Changed == true);
    
    // Check for reverse conflicts.
index 6bb514f8ae769c0565cdc89f6eedeb53ad155beb..d637beb5989740e9dfbc841b7bd295dc80836415 100644 (file)
@@ -6,6 +6,12 @@ apt (0.8.16~exp12ubuntu10) UNRELEASEDprecise-proposed; urgency=low
       other than the first specified is already installed, apt-get enters an
       infinite loop (LP: #985852)
 
+  [ Michael Vogt ]
+  * apt-pkg/packagemanager.cc:
+    - add APT::pkgPackageManager::MaxLoopCount to ensure that the
+      ordering code does not get into a endless loop when it flip-flops
+      between two states
+
  -- Malcolm Scott <launchpad@malc.org.uk>  Thu, 19 Apr 2012 19:52:56 +0100
 
 apt (0.8.16~exp12ubuntu9) precise-proposed; urgency=low