]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/orderlist.cc
* ftparchive/multicompress.cc, apt-inst/deb/debfile.cc:
[apt.git] / apt-pkg / orderlist.cc
index 55f9cb9cce8bf9ed2819ceeda3a8e45446bd3f3e..a53854a2687124eff9a10791e0c65a7c6923471c 100644 (file)
@@ -886,13 +886,16 @@ bool pkgOrderList::DepRemove(DepIterator D)
            continue;
 
         /* We wish to see if the dep on the parent package is okay
            continue;
 
         /* We wish to see if the dep on the parent package is okay
-           in the removed (install) state of the target pkg. */         
+           in the removed (install) state of the target pkg. */
+        bool tryFixDeps = false;
         if (CheckDep(D) == true)
         {
            // We want to catch loops with the code below.
            if (IsFlag(D.ParentPkg(),AddPending) == false)
               continue;
         }
         if (CheckDep(D) == true)
         {
            // We want to catch loops with the code below.
            if (IsFlag(D.ParentPkg(),AddPending) == false)
               continue;
         }
+        else
+           tryFixDeps = true;
 
         // This is the loop detection
         if (IsFlag(D.ParentPkg(),Added) == true || 
 
         // This is the loop detection
         if (IsFlag(D.ParentPkg(),Added) == true || 
@@ -903,6 +906,100 @@ bool pkgOrderList::DepRemove(DepIterator D)
            continue;
         }
 
            continue;
         }
 
+        if (tryFixDeps == true)
+        {
+           for (pkgCache::DepIterator F = D.ParentPkg().CurrentVer().DependsList();
+                F.end() == false; ++F)
+           {
+              if (F->Type != pkgCache::Dep::Depends && F->Type != pkgCache::Dep::PreDepends)
+                 continue;
+              // Check the Providers
+              if (F.TargetPkg()->ProvidesList != 0)
+              {
+                 pkgCache::PrvIterator Prov = F.TargetPkg().ProvidesList();
+                 for (; Prov.end() == false; ++Prov)
+                 {
+                    pkgCache::PkgIterator const P = Prov.OwnerPkg();
+                    if (IsFlag(P, InList) == true &&
+                        IsFlag(P, AddPending) == true &&
+                        IsFlag(P, Added) == false &&
+                        Cache[P].InstallVer == 0)
+                       break;
+                 }
+                 if (Prov.end() == false)
+                    for (pkgCache::PrvIterator Prv = F.TargetPkg().ProvidesList();
+                         Prv.end() == false; ++Prv)
+                    {
+                       pkgCache::PkgIterator const P = Prv.OwnerPkg();
+                       if (IsFlag(P, InList) == true &&
+                           IsFlag(P, AddPending) == false &&
+                           Cache[P].InstallVer != 0 &&
+                           VisitNode(P) == true)
+                       {
+                          Flag(P, Immediate);
+                          tryFixDeps = false;
+                          break;
+                       }
+                    }
+                 if (tryFixDeps == false)
+                    break;
+              }
+
+              // Check for Or groups
+              if ((F->CompareOp & pkgCache::Dep::Or) != pkgCache::Dep::Or)
+                 continue;
+              // Lets see if the package is part of the Or group
+              pkgCache::DepIterator S = F;
+              for (; S.end() == false; ++S)
+              {
+                 if (S.TargetPkg() == D.TargetPkg())
+                    break;
+                 if ((S->CompareOp & pkgCache::Dep::Or) != pkgCache::Dep::Or ||
+                     CheckDep(S)) // Or group is satisfied by another package
+                    for (;S.end() == false; ++S);
+              }
+              if (S.end() == true)
+                 continue;
+              // skip to the end of the or group
+              for (;S.end() == false && (S->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; ++S);
+              ++S;
+              // The soon to be removed is part of the Or group
+              // start again in the or group and find something which will serve as replacement
+              for (; F.end() == false && F != S; ++F)
+              {
+                 if (IsFlag(F.TargetPkg(), InList) == true &&
+                     IsFlag(F.TargetPkg(), AddPending) == false &&
+                     Cache[F.TargetPkg()].InstallVer != 0 &&
+                     VisitNode(F.TargetPkg()) == true)
+                 {
+                    Flag(F.TargetPkg(), Immediate);
+                    tryFixDeps = false;
+                    break;
+                 }
+                 else if (F.TargetPkg()->ProvidesList != 0)
+                 {
+                    pkgCache::PrvIterator Prv = F.TargetPkg().ProvidesList();
+                    for (; Prv.end() == false; ++Prv)
+                    {
+                       if (IsFlag(Prv.OwnerPkg(), InList) == true &&
+                           IsFlag(Prv.OwnerPkg(), AddPending) == false &&
+                           Cache[Prv.OwnerPkg()].InstallVer != 0 &&
+                           VisitNode(Prv.OwnerPkg()) == true)
+                       {
+                          Flag(Prv.OwnerPkg(), Immediate);
+                          tryFixDeps = false;
+                          break;
+                       }
+                    }
+                    if (Prv.end() == false)
+                       break;
+                 }
+              }
+              if (tryFixDeps == false)
+                 break;
+           }
+        }
+
         // Skip over missing files
         if (IsMissing(D.ParentPkg()) == true)
            continue;
         // Skip over missing files
         if (IsMissing(D.ParentPkg()) == true)
            continue;