summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/cachefile.cc58
-rw-r--r--apt-pkg/cachefile.h15
-rw-r--r--debian/changelog1
3 files changed, 61 insertions, 13 deletions
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index b0f8bc424..01598386c 100644
--- a/apt-pkg/cachefile.cc
+++ b/apt-pkg/cachefile.cc
@@ -27,7 +27,8 @@
// CacheFile::CacheFile - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-pkgCacheFile::pkgCacheFile() : Map(0), Cache(0), DCache(0), Policy(0)
+pkgCacheFile::pkgCacheFile() : Map(NULL), Cache(NULL), DCache(NULL),
+ Policy(NULL), SrcList(NULL)
{
}
/*}}}*/
@@ -38,16 +39,30 @@ pkgCacheFile::~pkgCacheFile()
{
delete DCache;
delete Policy;
+ delete SrcList;
delete Cache;
delete Map;
_system->UnLock(true);
-}
+}
/*}}}*/
// CacheFile::BuildCaches - Open and build the cache files /*{{{*/
// ---------------------------------------------------------------------
/* */
bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
{
+ if (Cache != NULL)
+ return true;
+
+ if (_config->FindB("pkgCacheFile::Generate", true) == false)
+ {
+ Map = new MMap(*new FileFd(_config->FindFile("Dir::Cache::pkgcache"),
+ FileFd::ReadOnly),MMap::Public|MMap::ReadOnly);
+ Cache = new pkgCache(Map);
+ if (_error->PendingError() == true)
+ return false;
+ return true;
+ }
+
const bool ErrorWasEmpty = _error->empty();
if (WithLock == true)
if (_system->Lock() == false)
@@ -58,14 +73,11 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
if (_error->PendingError() == true)
return false;
-
- // Read the source list
- pkgSourceList List;
- if (List.ReadMainList() == false)
- return _error->Error(_("The list of sources could not be read."));
+
+ BuildSourceList(Progress);
// Read the caches
- bool Res = pkgCacheGenerator::MakeStatusCache(List,Progress,&Map,!WithLock);
+ bool Res = pkgCacheGenerator::MakeStatusCache(*SrcList,Progress,&Map,!WithLock);
if (Progress != NULL)
Progress->Done();
if (Res == false)
@@ -81,11 +93,28 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock)
return true;
}
/*}}}*/
+// CacheFile::BuildSourceList - Open and build all relevant sources.list/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgCacheFile::BuildSourceList(OpProgress *Progress)
+{
+ if (SrcList != NULL)
+ return true;
+
+ SrcList = new pkgSourceList();
+ if (SrcList->ReadMainList() == false)
+ return _error->Error(_("The list of sources could not be read."));
+ return true;
+}
+ /*}}}*/
// CacheFile::BuildPolicy - Open and build all relevant preferences /*{{{*/
// ---------------------------------------------------------------------
/* */
bool pkgCacheFile::BuildPolicy(OpProgress *Progress)
{
+ if (Policy != NULL)
+ return true;
+
Policy = new pkgPolicy(Cache);
if (_error->PendingError() == true)
return false;
@@ -101,6 +130,9 @@ bool pkgCacheFile::BuildPolicy(OpProgress *Progress)
/* */
bool pkgCacheFile::BuildDepCache(OpProgress *Progress)
{
+ if (DCache != NULL)
+ return true;
+
DCache = new pkgDepCache(Cache,Policy);
if (_error->PendingError() == true)
return false;
@@ -139,12 +171,14 @@ void pkgCacheFile::Close()
delete DCache;
delete Policy;
delete Cache;
+ delete SrcList;
delete Map;
_system->UnLock(true);
- Map = 0;
- DCache = 0;
- Policy = 0;
- Cache = 0;
+ Map = NULL;
+ DCache = NULL;
+ Policy = NULL;
+ Cache = NULL;
+ SrcList = NULL;
}
/*}}}*/
diff --git a/apt-pkg/cachefile.h b/apt-pkg/cachefile.h
index b75a7dbe4..1647aff8e 100644
--- a/apt-pkg/cachefile.h
+++ b/apt-pkg/cachefile.h
@@ -23,6 +23,7 @@
#include <apt-pkg/sourcelist.h>
class pkgPolicy;
+class pkgSourceList;
class pkgCacheFile
{
protected:
@@ -31,6 +32,7 @@ class pkgCacheFile
pkgCache *Cache;
pkgDepCache *DCache;
pkgPolicy *Policy;
+ pkgSourceList *SrcList;
public:
@@ -39,6 +41,10 @@ class pkgCacheFile
inline operator pkgCache *() {return Cache;};
inline operator pkgDepCache &() {return *DCache;};
inline operator pkgDepCache *() {return DCache;};
+ inline operator pkgPolicy &() {return *Policy;};
+ inline operator pkgPolicy *() {return Policy;};
+ inline operator pkgSourceList &() {return *SrcList;};
+ inline operator pkgSourceList *() {return SrcList;};
inline pkgDepCache *operator ->() {return DCache;};
inline pkgDepCache &operator *() {return *DCache;};
inline pkgDepCache::StateCache &operator [](pkgCache::PkgIterator const &I) {return (*DCache)[I];};
@@ -46,12 +52,19 @@ class pkgCacheFile
bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true);
__deprecated bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); };
+ bool BuildSourceList(OpProgress *Progress = NULL);
bool BuildPolicy(OpProgress *Progress = NULL);
bool BuildDepCache(OpProgress *Progress = NULL);
bool Open(OpProgress *Progress = NULL, bool WithLock = true);
+ inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); };
__deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); };
void Close();
-
+
+ inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; };
+ inline pkgDepCache* GetDepCache() { BuildDepCache(); return DCache; };
+ inline pkgPolicy* GetPolicy() { BuildPolicy(); return Policy; };
+ inline pkgSourceList* GetSourceList() { BuildSourceList(); return SrcList; };
+
pkgCacheFile();
virtual ~pkgCacheFile();
};
diff --git a/debian/changelog b/debian/changelog
index 097916d1e..9001e91a7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -35,6 +35,7 @@ apt (0.7.26~exp6) UNRELEASED; urgency=low
* apt-pkg/cachefile.{cc,h}:
- split Open() into submethods to be able to build only parts
- make the OpProgress optional in the Cache buildprocess
+ - store also the SourceList we use internally for export
-- David Kalnischkies <kalnischkies@gmail.com> Mon, 31 May 2010 22:36:35 +0200