+ if (_config->FindB("Debug::NoLocking",false) == true)
+ WithLock = false;
+
+ if (_error->PendingError() == true)
+ return false;
+
+ BuildSourceList(Progress);
+
+ // Read the caches
+ 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."));
+
+ /* This sux, remove it someday */
+ if (ErrorWasEmpty == true && _error->empty() == false)
+ _error->Warning(_("You may want to run apt-get update to correct these problems"));
+
+ Cache = new pkgCache(Map);
+ if (_error->PendingError() == true)
+ return false;
+ 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;
+
+ if (ReadPinFile(*Policy) == false || ReadPinDir(*Policy) == false)
+ return false;
+
+ 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);
+ 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();