apt: apt-pkg/indexfile.h Source File

apt 2.3.15 commandline package manager

indexfile.h
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 Index File - Abstraction for an index of archive/source file.
6
7 There are 4 primary sorts of index files, all represented by this
8 class:
9
10 Binary index files
11 Binary translation files
12 Binary index files describing the local system
13 Source index files
14
15 They are all bundled together here, and the interfaces for
16 sources.list, acquire, cache gen and record parsing all use this class
17 to access the underlying representation.
18
19 ##################################################################### */
20 /*}}}*/
21#ifndef PKGLIB_INDEXFILE_H
22#define PKGLIB_INDEXFILE_H
23
24#include <apt-pkg/macros.h>
25#include <apt-pkg/pkgcache.h>
26#include <apt-pkg/pkgrecords.h>
27#include <apt-pkg/srcrecords.h>
28
29#include <map>
30#include <string>
31
32
33class pkgCacheGenerator;
34class pkgCacheListParser;
35class OpProgress;
36
37 class APT_PUBLIC IndexTarget /*{{{*/
39{
40 public:
42 std::string URI;
43
45 std::string Description;
46
48 std::string ShortDesc;
49
52 std::string MetaKey;
53
55 bool IsOptional;
56
58 bool KeepCompressed;
59
63 std::map<std::string, std::string> Options;
64
65 IndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
66 std::string const &LongDesc, std::string const &URI, bool const IsOptional,
67 bool const KeepCompressed, std::map<std::string, std::string> const &Options);
68
69 enum OptionKeys
70 {
71 SITE,
72 RELEASE,
73 COMPONENT,
74 LANGUAGE,
75 ARCHITECTURE,
76 BASE_URI,
77 REPO_URI,
78 CREATED_BY,
79 TARGET_OF,
80 FILENAME,
81 EXISTING_FILENAME,
82 PDIFFS,
83 COMPRESSIONTYPES,
84 DEFAULTENABLED,
85 SOURCESENTRY,
86 BY_HASH,
87 KEEPCOMPRESSEDAS,
88 FALLBACK_OF,
89 IDENTIFIER,
90 ALLOW_INSECURE,
91 ALLOW_WEAK,
92 ALLOW_DOWNGRADE_TO_INSECURE,
93 INRELEASE_PATH,
94 };
95 std::string Option(OptionKeys const Key) const;
96 bool OptionBool(OptionKeys const Key) const;
97 std::string Format(std::string format) const;
98};
99 /*}}}*/
100
101 class APT_PUBLIC pkgIndexFile
102{
103 void * const d;
104 protected:
105 bool Trusted;
106
107 public:
108
109 class APT_PUBLIC Type
110 {
111 public:
112
113 // Global list of Items supported
114 static Type **GlobalList;
115 static unsigned long GlobalListLen;
116 static Type *GetType(const char * const Type) APT_PURE;
117
118 const char *Label;
119
120 virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &/*File*/) const {return 0;};
121 virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string const &/*File*/) const {return 0;};
122 Type();
123 virtual ~Type() {};
124 };
125
126 virtual const Type *GetType() const = 0;
127
128 // Return descriptive strings of various sorts
129 virtual std::string ArchiveInfo(pkgCache::VerIterator const &Ver) const;
130 virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
131 pkgSrcRecords::File const &File) const;
132 virtual std::string Describe(bool const Short = false) const = 0;
133
134 // Interface for acquire
135 virtual std::string ArchiveURI(std::string const &/*File*/) const {return std::string();};
136
137 // Interface for the record parsers
138 virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
139
140 // Interface for the Cache Generator
141 virtual bool Exists() const = 0;
142 virtual bool HasPackages() const = 0;
143 virtual unsigned long Size() const = 0;
144 virtual bool Merge(pkgCacheGenerator &/*Gen*/, OpProgress* const /*Prog*/) { return true; };
145 virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
146
147 bool IsTrusted() const { return Trusted; };
148
149 explicit pkgIndexFile(bool const Trusted);
150 virtual ~pkgIndexFile();
151};
152
153 class APT_PUBLIC pkgDebianIndexFile : public pkgIndexFile
154{
155protected:
156 virtual std::string IndexFileName() const = 0;
157 virtual std::string GetComponent() const = 0;
158 virtual std::string GetArchitecture() const = 0;
159 virtual std::string GetProgressDescription() const = 0;
160 virtual uint8_t GetIndexFlags() const = 0;
161 virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) = 0;
162 APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg);
163
164public:
165 virtual bool Merge(pkgCacheGenerator &Gen, OpProgress* const Prog) APT_OVERRIDE;
166 virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE;
167
168 explicit pkgDebianIndexFile(bool const Trusted);
169 virtual ~pkgDebianIndexFile();
170};
171
172 class APT_PUBLIC pkgDebianIndexTargetFile : public pkgDebianIndexFile
173{
174 void * const d;
175protected:
176 IndexTarget const Target;
177
178 virtual std::string IndexFileName() const APT_OVERRIDE;
179 virtual std::string GetComponent() const APT_OVERRIDE;
180 virtual std::string GetArchitecture() const APT_OVERRIDE;
181 virtual std::string GetProgressDescription() const APT_OVERRIDE;
182 virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
183
184public:
185 virtual std::string ArchiveURI(std::string const &File) const APT_OVERRIDE;
186 virtual std::string Describe(bool const Short = false) const APT_OVERRIDE;
187 virtual bool Exists() const APT_OVERRIDE;
188 virtual unsigned long Size() const APT_OVERRIDE;
189 IndexTarget GetIndexTarget() const APT_HIDDEN;
190
191 pkgDebianIndexTargetFile(IndexTarget const &Target, bool const Trusted);
192 virtual ~pkgDebianIndexTargetFile();
193};
194
195 class APT_PUBLIC pkgDebianIndexRealFile : public pkgDebianIndexFile
196{
197 void * const d;
198protected:
199 std::string File;
200
201 virtual std::string IndexFileName() const APT_OVERRIDE;
202 virtual std::string GetProgressDescription() const APT_OVERRIDE;
203 virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
204public:
205 virtual std::string Describe(bool const /*Short*/ = false) const APT_OVERRIDE;
206 virtual bool Exists() const APT_OVERRIDE;
207 virtual unsigned long Size() const APT_OVERRIDE;
208 virtual std::string ArchiveURI(std::string const &/*File*/) const APT_OVERRIDE;
209
210 pkgDebianIndexRealFile(std::string const &File, bool const Trusted);
211 virtual ~pkgDebianIndexRealFile();
212};
213
214#endif
FileFd
Definition: fileutl.h:39
IndexTarget
Information about an index file.
Definition: indexfile.h:39
IndexTarget::IsOptional
bool IsOptional
Is it okay if the file isn't found in the meta index.
Definition: indexfile.h:55
IndexTarget::KeepCompressed
bool KeepCompressed
If the file is downloaded compressed, do not unpack it.
Definition: indexfile.h:58
IndexTarget::Description
std::string Description
A description of the index file.
Definition: indexfile.h:45
IndexTarget::ShortDesc
std::string ShortDesc
A shorter description of the index file.
Definition: indexfile.h:48
IndexTarget::Options
std::map< std::string, std::string > Options
options with which this target was created Prefer the usage of #Option if at all possible....
Definition: indexfile.h:63
IndexTarget::URI
std::string URI
A URI from which the index file can be downloaded.
Definition: indexfile.h:42
IndexTarget::MetaKey
std::string MetaKey
The key by which this index file should be looked up within the meta index file.
Definition: indexfile.h:52
OpProgress
Definition: progress.h:30
URI
Definition: strutl.h:208
pkgCacheGenerator
Definition: pkgcachegen.h:43
pkgCacheListParser
Definition: pkgcachegen.h:172
pkgCache
Definition: cacheiterators.h:48
pkgDebianIndexFile
Definition: indexfile.h:154
pkgDebianIndexRealFile
Definition: indexfile.h:196
pkgDebianIndexTargetFile
Definition: indexfile.h:173
pkgIndexFile::Type
Definition: indexfile.h:110
pkgIndexFile
Definition: indexfile.h:102
pkgSrcRecords::Parser
Definition: srcrecords.h:39
pkgcache.h
pkgCache - Structure definitions for the cache file
pkgSrcRecords::File
Definition: srcrecords.h:30