]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcachegen.cc
Various minor bug fixes
[apt.git] / apt-pkg / pkgcachegen.cc
index ee65c94d1c707ed5b7b1893a953921533dcc0361..804c59a48cd38708dc9f79c564115564d0073f97 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: pkgcachegen.cc,v 1.35 1999/04/18 06:36:36 jgg Exp $
+// $Id: pkgcachegen.cc,v 1.39 1999/06/04 05:54:20 jgg Exp $
 /* ######################################################################
    
    Package Cache Generator - Generator for the cache structure.
@@ -26,6 +26,7 @@
 
 #include <sys/stat.h>
 #include <unistd.h>
+#include <errno.h>
                                                                        /*}}}*/
 
 // CacheGenerator::pkgCacheGenerator - Constructor                     /*{{{*/
@@ -110,20 +111,34 @@ bool pkgCacheGenerator::MergeList(ListParser &List)
       
       /* We already have a version for this item, record that we
          saw it */
-      if (Res == 0)
+      unsigned long Hash = List.VersionHash();
+      if (Res == 0 && Ver->Hash == Hash)
       {
         if (List.UsePackage(Pkg,Ver) == false)
            return _error->Error("Error occured while processing %s (UsePackage2)",PackageName.c_str());
-        
+
         if (NewFileVer(Ver,List) == false)
            return _error->Error("Error occured while processing %s (NewFileVer1)",PackageName.c_str());
         
         continue;
       }      
 
+      // Skip to the end of the same version set.
+      if (Res == 0)
+      {
+        for (; Ver.end() == false; Last = &Ver->NextVer, Ver++)
+        {
+           Res = pkgVersionCompare(Version.begin(),Version.end(),Ver.VerStr(),
+                                   Ver.VerStr() + strlen(Ver.VerStr()));
+           if (Res != 0)
+              break;
+        }
+      }
+
       // Add a new version
       *Last = NewVersion(Ver,Version,*Last);
       Ver->ParentPkg = Pkg.Index();
+      Ver->Hash = Hash;
       if (List.NewVersion(Ver) == false)
         return _error->Error("Error occured while processing %s (NewVersion1)",PackageName.c_str());
 
@@ -623,7 +638,7 @@ static bool pkgMergeStatus(OpProgress &Progress,pkgCacheGenerator &Gen,
 /* This puts the source package cache into the given generator. */
 bool pkgGenerateSrcCache(pkgSourceList &List,OpProgress &Progress,
                         pkgCacheGenerator &Gen,
-                        unsigned long &CurrentSize,unsigned long TotalSize)
+                        unsigned long &CurrentSize,unsigned long &TotalSize)
 {
    string ListDir = _config->FindDir("Dir::State::lists");
    
@@ -761,7 +776,9 @@ MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress)
    /* If the cache file is writeable this is just a wrapper for
       MakeStatusCache */
    string CacheFile = _config->FindFile("Dir::Cache::pkgcache");
-   bool Writeable = access(CacheFile.c_str(),W_OK) == 0;
+   bool Writeable = (access(CacheFile.c_str(),W_OK) == 0) ||
+                    (errno == ENOENT);
+
    if (Writeable == true)
    {
       if (pkgMakeStatusCache(List,Progress) == false)