Просмотр исходного кода

Sync
Author: jgg
Date: 1998-09-07 05:28:32 GMT
Sync

Arch Librarian лет назад: 22
Родитель
Сommit
a246f2dc8c
4 измененных файлов с 49 добавлено и 33 удалено
  1. 4 2
      apt-pkg/contrib/progress.cc
  2. 35 22
      apt-pkg/depcache.cc
  3. 5 7
      apt-pkg/depcache.h
  4. 5 2
      apt-pkg/pkgcachegen.cc

+ 4 - 2
apt-pkg/contrib/progress.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: progress.cc,v 1.6 1998/08/26 04:52:28 jgg Exp $
+// $Id: progress.cc,v 1.7 1998/09/07 05:28:38 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    OpProgress - Operation Progress
    OpProgress - Operation Progress
@@ -27,7 +27,9 @@ OpProgress::OpProgress() : Current(0), Total(0), Size(0), SubTotal(1),
 									/*}}}*/
 									/*}}}*/
 // OpProgress::Progress - Sub progress with no state change		/*{{{*/
 // OpProgress::Progress - Sub progress with no state change		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
-/* This assumes that Size is the same as the current sub size */
+/* Current is the Base Overall progress in units of Total. Cur is the sub
+   progress in units of SubTotal. Size is a scaling factor that says what
+   percent of Total SubTotal is. */
 void OpProgress::Progress(unsigned long Cur)
 void OpProgress::Progress(unsigned long Cur)
 {
 {
    Percent = (Current + Cur/((float)SubTotal)*Size)*100.0/Total;
    Percent = (Current + Cur/((float)SubTotal)*Size)*100.0/Total;

+ 35 - 22
apt-pkg/depcache.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: depcache.cc,v 1.2 1998/07/12 23:58:24 jgg Exp $
+// $Id: depcache.cc,v 1.3 1998/09/07 05:28:32 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    Dependency Cache - Caches Dependency information.
    Dependency Cache - Caches Dependency information.
@@ -20,11 +20,11 @@
 // DepCache::pkgDepCache - Constructors					/*{{{*/
 // DepCache::pkgDepCache - Constructors					/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */
-pkgDepCache::pkgDepCache(MMap &Map) :
-             pkgCache(Map), PkgState(0), DepState(0) 
+pkgDepCache::pkgDepCache(MMap &Map,OpProgress &Prog) :
+             pkgCache(Map), PkgState(0), DepState(0)
 {
 {
    if (_error->PendingError() == false)
    if (_error->PendingError() == false)
-      Init();
+      Init(&Prog);
 }
 }
 									/*}}}*/
 									/*}}}*/
 // DepCache::~pkgDepCache - Destructor					/*{{{*/
 // DepCache::~pkgDepCache - Destructor					/*{{{*/
@@ -36,23 +36,10 @@ pkgDepCache::~pkgDepCache()
    delete [] DepState;
    delete [] DepState;
 }
 }
 									/*}}}*/
 									/*}}}*/
-// DepCache::ReMap - Regenerate the extra data for the new cache	/*{{{*/
-// ---------------------------------------------------------------------
-/* pkgCache's constructors call this function, but because the object is not
-   fully constructed at that point it will not result in this function being
-   called but pkgCache::ReMap will be instead.*/
-bool pkgDepCache::ReMap()
-{
-   if (pkgCache::ReMap() == false)
-      return false;
-   
-   return Init();
-}
-									/*}}}*/
 // DepCache::Init - Generate the initial extra structures.		/*{{{*/
 // DepCache::Init - Generate the initial extra structures.		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This allocats the extension buffers and initializes them. */
 /* This allocats the extension buffers and initializes them. */
-bool pkgDepCache::Init()
+bool pkgDepCache::Init(OpProgress *Prog)
 {
 {
    delete [] PkgState;
    delete [] PkgState;
    delete [] DepState;
    delete [] DepState;
@@ -61,10 +48,21 @@ bool pkgDepCache::Init()
    memset(PkgState,0,sizeof(*PkgState)*Head().PackageCount);
    memset(PkgState,0,sizeof(*PkgState)*Head().PackageCount);
    memset(DepState,0,sizeof(*DepState)*Head().DependsCount); 
    memset(DepState,0,sizeof(*DepState)*Head().DependsCount); 
    
    
+   if (Prog != 0)
+   {
+      Prog->OverallProgress(0,2*Head().PackageCount,Head().PackageCount,
+			    "Building Dependancy Tree");
+      Prog->SubProgress(Head().PackageCount,"Candidate Versions");
+   }
+   
    /* Set the current state of everything. In this state all of the
    /* Set the current state of everything. In this state all of the
       packages are kept exactly as is. See AllUpgrade */
       packages are kept exactly as is. See AllUpgrade */
-   for (PkgIterator I = PkgBegin(); I.end() != true; I++)
+   int Done = 0;
+   for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++)
    {
    {
+      if (Prog != 0)
+	 Prog->Progress(Done);
+      
       // Find the proper cache slot
       // Find the proper cache slot
       StateCache &State = PkgState[I->ID];
       StateCache &State = PkgState[I->ID];
       State.iFlags = 0;
       State.iFlags = 0;
@@ -77,7 +75,16 @@ bool pkgDepCache::Init()
       State.Update(I,*this);
       State.Update(I,*this);
    }   
    }   
    
    
-   Update();
+   if (Prog != 0)
+   {
+      
+      Prog->OverallProgress(Head().PackageCount,2*Head().PackageCount,
+			    Head().PackageCount,
+			    "Building Dependancy Tree");
+      Prog->SubProgress(Head().PackageCount,"Dependency Generation");
+   }
+   
+   Update(Prog);
    
    
    return true;
    return true;
 } 
 } 
@@ -392,7 +399,7 @@ void pkgDepCache::UpdateVerState(PkgIterator Pkg)
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* This will figure out the state of all the packages and all the 
 /* This will figure out the state of all the packages and all the 
    dependencies based on the current policy. */
    dependencies based on the current policy. */
-void pkgDepCache::Update()
+void pkgDepCache::Update(OpProgress *Prog)
 {   
 {   
    iUsrSize = 0;
    iUsrSize = 0;
    iDownloadSize = 0;
    iDownloadSize = 0;
@@ -403,8 +410,11 @@ void pkgDepCache::Update()
    iBadCount = 0;
    iBadCount = 0;
    
    
    // Perform the depends pass
    // Perform the depends pass
-   for (PkgIterator I = PkgBegin(); I.end() != true; I++)
+   int Done = 0;
+   for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++)
    {
    {
+      if (Prog != 0 && Done%20 == 0)
+	 Prog->Progress(Done);
       for (VerIterator V = I.VersionList(); V.end() != true; V++)
       for (VerIterator V = I.VersionList(); V.end() != true; V++)
       {
       {
 	 unsigned char Group = 0;
 	 unsigned char Group = 0;
@@ -432,6 +442,9 @@ void pkgDepCache::Update()
       UpdateVerState(I);
       UpdateVerState(I);
       AddStates(I);
       AddStates(I);
    }
    }
+
+   if (Prog != 0)      
+      Prog->Progress(Done);
 }
 }
 									/*}}}*/
 									/*}}}*/
 // DepCache::Update - Update the deps list of a package	   		/*{{{*/
 // DepCache::Update - Update the deps list of a package	   		/*{{{*/

+ 5 - 7
apt-pkg/depcache.h

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: depcache.h,v 1.3 1998/07/12 23:58:25 jgg Exp $
+// $Id: depcache.h,v 1.4 1998/09/07 05:28:35 jgg Exp $
 /* ######################################################################
 /* ######################################################################
 
 
    DepCache - Dependency Extension data for the cache
    DepCache - Dependency Extension data for the cache
@@ -44,6 +44,7 @@
 #endif
 #endif
 
 
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/progress.h>
 
 
 class pkgDepCache : public pkgCache
 class pkgDepCache : public pkgCache
 {
 {
@@ -109,7 +110,7 @@ class pkgDepCache : public pkgCache
    void BuildGroupOrs(VerIterator const &V);
    void BuildGroupOrs(VerIterator const &V);
    void UpdateVerState(PkgIterator Pkg);
    void UpdateVerState(PkgIterator Pkg);
 
 
-   bool Init();
+   bool Init(OpProgress *Prog);
 
 
    protected:
    protected:
 
 
@@ -165,11 +166,8 @@ class pkgDepCache : public pkgCache
    void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true);
    void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true);
    
    
    // This is for debuging
    // This is for debuging
-   void Update();
+   void Update(OpProgress *Prog = 0);
 
 
-   // Hook to keep the extra data in sync
-   virtual bool ReMap();
-   
    // Size queries
    // Size queries
    inline long UsrSize() {return iUsrSize;};
    inline long UsrSize() {return iUsrSize;};
    inline long DebSize() {return iDownloadSize;};
    inline long DebSize() {return iDownloadSize;};
@@ -179,7 +177,7 @@ class pkgDepCache : public pkgCache
    inline long BrokenCount() {return iBrokenCount;};
    inline long BrokenCount() {return iBrokenCount;};
    inline long BadCount() {return iBadCount;};
    inline long BadCount() {return iBadCount;};
    
    
-   pkgDepCache(MMap &Map);
+   pkgDepCache(MMap &Map,OpProgress &Prog);
    virtual ~pkgDepCache();
    virtual ~pkgDepCache();
 };
 };
 
 

+ 5 - 2
apt-pkg/pkgcachegen.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: pkgcachegen.cc,v 1.14 1998/08/26 04:52:23 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.15 1998/09/07 05:28:37 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    Package Cache Generator - Generator for the cache structure.
    Package Cache Generator - Generator for the cache structure.
@@ -70,6 +70,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List)
 {
 {
    List.Owner = this;
    List.Owner = this;
 
 
+   int Counter = 0;
    while (List.Step() == true)
    while (List.Step() == true)
    {
    {
       // Get a pointer to the package structure
       // Get a pointer to the package structure
@@ -77,7 +78,9 @@ bool pkgCacheGenerator::MergeList(ListParser &List)
       pkgCache::PkgIterator Pkg;
       pkgCache::PkgIterator Pkg;
       if (NewPackage(Pkg,PackageName) == false)
       if (NewPackage(Pkg,PackageName) == false)
 	 return _error->Error("Error occured while processing %s (NewPackage)",PackageName.c_str());
 	 return _error->Error("Error occured while processing %s (NewPackage)",PackageName.c_str());
-      Progress.Progress(List.Offset());
+      Counter++;
+      if (Counter % 100 == 0)
+	 Progress.Progress(List.Offset());
 
 
       /* Get a pointer to the version structure. We know the list is sorted
       /* Get a pointer to the version structure. We know the list is sorted
          so we use that fact in the search. Insertion of new versions is
          so we use that fact in the search. Insertion of new versions is