]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/algorithms.cc
* apt-pkg/depcache.cc:
[apt.git] / apt-pkg / algorithms.cc
index c679e76f67ba0fbdf3c95965afb72954eb8207e7..ac9d3be0bea35a05c93d4545c1996c8c7a91f349 100644 (file)
 #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>
-#include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/version.h>
 #include <apt-pkg/sptr.h>
 
     
 #include <apti18n.h>
 #include <apt-pkg/version.h>
 #include <apt-pkg/sptr.h>
 
     
 #include <apti18n.h>
-    
+#include <sys/types.h>
 #include <iostream>
                                                                        /*}}}*/
 using namespace std;
 #include <iostream>
                                                                        /*}}}*/
 using namespace std;
@@ -223,6 +222,8 @@ void pkgSimulate::ShortBreaks()
    the necessary calculations to deal with the problems. */
 bool pkgApplyStatus(pkgDepCache &Cache)
 {
    the necessary calculations to deal with the problems. */
 bool pkgApplyStatus(pkgDepCache &Cache)
 {
+   pkgDepCache::ActionGroup group(Cache);
+
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
    {
       if (I->VersionList == 0)
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
    {
       if (I->VersionList == 0)
@@ -233,13 +234,13 @@ bool pkgApplyStatus(pkgDepCache &Cache)
          I->InstState == pkgCache::State::HoldReInstReq)
       {
         if (I->CurrentVer != 0 && I.CurrentVer().Downloadable() == true)
          I->InstState == pkgCache::State::HoldReInstReq)
       {
         if (I->CurrentVer != 0 && I.CurrentVer().Downloadable() == true)
-           Cache.MarkKeep(I);
+           Cache.MarkKeep(I, false, false);
         else
         {
            // Is this right? Will dpkg choke on an upgrade?
            if (Cache[I].CandidateVer != 0 &&
                 Cache[I].CandidateVerIter(Cache).Downloadable() == true)
         else
         {
            // Is this right? Will dpkg choke on an upgrade?
            if (Cache[I].CandidateVer != 0 &&
                 Cache[I].CandidateVerIter(Cache).Downloadable() == true)
-              Cache.MarkInstall(I);
+              Cache.MarkInstall(I, false, 0, false);
            else
               return _error->Error(_("The package %s needs to be reinstalled, "
                                    "but I can't find an archive for it."),I.Name());
            else
               return _error->Error(_("The package %s needs to be reinstalled, "
                                    "but I can't find an archive for it."),I.Name());
@@ -256,12 +257,12 @@ bool pkgApplyStatus(pkgDepCache &Cache)
         case pkgCache::State::HalfConfigured:
         if ((I->CurrentVer != 0 && I.CurrentVer().Downloadable() == true) ||
             I.State() != pkgCache::PkgIterator::NeedsUnpack)
         case pkgCache::State::HalfConfigured:
         if ((I->CurrentVer != 0 && I.CurrentVer().Downloadable() == true) ||
             I.State() != pkgCache::PkgIterator::NeedsUnpack)
-           Cache.MarkKeep(I);
+           Cache.MarkKeep(I, false, false);
         else
         {
            if (Cache[I].CandidateVer != 0 &&
                 Cache[I].CandidateVerIter(Cache).Downloadable() == true)
         else
         {
            if (Cache[I].CandidateVer != 0 &&
                 Cache[I].CandidateVerIter(Cache).Downloadable() == true)
-              Cache.MarkInstall(I);
+              Cache.MarkInstall(I, true, 0, false);
            else
               Cache.MarkDelete(I);
         }
            else
               Cache.MarkDelete(I);
         }
@@ -287,10 +288,12 @@ bool pkgApplyStatus(pkgDepCache &Cache)
    on the result. */
 bool pkgFixBroken(pkgDepCache &Cache)
 {
    on the result. */
 bool pkgFixBroken(pkgDepCache &Cache)
 {
+   pkgDepCache::ActionGroup group(Cache);
+
    // Auto upgrade all broken packages
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
       if (Cache[I].NowBroken() == true)
    // Auto upgrade all broken packages
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
       if (Cache[I].NowBroken() == true)
-        Cache.MarkInstall(I,true);
+        Cache.MarkInstall(I, true, 0, false);
    
    /* Fix packages that are in a NeedArchive state but don't have a
       downloadable install version */
    
    /* Fix packages that are in a NeedArchive state but don't have a
       downloadable install version */
@@ -303,7 +306,7 @@ bool pkgFixBroken(pkgDepCache &Cache)
       if (Cache[I].InstVerIter(Cache).Downloadable() == false)
         continue;
 
       if (Cache[I].InstVerIter(Cache).Downloadable() == false)
         continue;
 
-      Cache.MarkInstall(I,true);      
+      Cache.MarkInstall(I, true, 0, false);
    }
    
    pkgProblemResolver Fix(&Cache);
    }
    
    pkgProblemResolver Fix(&Cache);
@@ -320,23 +323,25 @@ bool pkgFixBroken(pkgDepCache &Cache)
  */
 bool pkgDistUpgrade(pkgDepCache &Cache)
 {
  */
 bool pkgDistUpgrade(pkgDepCache &Cache)
 {
+   pkgDepCache::ActionGroup group(Cache);
+
    /* Auto upgrade all installed packages, this provides the basis 
       for the installation */
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
       if (I->CurrentVer != 0)
    /* Auto upgrade all installed packages, this provides the basis 
       for the installation */
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
       if (I->CurrentVer != 0)
-        Cache.MarkInstall(I,true);
+        Cache.MarkInstall(I, true, 0, false);
 
    /* Now, auto upgrade all essential packages - this ensures that
       the essential packages are present and working */
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
       if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
 
    /* Now, auto upgrade all essential packages - this ensures that
       the essential packages are present and working */
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
       if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
-        Cache.MarkInstall(I,true);
+        Cache.MarkInstall(I, true, 0, false);
    
    /* We do it again over all previously installed packages to force 
       conflict resolution on them all. */
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
       if (I->CurrentVer != 0)
    
    /* We do it again over all previously installed packages to force 
       conflict resolution on them all. */
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
       if (I->CurrentVer != 0)
-        Cache.MarkInstall(I,false);
+        Cache.MarkInstall(I, false, 0, false);
 
    pkgProblemResolver Fix(&Cache);
 
 
    pkgProblemResolver Fix(&Cache);
 
@@ -348,7 +353,7 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
         if (I->SelectedState == pkgCache::State::Hold)
         {
            Fix.Protect(I);
         if (I->SelectedState == pkgCache::State::Hold)
         {
            Fix.Protect(I);
-           Cache.MarkKeep(I);
+           Cache.MarkKeep(I, false, false);
         }
       }
    }
         }
       }
    }
@@ -363,6 +368,8 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
    to install packages not marked for install */
 bool pkgAllUpgrade(pkgDepCache &Cache)
 {
    to install packages not marked for install */
 bool pkgAllUpgrade(pkgDepCache &Cache)
 {
+   pkgDepCache::ActionGroup group(Cache);
+
    pkgProblemResolver Fix(&Cache);
 
    if (Cache.BrokenCount() != 0)
    pkgProblemResolver Fix(&Cache);
 
    if (Cache.BrokenCount() != 0)
@@ -379,7 +386,7 @@ bool pkgAllUpgrade(pkgDepCache &Cache)
            continue;
       
       if (I->CurrentVer != 0 && Cache[I].InstallVer != 0)
            continue;
       
       if (I->CurrentVer != 0 && Cache[I].InstallVer != 0)
-        Cache.MarkInstall(I,false);
+        Cache.MarkInstall(I, false, 0, false);
    }
       
    return Fix.ResolveByKeep();
    }
       
    return Fix.ResolveByKeep();
@@ -392,6 +399,8 @@ bool pkgAllUpgrade(pkgDepCache &Cache)
    the package is restored. */
 bool pkgMinimizeUpgrade(pkgDepCache &Cache)
 {   
    the package is restored. */
 bool pkgMinimizeUpgrade(pkgDepCache &Cache)
 {   
+   pkgDepCache::ActionGroup group(Cache);
+
    if (Cache.BrokenCount() != 0)
       return false;
    
    if (Cache.BrokenCount() != 0)
       return false;
    
@@ -408,9 +417,9 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache)
            continue;
 
         // Keep it and see if that is OK
            continue;
 
         // Keep it and see if that is OK
-        Cache.MarkKeep(I);
+        Cache.MarkKeep(I, false, false);
         if (Cache.BrokenCount() != 0)
         if (Cache.BrokenCount() != 0)
-           Cache.MarkInstall(I,false);
+           Cache.MarkInstall(I, false, 0, false);
         else
         {
            // If keep didnt actually do anything then there was no change..
         else
         {
            // If keep didnt actually do anything then there was no change..
@@ -568,6 +577,8 @@ void pkgProblemResolver::MakeScores()
    installable */
 bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
 {
    installable */
 bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
 {
+   pkgDepCache::ActionGroup group(Cache);
+
    if ((Flags[Pkg->ID] & Upgradable) == 0 || Cache[Pkg].Upgradable() == false)
       return false;
    if ((Flags[Pkg->ID] & Protected) == Protected)
    if ((Flags[Pkg->ID] & Upgradable) == 0 || Cache[Pkg].Upgradable() == false)
       return false;
    if ((Flags[Pkg->ID] & Protected) == Protected)
@@ -576,7 +587,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
    Flags[Pkg->ID] &= ~Upgradable;
    
    bool WasKept = Cache[Pkg].Keep();
    Flags[Pkg->ID] &= ~Upgradable;
    
    bool WasKept = Cache[Pkg].Keep();
-   Cache.MarkInstall(Pkg,false);
+   Cache.MarkInstall(Pkg, false, 0, false);
 
    // This must be a virtual package or something like that.
    if (Cache[Pkg].InstVerIter(Cache).end() == true)
 
    // This must be a virtual package or something like that.
    if (Cache[Pkg].InstVerIter(Cache).end() == true)
@@ -661,7 +672,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
    if (Fail == true)
    {
       if (WasKept == true)
    if (Fail == true)
    {
       if (WasKept == true)
-        Cache.MarkKeep(Pkg);
+        Cache.MarkKeep(Pkg, false, false);
       else
         Cache.MarkDelete(Pkg);
       return false;
       else
         Cache.MarkDelete(Pkg);
       return false;
@@ -688,6 +699,8 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
    upgrade packages to advoid problems. */
 bool pkgProblemResolver::Resolve(bool BrokenFix)
 {
    upgrade packages to advoid problems. */
 bool pkgProblemResolver::Resolve(bool BrokenFix)
 {
+   pkgDepCache::ActionGroup group(Cache);
+
    unsigned long Size = Cache.Head().PackageCount;
 
    // Record which packages are marked for install
    unsigned long Size = Cache.Head().PackageCount;
 
    // Record which packages are marked for install
@@ -703,7 +716,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
         {
            if (Cache[I].InstBroken() == true && BrokenFix == true)
            {
         {
            if (Cache[I].InstBroken() == true && BrokenFix == true)
            {
-              Cache.MarkInstall(I,false);
+              Cache.MarkInstall(I, false, 0, false);
               if (Cache[I].Install() == true)
                  Again = true;
            }
               if (Cache[I].Install() == true)
                  Again = true;
            }
@@ -769,14 +782,14 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
            pkgCache::Version *OldVer = Cache[I].InstallVer;
            Flags[I->ID] &= ReInstateTried;
            
            pkgCache::Version *OldVer = Cache[I].InstallVer;
            Flags[I->ID] &= ReInstateTried;
            
-           Cache.MarkInstall(I,false);
+           Cache.MarkInstall(I, false, 0, false);
            if (Cache[I].InstBroken() == true || 
                OldBreaks < Cache.BrokenCount())
            {
               if (OldVer == 0)
                  Cache.MarkDelete(I);
               else
            if (Cache[I].InstBroken() == true || 
                OldBreaks < Cache.BrokenCount())
            {
               if (OldVer == 0)
                  Cache.MarkDelete(I);
               else
-                 Cache.MarkKeep(I);
+                 Cache.MarkKeep(I, false, false);
            }       
            else
               if (Debug == true)
            }       
            else
               if (Debug == true)
@@ -821,7 +834,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
                  {
                     if (Debug == true)
                        clog << "  Or group keep for " << I.Name() << endl;
                  {
                     if (Debug == true)
                        clog << "  Or group keep for " << I.Name() << endl;
-                    Cache.MarkKeep(I);
+                    Cache.MarkKeep(I, false, false);
                     Change = true;
                  }
               }
                     Change = true;
                  }
               }
@@ -871,7 +884,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
               }
               
               Change = true;
               }
               
               Change = true;
-              Cache.MarkKeep(I);                 
+              Cache.MarkKeep(I, false, false);
               break;
            }
            
               break;
            }
            
@@ -908,7 +921,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
                  /* See if a keep will do, unless the package is protected,
                     then installing it will be necessary */
                  bool Installed = Cache[I].Install();
                  /* See if a keep will do, unless the package is protected,
                     then installing it will be necessary */
                  bool Installed = Cache[I].Install();
-                 Cache.MarkKeep(I);
+                 Cache.MarkKeep(I, false, false);
                  if (Cache[I].InstBroken() == false)
                  {
                     // Unwind operation will be keep now
                  if (Cache[I].InstBroken() == false)
                  {
                     // Unwind operation will be keep now
@@ -917,7 +930,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
                     
                     // Restore
                     if (InOr == true && Installed == true)
                     
                     // Restore
                     if (InOr == true && Installed == true)
-                       Cache.MarkInstall(I,false);
+                       Cache.MarkInstall(I, false, 0, false);
                     
                     if (Debug == true)
                        clog << "  Holding Back " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl;
                     
                     if (Debug == true)
                        clog << "  Holding Back " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl;
@@ -989,7 +1002,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
                  
                  // Restore
                  if (InOr == true && Installed == true)
                  
                  // Restore
                  if (InOr == true && Installed == true)
-                    Cache.MarkInstall(I,false);
+                    Cache.MarkInstall(I, false, 0, false);
                  
                  if (Debug == true)
                     clog << "  Holding Back " << I.Name() << " because I can't find " << Start.TargetPkg().Name() << endl;
                  
                  if (Debug == true)
                     clog << "  Holding Back " << I.Name() << " because I can't find " << Start.TargetPkg().Name() << endl;
@@ -1034,7 +1047,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
               {
                  if (Debug == true)
                     clog << "  Fixing " << I.Name() << " via keep of " << J->Pkg.Name() << endl;
               {
                  if (Debug == true)
                     clog << "  Fixing " << I.Name() << " via keep of " << J->Pkg.Name() << endl;
-                 Cache.MarkKeep(J->Pkg);
+                 Cache.MarkKeep(J->Pkg, false, false);
               }
 
               if (Counter > 1)
               }
 
               if (Counter > 1)
@@ -1088,6 +1101,8 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
    system was non-broken previously. */
 bool pkgProblemResolver::ResolveByKeep()
 {
    system was non-broken previously. */
 bool pkgProblemResolver::ResolveByKeep()
 {
+   pkgDepCache::ActionGroup group(Cache);
+
    unsigned long Size = Cache.Head().PackageCount;
 
    if (Debug == true)      
    unsigned long Size = Cache.Head().PackageCount;
 
    if (Debug == true)      
@@ -1121,7 +1136,7 @@ bool pkgProblemResolver::ResolveByKeep()
       {
         if (Debug == true)
            clog << "Keeping package " << I.Name() << endl;
       {
         if (Debug == true)
            clog << "Keeping package " << I.Name() << endl;
-        Cache.MarkKeep(I);
+        Cache.MarkKeep(I, false, false);
         if (Cache[I].InstBroken() == false)
         {
            K = PList - 1;
         if (Cache[I].InstBroken() == false)
         {
            K = PList - 1;
@@ -1169,7 +1184,7 @@ bool pkgProblemResolver::ResolveByKeep()
               {
                  if (Debug == true)
                     clog << "  Keeping Package " << Pkg.Name() << " due to dep" << endl;
               {
                  if (Debug == true)
                     clog << "  Keeping Package " << Pkg.Name() << " due to dep" << endl;
-                 Cache.MarkKeep(Pkg);
+                 Cache.MarkKeep(Pkg, false, false);
               }
               
               if (Cache[I].InstBroken() == false)
               }
               
               if (Cache[I].InstBroken() == false)
@@ -1206,6 +1221,8 @@ bool pkgProblemResolver::ResolveByKeep()
 /* This is used to make sure protected packages are installed */
 void pkgProblemResolver::InstallProtect()
 {
 /* This is used to make sure protected packages are installed */
 void pkgProblemResolver::InstallProtect()
 {
+   pkgDepCache::ActionGroup group(Cache);
+
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
    {
       if ((Flags[I->ID] & Protected) == Protected)
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
    {
       if ((Flags[I->ID] & Protected) == Protected)
@@ -1213,7 +1230,7 @@ void pkgProblemResolver::InstallProtect()
         if ((Flags[I->ID] & ToRemove) == ToRemove)
            Cache.MarkDelete(I);
         else
         if ((Flags[I->ID] & ToRemove) == ToRemove)
            Cache.MarkDelete(I);
         else
-           Cache.MarkInstall(I,false);
+           Cache.MarkInstall(I, false, 0, false);
       }
    }   
 }
       }
    }   
 }
@@ -1250,187 +1267,3 @@ void pkgPrioSortList(pkgCache &Cache,pkgCache::Version **List)
 }
                                                                        /*}}}*/
 
 }
                                                                        /*}}}*/
 
-
-// mark a single package in Mark-and-Sweep
-void pkgMarkPackage(pkgDepCache &Cache,
-                   const pkgCache::PkgIterator &pkg,
-                   const pkgCache::VerIterator &ver,
-                   bool follow_recommends,
-                   bool follow_suggests)
-{
-   pkgDepCache::StateCache &state=Cache[pkg];
-   pkgCache::VerIterator candver=state.CandidateVerIter(Cache);
-   pkgCache::VerIterator instver=state.InstVerIter(Cache);
-
-#if 0
-   // If a package was garbage-collected but is now being marked, we
-   // should re-select it 
-   // For cases when a pkg is set to upgrade and this trigger the
-   // removal of a no-longer used dependency.  if the pkg is set to
-   // keep again later it will result in broken deps
-   if(state.Delete() && state.RemoveReason=pkgDepCache::Unused) 
-   {
-      if(ver==candver)
-        mark_install(pkg, false, false, NULL);
-      else if(ver==pkg.CurrentVer())
-        MarkKeep(pkg);
-      
-      instver=state.InstVerIter(*this);
-   }
-#endif
-
-   // Ignore versions other than the InstVer, and ignore packages
-   // that are already going to be removed or just left uninstalled.
-   if(!(ver==instver && !instver.end()))
-      return;
-
-   // if we are marked already we are done
-   if(state.Marked)
-      return;
-
-   //std::cout << "Setting Marked for: " << pkg.Name() << std::endl;
-   state.Marked=true;
-
-   if(!ver.end())
-   {
-     for(pkgCache::DepIterator d=ver.DependsList(); !d.end(); ++d)
-     {
-       if(d->Type==pkgCache::Dep::Depends ||
-          d->Type==pkgCache::Dep::PreDepends ||
-          (follow_recommends &&
-           d->Type==pkgCache::Dep::Recommends) ||
-          (follow_suggests &&
-           d->Type==pkgCache::Dep::Suggests))
-        {
-          // Try all versions of this package.
-          for(pkgCache::VerIterator V=d.TargetPkg().VersionList(); 
-              !V.end(); ++V)
-          {
-             if(_system->VS->CheckDep(V.VerStr(),d->CompareOp, d.TargetVer()))
-             {
-                pkgMarkPackage(Cache, V.ParentPkg(), V, 
-                               follow_recommends, follow_suggests);
-             }
-          }
-          // Now try virtual packages
-          for(pkgCache::PrvIterator prv=d.TargetPkg().ProvidesList(); 
-              !prv.end(); ++prv)
-          {
-             if(_system->VS->CheckDep(prv.ProvideVersion(), d->CompareOp, 
-                                      d.TargetVer()))
-             {
-                pkgMarkPackage(Cache, prv.OwnerPkg(), prv.OwnerVer(),
-                               follow_recommends, follow_suggests);
-             }
-          }
-       }
-     }
-   }
-}
-
-
-bool pkgMarkUsed(pkgDepCache &Cache)
-{
-   bool follow_recommends;
-   bool follow_suggests;
-
-   // init the states
-   for(pkgCache::PkgIterator p=Cache.PkgBegin(); !p.end(); ++p)
-   {
-      Cache[p].Marked=false;
-      Cache[p].Garbage=false;
-   }
-
-   // init vars
-   follow_recommends=_config->FindB("APT::AutoRemove::RecommendsImportant",false);
-   follow_suggests=_config->FindB("APT::AutoRemove::SuggestsImportend", false);
-
-
-   // do the mark part
-   for(pkgCache::PkgIterator p=Cache.PkgBegin(); !p.end(); ++p)
-   {
-      if(!(Cache[p].Flags & pkgCache::Flag::Auto) ||
-        (p->Flags & pkgCache::Flag::Essential))
-      {
-        if(Cache[p].Keep() && !p.CurrentVer().end())
-           pkgMarkPackage(Cache, p, p.CurrentVer(),
-                          follow_recommends, follow_suggests);
-        else if(Cache[p].Install())
-           pkgMarkPackage(Cache, p, Cache[p].InstVerIter(Cache),
-                          follow_recommends, follow_suggests);
-      }
-   }
-
-
-   // do the sweep
-   for(pkgCache::PkgIterator p=Cache.PkgBegin(); !p.end(); ++p)
-  {
-     pkgDepCache::StateCache &state=Cache[p];
-
-     if(!state.Marked)
-     {
-       // mark installed but not yet marked stuff as garbage
-       if(p->CurrentVer != 0) {
-          state.Garbage=true;
-          std::cout << "Garbage: " << p.Name() << std::endl;
-       }
-
-#if 0   // mvo: the below bits still needs to be ported
-
-       // Be sure not to re-delete already deleted packages.
-       if(delete_unused && (!p.CurrentVer().end() || state.Install()) &&
-          !state.Delete())
-       {
-             bool do_delete=true;
-
-             // If the package is being upgraded, check if we're
-             // losing a versioned dep.  If the dependency matches
-             // the previous version and not the new version, keep
-             // the package back instead of removing it.
-             if(!p.CurrentVer().end() && state.Install())
-               {
-                 const char *vs=p.CurrentVer().VerStr();
-
-                 // Check direct revdeps only.  THIS ASSUMES NO
-                 // VERSIONED PROVIDES, but Debian probably won't
-                 // have them for ages if ever.
-                 for(pkgCache::DepIterator revdep=p.RevDependsList();
-                     !revdep.end(); ++revdep)
-                   {
-                     pkgCache::PkgIterator depender=revdep.ParentPkg();
-                     // Find which version of the depending package
-                     // will be installed.
-                     pkgCache::VerIterator instver=(*this)[depender].InstVerIter(*this);
-
-                     // Only pay attention to strong positive
-                     // dependencies whose parents will be installed.
-                     if(revdep.ParentVer()==instver &&
-                        (revdep->Type==pkgCache::Dep::Depends ||
-                         revdep->Type==pkgCache::Dep::PreDepends ||
-                         (revdep->Type==pkgCache::Dep::Recommends &&
-                          follow_recommends)))
-                       {
-                         // If the previous version matched, cancel the
-                         // deletion.  (note that I assume that the new
-                         // version does NOT match; otherwise it would
-                         // not be unused!)
-                         if(_system->VS->CheckDep(vs,
-                                                  revdep->CompareOp,
-                                                  revdep.TargetVer()))
-                           {
-                             mark_keep(p, false, false, undo);
-                             do_delete=false;
-                             break;
-                           }
-                       }
-                   }
-               }
-
-             if(do_delete)
-               mark_delete(p, false, true, undo);
-           }
-#endif
-     }
-  }
-   return true;
-}