]>
git.saurik.com Git - apt.git/blob - apt-pkg/cachefile.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: cachefile.cc,v 1.7 2001/07/01 20:49:08 jgg Exp $
4 /* ######################################################################
6 CacheFile - Simple wrapper class for opening, generating and whatnot
8 This class implements a simple 2 line mechanism to open various sorts
9 of caches. It can operate as root, as not root, show progress and so on,
10 it transparently handles everything necessary.
12 ##################################################################### */
14 // Include Files /*{{{*/
16 #pragma implementation "apt-pkg/cachefile.h"
19 #include <apt-pkg/cachefile.h>
20 #include <apt-pkg/error.h>
21 #include <apt-pkg/sourcelist.h>
22 #include <apt-pkg/pkgcachegen.h>
23 #include <apt-pkg/configuration.h>
24 #include <apt-pkg/policy.h>
25 #include <apt-pkg/pkgsystem.h>
30 // CacheFile::CacheFile - Constructor /*{{{*/
31 // ---------------------------------------------------------------------
33 pkgCacheFile::pkgCacheFile() : Map(0), Cache(0), DCache(0), Policy(0)
37 // CacheFile::~CacheFile - Destructor /*{{{*/
38 // ---------------------------------------------------------------------
40 pkgCacheFile::~pkgCacheFile()
46 _system
->UnLock(true);
49 // CacheFile::Open - Open the cache files, creating if necessary /*{{{*/
50 // ---------------------------------------------------------------------
52 bool pkgCacheFile::Open(OpProgress
&Progress
,bool WithLock
)
55 if (_system
->Lock() == false)
58 if (_config
->FindB("Debug::NoLocking",false) == true)
61 if (_error
->PendingError() == true)
64 // Read the source list
66 if (List
.ReadMainList() == false)
67 return _error
->Error(_("The list of sources could not be read."));
70 bool Res
= pkgMakeStatusCache(List
,Progress
,&Map
,!WithLock
);
73 return _error
->Error(_("The package lists or status file could not be parsed or opened."));
75 /* This sux, remove it someday */
76 if (_error
->empty() == false)
77 _error
->Warning(_("You may want to run apt-get update to correct these problems"));
79 Cache
= new pkgCache(Map
);
80 if (_error
->PendingError() == true)
84 Policy
= new pkgPolicy(Cache
);
85 if (_error
->PendingError() == true)
87 if (ReadPinFile(*Policy
) == false)
90 // Create the dependency cache
91 DCache
= new pkgDepCache(Cache
,Policy
);
92 if (_error
->PendingError() == true)
95 DCache
->Init(&Progress
);
97 if (_error
->PendingError() == true)
104 // CacheFile::Close - close the cache files /*{{{*/
105 // ---------------------------------------------------------------------
107 void pkgCacheFile::Close()
113 _system
->UnLock(true);