]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/depcache.cc
More cache usage counters
[apt.git] / apt-pkg / depcache.cc
index db1cdad626791a7dd64c4ff69a24736f287f8087..eb9d5a35be97b1edb9dd412fa19ba5fd3a2a2bec 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: depcache.cc,v 1.5 1998/11/13 23:20:06 jgg Exp $
+// $Id: depcache.cc,v 1.11 1998/12/10 04:22:45 jgg Exp $
 /* ######################################################################
 
    Dependency Cache - Caches Dependency information.
@@ -25,6 +25,12 @@ pkgDepCache::pkgDepCache(MMap &Map,OpProgress &Prog) :
 {
    if (_error->PendingError() == false)
       Init(&Prog);
+}
+pkgDepCache::pkgDepCache(MMap &Map) :
+             pkgCache(Map), PkgState(0), DepState(0)
+{
+   if (_error->PendingError() == false)
+      Init(0);
 }
                                                                        /*}}}*/
 // DepCache::~pkgDepCache - Destructor                                 /*{{{*/
@@ -51,7 +57,7 @@ bool pkgDepCache::Init(OpProgress *Prog)
    if (Prog != 0)
    {
       Prog->OverallProgress(0,2*Head().PackageCount,Head().PackageCount,
-                           "Building Dependancy Tree");
+                           "Building Dependency Tree");
       Prog->SubProgress(Head().PackageCount,"Candidate Versions");
    }
    
@@ -80,7 +86,7 @@ bool pkgDepCache::Init(OpProgress *Prog)
       
       Prog->OverallProgress(Head().PackageCount,2*Head().PackageCount,
                            Head().PackageCount,
-                           "Building Dependancy Tree");
+                           "Building Dependency Tree");
       Prog->SubProgress(Head().PackageCount,"Dependency Generation");
    }
    
@@ -208,11 +214,18 @@ void pkgDepCache::AddSizes(const PkgIterator &Pkg,long Mult)
 {
    StateCache &P = PkgState[Pkg->ID];
    
+   if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure)
+   {
+      iUsrSize += Mult*P.InstVerIter(*this)->InstalledSize;
+      return;
+   }
+   
    // Compute the size data
    if (P.NewInstall() == true)
    {
       iUsrSize += Mult*P.InstVerIter(*this)->InstalledSize;
       iDownloadSize += Mult*P.InstVerIter(*this)->Size;
+      return;
    }
    
    // Upgrading
@@ -222,11 +235,23 @@ void pkgDepCache::AddSizes(const PkgIterator &Pkg,long Mult)
       iUsrSize += Mult*((signed)P.InstVerIter(*this)->InstalledSize - 
                        (signed)Pkg.CurrentVer()->InstalledSize);
       iDownloadSize += Mult*P.InstVerIter(*this)->Size;
+      return;
+   }
+   
+   // Reinstall
+   if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack &&
+       P.Delete() == false)
+   {
+      iDownloadSize += Mult*P.InstVerIter(*this)->Size;
+      return;
    }
    
    // Removing
    if (Pkg->CurrentVer != 0 && P.InstallVer == 0)
+   {
       iUsrSize -= Mult*Pkg.CurrentVer()->InstalledSize;
+      return;
+   }   
 }
                                                                        /*}}}*/
 // DepCache::AddStates - Add the package to the state counter          /*{{{*/
@@ -293,6 +318,7 @@ void pkgDepCache::BuildGroupOrs(VerIterator const &V)
         State = ~State;
       
       // Add to the group if we are within an or..
+      State &= 0x7;
       Group |= State;
       State |= Group << 3;
       if ((D->CompareOp & Dep::Or) != Dep::Or)
@@ -562,7 +588,10 @@ void pkgDepCache::MarkDelete(PkgIterator const &Pkg)
    RemoveSizes(Pkg);
    RemoveStates(Pkg);
    
-   P.Mode = ModeDelete;
+   if (Pkg->CurrentVer == 0)
+      P.Mode = ModeKeep;
+   else
+      P.Mode = ModeDelete;
    P.InstallVer = 0;
    P.Flags &= Flag::Auto;