Purge support
[ntk/apt.git] / apt-pkg / packagemanager.cc
index 8556687..126caef 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: packagemanager.cc,v 1.15 1999/07/03 03:10:35 jgg Exp $
+// $Id: packagemanager.cc,v 1.18 1999/07/10 04:58:42 jgg Exp $
 /* ######################################################################
 
    Package Manager - Abstacts the package manager
@@ -89,25 +89,14 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
 bool pkgPackageManager::FixMissing()
 {
    pkgProblemResolver Resolve(Cache);
-
+   List->SetFileList(FileNames);
+   
    bool Bad = false;
    for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
    {
-      // These don't need files
-      if (Cache[I].Keep() == true)
-        continue;
-      if (Cache[I].Delete() == true)
-        continue;
-      
-      // We have a filename
-      if (FileNames[I->ID].empty() == false)
+      if (List->IsMissing(I) == false)
         continue;
-      
-      // Skip Packages that need configure only.
-      if (I.State() == pkgCache::PkgIterator::NeedsConfigure && 
-         Cache[I].Keep() == true)
-        continue;
-      
+   
       // Okay, this file is missing and we need it. Mark it for keep 
       Bad = true;
       Cache.MarkKeep(I);
@@ -163,7 +152,9 @@ bool pkgPackageManager::CreateOrderList()
       // Not interesting
       if ((Cache[I].Keep() == true || 
          Cache[I].InstVerIter(Cache) == I.CurrentVer()) && 
-         I.State() == pkgCache::PkgIterator::NeedsNothing)
+         I.State() == pkgCache::PkgIterator::NeedsNothing &&
+         (I.Purge() != false || Cache[I].Mode != pkgDepCache::ModeDelete ||
+          (Cache[I].iFlags & pkgDepCache::Purge) != pkgDepCache::Purge))
         continue;
       
       // Append it to the list
@@ -386,7 +377,7 @@ bool pkgPackageManager::SmartRemove(PkgIterator Pkg)
       return true;
 
    List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States);
-   return Remove(Pkg);
+   return Remove(Pkg,(Cache[Pkg].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge);
 }
                                                                        /*}}}*/
 // PM::SmartUnPack - Install helper                                    /*{{{*/
@@ -526,7 +517,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
         continue;
       }
       
-      if (Cache[Pkg].Delete() == false && FileNames[Pkg->ID].empty() == true)
+      if (List->IsMissing(Pkg) == true)
       {
         if (Debug == true)
            clog << "Sequence completed at" << Pkg.Name() << endl;