]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcachegen.cc
* debian/rules:
[apt.git] / apt-pkg / pkgcachegen.cc
index 21240b9516fc451f86c6910c78273bd50bba990c..d96d3370fcf38a7372e3744a6c2ad40b720db079 100644 (file)
@@ -356,8 +356,7 @@ bool pkgCacheGenerator::NewGroup(pkgCache::GrpIterator &Grp, const string &Name)
    Grp->Next = Cache.HeaderP->GrpHashTable[Hash];
    Cache.HeaderP->GrpHashTable[Hash] = Group;
 
-   Cache.HeaderP->GroupCount++;
-
+   Grp->ID = Cache.HeaderP->GroupCount++;
    return true;
 }
                                                                        /*}}}*/
@@ -1003,7 +1002,20 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
    // Decide if we can write to the files..
    string const CacheFile = _config->FindFile("Dir::Cache::pkgcache");
    string const SrcCacheFile = _config->FindFile("Dir::Cache::srcpkgcache");
-   
+
+   // ensure the cache directory exists
+   if (CacheFile.empty() == false || SrcCacheFile.empty() == false)
+   {
+      string dir = _config->FindDir("Dir::Cache");
+      size_t const len = dir.size();
+      if (len > 5 && dir.find("/apt/", len - 6, 5) == len - 5)
+        dir = dir.substr(0, len - 5);
+      if (CacheFile.empty() == false)
+        CreateDirectory(dir, flNotFile(CacheFile));
+      if (SrcCacheFile.empty() == false)
+        CreateDirectory(dir, flNotFile(SrcCacheFile));
+   }
+
    // Decide if we can write to the cache
    bool Writeable = false;
    if (CacheFile.empty() == false)