]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcachegen.cc
use references instead of copies in the Cache generation methods
[apt.git] / apt-pkg / pkgcachegen.cc
index 8187b3950112be32e93a11820744c40986a30ed6..62e4577347d3716e3595fea1068d33679e6190ad 100644 (file)
@@ -61,8 +61,8 @@ pkgCacheGenerator::pkgCacheGenerator(DynamicMMap *pMap,OpProgress *Prog) :
 
       // Starting header
       *Cache.HeaderP = pkgCache::Header();
-      Cache.HeaderP->VerSysName = Map.WriteString(_system->VS->Label);
-      Cache.HeaderP->Architecture = Map.WriteString(_config->Find("APT::Architecture"));
+      Cache.HeaderP->VerSysName = WriteStringInMap(_system->VS->Label);
+      Cache.HeaderP->Architecture = WriteStringInMap(_config->Find("APT::Architecture"));
       Cache.ReMap();
    }
    else
@@ -96,6 +96,21 @@ pkgCacheGenerator::~pkgCacheGenerator()
    Map.Sync(0,sizeof(pkgCache::Header));
 }
                                                                        /*}}}*/
+// CacheGenerator::WriteStringInMap                                    /*{{{*/
+unsigned long pkgCacheGenerator::WriteStringInMap(const char *String,
+                                       const unsigned long &Len) {
+   return Map.WriteString(String, Len);
+}
+                                                                       /*}}}*/
+// CacheGenerator::WriteStringInMap                                    /*{{{*/
+unsigned long pkgCacheGenerator::WriteStringInMap(const char *String) {
+   return Map.WriteString(String);
+}
+                                                                       /*}}}*/
+unsigned long pkgCacheGenerator::AllocateInMap(const unsigned long &size) {/*{{{*/
+   return Map.Allocate(size);
+}
+                                                                       /*}}}*/
 // CacheGenerator::MergeList - Merge the package list                  /*{{{*/
 // ---------------------------------------------------------------------
 /* This provides the generation of the entries in the cache. Each loop
@@ -142,13 +157,14 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
         // we first process the package, then the descriptions
         // (this has the bonus that we get MMap error when we run out
         //  of MMap space)
-        if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false)
+        pkgCache::VerIterator Ver(Cache);
+        if (List.UsePackage(Pkg, Ver) == false)
            return _error->Error(_("Error occurred while processing %s (UsePackage1)"),
                                 PackageName.c_str());
 
         // Find the right version to write the description
         MD5SumValue CurMd5 = List.Description_md5();
-        pkgCache::VerIterator Ver = Pkg.VersionList();
+        Ver = Pkg.VersionList();
         map_ptrloc *LastVer = &Pkg->VersionList;
 
         for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
@@ -335,29 +351,29 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List)
 // CacheGenerator::NewGroup - Add a new group                          /*{{{*/
 // ---------------------------------------------------------------------
 /* This creates a new group structure and adds it to the hash table */
-bool pkgCacheGenerator::NewGroup(pkgCache::GrpIterator &Grp, const string &Name) {
-       Grp = Cache.FindGrp(Name);
-       if (Grp.end() == false)
-               return true;
-
-       // Get a structure
-       unsigned long const Group = Map.Allocate(sizeof(pkgCache::Group));
-       if (unlikely(Group == 0))
-               return false;
+bool pkgCacheGenerator::NewGroup(pkgCache::GrpIterator &Grp, const string &Name)
+{
+   Grp = Cache.FindGrp(Name);
+   if (Grp.end() == false)
+      return true;
 
-       Grp = pkgCache::GrpIterator(Cache, Cache.GrpP + Group);
-       Grp->Name = Map.WriteString(Name);
-       if (unlikely(Grp->Name == 0))
-               return false;
+   // Get a structure
+   unsigned long const Group = AllocateInMap(sizeof(pkgCache::Group));
+   if (unlikely(Group == 0))
+      return false;
 
-       // Insert it into the hash table
-       unsigned long const Hash = Cache.Hash(Name);
-       Grp->Next = Cache.HeaderP->GrpHashTable[Hash];
-       Cache.HeaderP->GrpHashTable[Hash] = Group;
+   Grp = pkgCache::GrpIterator(Cache, Cache.GrpP + Group);
+   Grp->Name = WriteStringInMap(Name);
+   if (unlikely(Grp->Name == 0))
+      return false;
 
-       Cache.HeaderP->GroupCount++;
+   // Insert it into the hash table
+   unsigned long const Hash = Cache.Hash(Name);
+   Grp->Next = Cache.HeaderP->GrpHashTable[Hash];
+   Cache.HeaderP->GrpHashTable[Hash] = Group;
 
-       return true;
+   Grp->ID = Cache.HeaderP->GroupCount++;
+   return true;
 }
                                                                        /*}}}*/
 // CacheGenerator::NewPackage - Add a new package                      /*{{{*/
@@ -374,20 +390,28 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name
         return true;
 
    // Get a structure
-   unsigned long const Package = Map.Allocate(sizeof(pkgCache::Package));
+   unsigned long const Package = AllocateInMap(sizeof(pkgCache::Package));
    if (unlikely(Package == 0))
       return false;
    Pkg = pkgCache::PkgIterator(Cache,Cache.PkgP + Package);
 
-   // Insert it into the hash table
-   unsigned long const Hash = Cache.Hash(Name);
-   Pkg->NextPackage = Cache.HeaderP->PkgHashTable[Hash];
-   Cache.HeaderP->PkgHashTable[Hash] = Package;
-
-   // remember the packages in the group
-   Grp->FirstPackage = Package;
-   if (Grp->LastPackage == 0)
-      Grp->LastPackage = Package;
+   // Insert the package into our package list
+   if (Grp->FirstPackage == 0) // the group is new
+   {
+      // Insert it into the hash table
+      unsigned long const Hash = Cache.Hash(Name);
+      Pkg->NextPackage = Cache.HeaderP->PkgHashTable[Hash];
+      Cache.HeaderP->PkgHashTable[Hash] = Package;
+      Grp->FirstPackage = Package;
+   }
+   else // Group the Packages together
+   {
+      // this package is the new last package
+      pkgCache::PkgIterator LastPkg(Cache, Cache.PkgP + Grp->LastPackage);
+      Pkg->NextPackage = LastPkg->NextPackage;
+      LastPkg->NextPackage = Package;
+   }
+   Grp->LastPackage = Package;
 
    // Set the name, arch and the ID
    Pkg->Name = Grp->Name;
@@ -410,7 +434,7 @@ bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver,
       return true;
    
    // Get a structure
-   unsigned long VerFile = Map.Allocate(sizeof(pkgCache::VerFile));
+   unsigned long VerFile = AllocateInMap(sizeof(pkgCache::VerFile));
    if (VerFile == 0)
       return 0;
    
@@ -441,7 +465,7 @@ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
                                            unsigned long Next)
 {
    // Get a structure
-   unsigned long Version = Map.Allocate(sizeof(pkgCache::Version));
+   unsigned long Version = AllocateInMap(sizeof(pkgCache::Version));
    if (Version == 0)
       return 0;
    
@@ -449,7 +473,7 @@ unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver,
    Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version);
    Ver->NextVer = Next;
    Ver->ID = Cache.HeaderP->VersionCount++;
-   Ver->VerStr = Map.WriteString(VerStr);
+   Ver->VerStr = WriteStringInMap(VerStr);
    if (Ver->VerStr == 0)
       return 0;
    
@@ -466,7 +490,7 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc,
       return true;
    
    // Get a structure
-   unsigned long DescFile = Map.Allocate(sizeof(pkgCache::DescFile));
+   unsigned long DescFile = AllocateInMap(sizeof(pkgCache::DescFile));
    if (DescFile == 0)
       return false;
 
@@ -499,7 +523,7 @@ map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
                                            map_ptrloc Next)
 {
    // Get a structure
-   map_ptrloc Description = Map.Allocate(sizeof(pkgCache::Description));
+   map_ptrloc Description = AllocateInMap(sizeof(pkgCache::Description));
    if (Description == 0)
       return 0;
 
@@ -507,8 +531,8 @@ map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
    Desc = pkgCache::DescIterator(Cache,Cache.DescP + Description);
    Desc->NextDesc = Next;
    Desc->ID = Cache.HeaderP->DescriptionCount++;
-   Desc->language_code = Map.WriteString(Lang);
-   Desc->md5sum = Map.WriteString(md5sum.Value());
+   Desc->language_code = WriteStringInMap(Lang);
+   Desc->md5sum = WriteStringInMap(md5sum.Value());
    if (Desc->language_code == 0 || Desc->md5sum == 0)
       return 0;
 
@@ -518,68 +542,73 @@ map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
 // CacheGenerator::FinishCache - do various finish operations          /*{{{*/
 // ---------------------------------------------------------------------
 /* This prepares the Cache for delivery */
-bool pkgCacheGenerator::FinishCache(OpProgress &Progress) {
-       // FIXME: add progress reporting for this operation
-       // Do we have different architectures in your groups ?
-       vector<string> archs = APT::Configuration::getArchitectures();
-       if (archs.size() > 1) {
-               // Create Conflicts in between the group
-               for (pkgCache::GrpIterator G = GetCache().GrpBegin(); G.end() != true; G++) {
-                       string const PkgName = G.Name();
-                       for (pkgCache::PkgIterator P = G.PackageList(); P.end() != true; P = G.NextPkg(P)) {
-                               if (strcmp(P.Arch(),"all") == 0)
-                                       continue;
-                               pkgCache::PkgIterator allPkg;
-                               for (pkgCache::VerIterator V = P.VersionList(); V.end() != true; V++) {
-                                       string const Arch = V.Arch(true);
-                                       map_ptrloc *OldDepLast = NULL;
-                                       /* MultiArch handling introduces a lot of implicit Dependencies:
-                                          - MultiArch: same → Co-Installable if they have the same version
-                                          - Architecture: all → Need to be Co-Installable for internal reasons
-                                          - All others conflict with all other group members */
-                                       bool const coInstall = (V->MultiArch == pkgCache::Version::All ||
-                                                               V->MultiArch == pkgCache::Version::Same);
-                                       if (V->MultiArch == pkgCache::Version::All && allPkg.end() == true)
-                                               allPkg = G.FindPkg("all");
-                                       for (vector<string>::const_iterator A = archs.begin(); A != archs.end(); ++A) {
-                                               if (*A == Arch)
-                                                       continue;
-                                               /* We allow only one installed arch at the time
-                                                  per group, therefore each group member conflicts
-                                                  with all other group members */
-                                               pkgCache::PkgIterator D = G.FindPkg(*A);
-                                               if (D.end() == true)
-                                                       continue;
-                                               if (coInstall == true) {
-                                                       // Replaces: ${self}:other ( << ${binary:Version})
-                                                       NewDepends(D, V, V.VerStr(),
-                                                                  pkgCache::Dep::Less, pkgCache::Dep::Replaces,
-                                                                  OldDepLast);
-                                                       // Breaks: ${self}:other (!= ${binary:Version})
-                                                       NewDepends(D, V, V.VerStr(),
-                                                                  pkgCache::Dep::Less, pkgCache::Dep::DpkgBreaks,
-                                                                  OldDepLast);
-                                                       NewDepends(D, V, V.VerStr(),
-                                                                  pkgCache::Dep::Greater, pkgCache::Dep::DpkgBreaks,
-                                                                  OldDepLast);
-                                                       if (V->MultiArch == pkgCache::Version::All) {
-                                                               // Depend on ${self}:all which does depend on nothing
-                                                               NewDepends(allPkg, V, V.VerStr(),
-                                                                          pkgCache::Dep::Equals, pkgCache::Dep::Depends,
-                                                                          OldDepLast);
-                                                       }
-                                               } else {
-                                                       // Conflicts: ${self}:other
-                                                       NewDepends(D, V, "",
-                                                                  pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts,
-                                                                  OldDepLast);
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-       return true;
+bool pkgCacheGenerator::FinishCache(OpProgress *Progress)
+{
+   // FIXME: add progress reporting for this operation
+   // Do we have different architectures in your groups ?
+   vector<string> archs = APT::Configuration::getArchitectures();
+   if (archs.size() > 1)
+   {
+      // Create Conflicts in between the group
+      for (pkgCache::GrpIterator G = GetCache().GrpBegin(); G.end() != true; G++)
+      {
+        string const PkgName = G.Name();
+        for (pkgCache::PkgIterator P = G.PackageList(); P.end() != true; P = G.NextPkg(P))
+        {
+           if (strcmp(P.Arch(),"all") == 0)
+              continue;
+           pkgCache::PkgIterator allPkg;
+           for (pkgCache::VerIterator V = P.VersionList(); V.end() != true; V++)
+           {
+              string const Arch = V.Arch(true);
+              map_ptrloc *OldDepLast = NULL;
+              /* MultiArch handling introduces a lot of implicit Dependencies:
+               - MultiArch: same → Co-Installable if they have the same version
+               - Architecture: all → Need to be Co-Installable for internal reasons
+               - All others conflict with all other group members */
+              bool const coInstall = (V->MultiArch == pkgCache::Version::All ||
+                                       V->MultiArch == pkgCache::Version::Same);
+              if (V->MultiArch == pkgCache::Version::All && allPkg.end() == true)
+                 allPkg = G.FindPkg("all");
+              for (vector<string>::const_iterator A = archs.begin(); A != archs.end(); ++A)
+              {
+                 if (*A == Arch)
+                    continue;
+                 /* We allow only one installed arch at the time
+                    per group, therefore each group member conflicts
+                    with all other group members */
+                 pkgCache::PkgIterator D = G.FindPkg(*A);
+                 if (D.end() == true)
+                    continue;
+                 if (coInstall == true)
+                 {
+                    // Replaces: ${self}:other ( << ${binary:Version})
+                    NewDepends(D, V, V.VerStr(),
+                               pkgCache::Dep::Less, pkgCache::Dep::Replaces,
+                               OldDepLast);
+                    // Breaks: ${self}:other (!= ${binary:Version})
+                    NewDepends(D, V, V.VerStr(),
+                               pkgCache::Dep::NotEquals, pkgCache::Dep::DpkgBreaks,
+                               OldDepLast);
+                    if (V->MultiArch == pkgCache::Version::All)
+                    {
+                       // Depend on ${self}:all which does depend on nothing
+                       NewDepends(allPkg, V, V.VerStr(),
+                                  pkgCache::Dep::Equals, pkgCache::Dep::Depends,
+                                  OldDepLast);
+                    }
+                 } else {
+                       // Conflicts: ${self}:other
+                       NewDepends(D, V, "",
+                                  pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts,
+                                  OldDepLast);
+                 }
+              }
+           }
+        }
+      }
+   }
+   return true;
 }
                                                                        /*}}}*/
 // CacheGenerator::NewDepends - Create a dependency element            /*{{{*/
@@ -594,7 +623,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
                                   map_ptrloc *OldDepLast)
 {
    // Get a structure
-   unsigned long const Dependency = Map.Allocate(sizeof(pkgCache::Dependency));
+   unsigned long const Dependency = AllocateInMap(sizeof(pkgCache::Dependency));
    if (unlikely(Dependency == 0))
       return false;
    
@@ -612,7 +641,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
         if (I->Version != 0 && I.TargetVer() == Version)
            Dep->Version = I->Version;*/
       if (Dep->Version == 0)
-        if (unlikely((Dep->Version = Map.WriteString(Version)) == 0))
+        if (unlikely((Dep->Version = WriteStringInMap(Version)) == 0))
            return false;
    }
 
@@ -640,7 +669,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
 // ---------------------------------------------------------------------
 /* This creates a Group and the Package to link this dependency to if
    needed and handles also the caching of the old endpoint */
-bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver,
+bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator &Ver,
                                               const string &PackageName,
                                               const string &Arch,
                                               const string &Version,
@@ -674,7 +703,7 @@ bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver,
 // ListParser::NewProvides - Create a Provides element                 /*{{{*/
 // ---------------------------------------------------------------------
 /* */
-bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
+bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver,
                                                const string &PkgName,
                                                const string &PkgArch,
                                                const string &Version)
@@ -686,7 +715,7 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver,
       return true;
    
    // Get a structure
-   unsigned long const Provides = Owner->Map.Allocate(sizeof(pkgCache::Provides));
+   unsigned long const Provides = Owner->AllocateInMap(sizeof(pkgCache::Provides));
    if (unlikely(Provides == 0))
       return false;
    Cache.HeaderP->ProvidesCount++;
@@ -721,12 +750,12 @@ bool pkgCacheGenerator::SelectFile(const string &File,const string &Site,
                                   unsigned long Flags)
 {
    // Get some space for the structure
-   CurrentFile = Cache.PkgFileP + Map.Allocate(sizeof(*CurrentFile));
+   CurrentFile = Cache.PkgFileP + AllocateInMap(sizeof(*CurrentFile));
    if (CurrentFile == Cache.PkgFileP)
       return false;
    
    // Fill it in
-   CurrentFile->FileName = Map.WriteString(File);
+   CurrentFile->FileName = WriteStringInMap(File);
    CurrentFile->Site = WriteUniqString(Site);
    CurrentFile->NextFile = Cache.HeaderP->FileList;
    CurrentFile->Flags = Flags;
@@ -778,7 +807,7 @@ unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
    }
    
    // Get a structure
-   unsigned long Item = Map.Allocate(sizeof(pkgCache::StringItem));
+   unsigned long Item = AllocateInMap(sizeof(pkgCache::StringItem));
    if (Item == 0)
       return 0;
 
@@ -786,7 +815,7 @@ unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
    pkgCache::StringItem *ItemP = Cache.StringItemP + Item;
    ItemP->NextItem = I - Cache.StringItemP;
    *Last = Item;
-   ItemP->String = Map.WriteString(S,Size);
+   ItemP->String = WriteStringInMap(S,Size);
    if (ItemP->String == 0)
       return 0;
    
@@ -907,7 +936,7 @@ static unsigned long ComputeSize(FileIterator Start,FileIterator End)
 // ---------------------------------------------------------------------
 /* */
 static bool BuildCache(pkgCacheGenerator &Gen,
-                      OpProgress &Progress,
+                      OpProgress *Progress,
                       unsigned long &CurrentSize,unsigned long TotalSize,
                       FileIterator Start, FileIterator End)
 {
@@ -928,7 +957,8 @@ static bool BuildCache(pkgCacheGenerator &Gen,
       }
       
       unsigned long Size = (*I)->Size();
-      Progress.OverallProgress(CurrentSize,TotalSize,Size,_("Reading package lists"));
+      if (Progress != NULL)
+        Progress->OverallProgress(CurrentSize,TotalSize,Size,_("Reading package lists"));
       CurrentSize += Size;
       
       if ((*I)->Merge(Gen,Progress) == false)
@@ -937,13 +967,15 @@ static bool BuildCache(pkgCacheGenerator &Gen,
 
    if (Gen.HasFileDeps() == true)
    {
-      Progress.Done();
+      if (Progress != NULL)
+        Progress->Done();
       TotalSize = ComputeSize(Start, End);
       CurrentSize = 0;
       for (I = Start; I != End; I++)
       {
         unsigned long Size = (*I)->Size();
-        Progress.OverallProgress(CurrentSize,TotalSize,Size,_("Collecting File Provides"));
+        if (Progress != NULL)
+           Progress->OverallProgress(CurrentSize,TotalSize,Size,_("Collecting File Provides"));
         CurrentSize += Size;
         if ((*I)->MergeFileProvides(Gen,Progress) == false)
            return false;
@@ -953,7 +985,7 @@ static bool BuildCache(pkgCacheGenerator &Gen,
    return true;
 }
                                                                        /*}}}*/
-// MakeStatusCache - Construct the status cache                                /*{{{*/
+// CacheGenerator::MakeStatusCache - Construct the status cache                /*{{{*/
 // ---------------------------------------------------------------------
 /* This makes sure that the status cache (the cache that has all 
    index files from the sources list and all local ones) is ready
@@ -961,7 +993,10 @@ static bool BuildCache(pkgCacheGenerator &Gen,
    the cache will be stored there. This is pretty much mandetory if you
    are using AllowMem. AllowMem lets the function be run as non-root
    where it builds the cache 'fast' into a memory buffer. */
-bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
+__deprecated bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
+                       MMap **OutMap, bool AllowMem)
+   { return pkgCacheGenerator::MakeStatusCache(List, &Progress, OutMap, AllowMem); }
+bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress,
                        MMap **OutMap,bool AllowMem)
 {
    bool const Debug = _config->FindB("Debug::pkgCacheGen", false);
@@ -986,7 +1021,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)
@@ -999,13 +1047,15 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
 
    if (Writeable == false && AllowMem == false && CacheFile.empty() == false)
       return _error->Error(_("Unable to write to %s"),flNotFile(CacheFile).c_str());
-   
-   Progress.OverallProgress(0,1,1,_("Reading package lists"));
-   
+
+   if (Progress != NULL)
+      Progress->OverallProgress(0,1,1,_("Reading package lists"));
+
    // Cache is OK, Fin.
    if (CheckValidity(CacheFile,Files.begin(),Files.end(),OutMap) == true)
    {
-      Progress.OverallProgress(1,1,1,_("Reading package lists"));
+      if (Progress != NULL)
+        Progress->OverallProgress(1,1,1,_("Reading package lists"));
       if (Debug == true)
         std::clog << "pkgcache.bin is valid - no need to build anything" << std::endl;
       return true;
@@ -1055,7 +1105,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
       TotalSize = ComputeSize(Files.begin()+EndOfSource,Files.end());
 
       // Build the status cache
-      pkgCacheGenerator Gen(Map.Get(),&Progress);
+      pkgCacheGenerator Gen(Map.Get(),Progress);
       if (_error->PendingError() == true)
         return false;
       if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
@@ -1072,7 +1122,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
       TotalSize = ComputeSize(Files.begin(),Files.end());
       
       // Build the source cache
-      pkgCacheGenerator Gen(Map.Get(),&Progress);
+      pkgCacheGenerator Gen(Map.Get(),Progress);
       if (_error->PendingError() == true)
         return false;
       if (BuildCache(Gen,Progress,CurrentSize,TotalSize,
@@ -1131,10 +1181,12 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
    return true;
 }
                                                                        /*}}}*/
-// MakeOnlyStatusCache - Build a cache with just the status files      /*{{{*/
+// CacheGenerator::MakeOnlyStatusCache - Build only a status files cache/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
+__deprecated bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
+   { return pkgCacheGenerator::MakeOnlyStatusCache(&Progress, OutMap); }
+bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap)
 {
    unsigned long MapSize = _config->FindI("APT::Cache-Limit",20*1024*1024);
    vector<pkgIndexFile *> Files;
@@ -1149,8 +1201,9 @@ bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
    TotalSize = ComputeSize(Files.begin()+EndOfSource,Files.end());
    
    // Build the status cache
-   Progress.OverallProgress(0,1,1,_("Reading package lists"));
-   pkgCacheGenerator Gen(Map.Get(),&Progress);
+   if (Progress != NULL)
+      Progress->OverallProgress(0,1,1,_("Reading package lists"));
+   pkgCacheGenerator Gen(Map.Get(),Progress);
    if (_error->PendingError() == true)
       return false;
    if (BuildCache(Gen,Progress,CurrentSize,TotalSize,