]> git.saurik.com Git - apt.git/blob - apt-private/private-cachefile.h
Merge branch 'debian/sid' into debian/experimental
[apt.git] / apt-private / private-cachefile.h
1 #ifndef APT_PRIVATE_CACHEFILE_H
2 #define APT_PRIVATE_CACHEFILE_H
3
4 #include <apt-pkg/cachefile.h>
5 #include <apt-pkg/progress.h>
6 #include <apt-pkg/configuration.h>
7 #include <apt-pkg/pkgcache.h>
8 #include <apt-pkg/macros.h>
9 #include <apt-pkg/sourcelist.h>
10 #include <apti18n.h>
11
12 // FIXME: we need to find a way to export this
13 class APT_PUBLIC SourceList : public pkgSourceList
14 {
15
16 public:
17 // Add custom metaIndex (e.g. local files)
18 void AddMetaIndex(metaIndex *mi) {
19 SrcList.push_back(mi);
20 }
21
22 };
23
24 // class CacheFile - Cover class for some dependency cache functions /*{{{*/
25 // ---------------------------------------------------------------------
26 /* */
27 class APT_PUBLIC CacheFile : public pkgCacheFile
28 {
29 static pkgCache *SortCache;
30 APT_HIDDEN static int NameComp(const void *a,const void *b) APT_PURE;
31
32 public:
33 pkgCache::Package **List;
34
35 void Sort();
36 bool CheckDeps(bool AllowBroken = false);
37 bool BuildCaches(bool WithLock = true)
38 {
39 OpTextProgress Prog(*_config);
40 if (pkgCacheFile::BuildCaches(&Prog,WithLock) == false)
41 return false;
42 return true;
43 }
44 // FIXME: this can go once the "libapt-pkg" pkgSourceList has a way
45 // to add custom metaIndexes (or custom local files or so)
46 bool BuildSourceList(OpProgress */*Progress*/ = NULL) {
47 if (SrcList != NULL)
48 return true;
49 SrcList = new SourceList();
50 if (SrcList->ReadMainList() == false)
51 return _error->Error(_("The list of sources could not be read."));
52 return true;
53 }
54 bool Open(bool WithLock = true)
55 {
56 OpTextProgress Prog(*_config);
57 if (pkgCacheFile::Open(&Prog,WithLock) == false)
58 return false;
59 Sort();
60
61 return true;
62 };
63 bool OpenForInstall()
64 {
65 if (_config->FindB("APT::Get::Print-URIs") == true)
66 return Open(false);
67 else
68 return Open(true);
69 }
70 CacheFile() : List(0) {};
71 ~CacheFile() {
72 delete[] List;
73 }
74 };
75 /*}}}*/
76
77 #endif