summaryrefslogtreecommitdiff
path: root/apt-pkg/cachefile.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-09-03 14:04:50 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-09-03 14:04:50 +0200
commit0205540433440a9ff4ad4ea4cce44c700a4b401c (patch)
tree97809e2e38482d3d7f124b30552a0936adf4d405 /apt-pkg/cachefile.cc
parent24baab5c477bf1e57a0b169a7bac1d2e9ab0c974 (diff)
parent2c6baa5a1f935eb3b8d4eb9fdef62e696416e27a (diff)
merged from lp:~donkult/apt/sid
Diffstat (limited to 'apt-pkg/cachefile.cc')
-rw-r--r--apt-pkg/cachefile.cc106
1 files changed, 81 insertions, 25 deletions
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index 790312dc8..964c5bd8b 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),
+ SrcList(NULL), Policy(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)
+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,15 +73,13 @@ 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 = pkgMakeStatusCache(List,Progress,&Map,!WithLock);
- Progress.Done();
+ bool Res = pkgCacheGenerator::MakeStatusCache(*SrcList,Progress,&Map,!WithLock);
+ if (Progress != NULL)
+ Progress->Done();
if (Res == false)
return _error->Error(_("The package lists or status file could not be parsed or opened."));
@@ -80,29 +93,70 @@ bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock)
return true;
}
/*}}}*/
-// CacheFile::Open - Open the cache files, creating if necessary /*{{{*/
+// CacheFile::BuildSourceList - Open and build all relevant sources.list/*{{{*/
// ---------------------------------------------------------------------
/* */
-bool pkgCacheFile::Open(OpProgress &Progress,bool WithLock)
+bool pkgCacheFile::BuildSourceList(OpProgress *Progress)
{
- if (BuildCaches(Progress,WithLock) == false)
- return false;
-
- // The policy engine
+ 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;
if (ReadPinFile(*Policy) == false || ReadPinDir(*Policy) == false)
return false;
-
- // Create the dependency cache
+
+ return true;
+}
+ /*}}}*/
+// CacheFile::BuildDepCache - Open and build the dependency cache /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgCacheFile::BuildDepCache(OpProgress *Progress)
+{
+ if (DCache != NULL)
+ return true;
+
DCache = new pkgDepCache(Cache,Policy);
if (_error->PendingError() == true)
return false;
-
- DCache->Init(&Progress);
- Progress.Done();
+
+ DCache->Init(Progress);
+ return true;
+}
+ /*}}}*/
+// CacheFile::Open - Open the cache files, creating if necessary /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgCacheFile::Open(OpProgress *Progress, bool WithLock)
+{
+ if (BuildCaches(Progress,WithLock) == false)
+ return false;
+
+ if (BuildPolicy(Progress) == false)
+ return false;
+
+ if (BuildDepCache(Progress) == false)
+ return false;
+
+ if (Progress != NULL)
+ Progress->Done();
if (_error->PendingError() == true)
return false;
@@ -117,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;
}
/*}}}*/