apt: apt-pkg/indexfile.h Source File

apt 2.7.10 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 SHADOWED,
95 };
96 std::string Option(OptionKeys const Key) const;
97 bool OptionBool(OptionKeys const Key) const;
98 std::string Format(std::string format) const;
99};
100 /*}}}*/
101
102 class APT_PUBLIC pkgIndexFile
103{
104 void * const d;
105 protected:
106 bool Trusted;
107
108 public:
109
110 class APT_PUBLIC Type
111 {
112 public:
113
114 // Global list of Items supported
115 static Type **GlobalList;
116 static unsigned long GlobalListLen;
117 static Type *GetType(const char * const Type) APT_PURE;
118
119 const char *Label;
120
121 virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &/*File*/) const {return 0;};
122 virtual pkgSrcRecords::Parser *CreateSrcPkgParser(std::string const &/*File*/) const {return 0;};
123 Type();
124 virtual ~Type() {};
125 };
126
127 virtual const Type *GetType() const = 0;
128
129 // Return descriptive strings of various sorts
130 virtual std::string ArchiveInfo(pkgCache::VerIterator const &Ver) const;
131 virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
132 pkgSrcRecords::File const &File) const;
133 virtual std::string Describe(bool const Short = false) const = 0;
134
135 // Interface for acquire
136 virtual std::string ArchiveURI(std::string const &/*File*/) const {return std::string();};
137
138 // Interface for the record parsers
139 virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
140
141 // Interface for the Cache Generator
142 virtual bool Exists() const = 0;
143 virtual bool HasPackages() const = 0;
144 virtual unsigned long Size() const = 0;
145 virtual bool Merge(pkgCacheGenerator &/*Gen*/, OpProgress* const /*Prog*/) { return true; };
146 virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
147
148 bool IsTrusted() const { return Trusted; };
149
150 explicit pkgIndexFile(bool const Trusted);
151 virtual ~pkgIndexFile();
152};
153
154 class APT_PUBLIC pkgDebianIndexFile : public pkgIndexFile
155{
156protected:
157 virtual std::string IndexFileName() const = 0;
158 virtual std::string GetComponent() const = 0;
159 virtual std::string GetArchitecture() const = 0;
160 virtual std::string GetProgressDescription() const = 0;
161 virtual uint8_t GetIndexFlags() const = 0;
162 virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) = 0;
163 APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg);
164
165public:
166 virtual bool Merge(pkgCacheGenerator &Gen, OpProgress* const Prog) APT_OVERRIDE;
167 virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE;
168
169 explicit pkgDebianIndexFile(bool const Trusted);
170 virtual ~pkgDebianIndexFile();
171};
172
173 class APT_PUBLIC pkgDebianIndexTargetFile : public pkgDebianIndexFile
174{
175 void * const d;
176protected:
177 IndexTarget const Target;
178
179 virtual std::string IndexFileName() const APT_OVERRIDE;
180 virtual std::string GetComponent() const APT_OVERRIDE;
181 virtual std::string GetArchitecture() const APT_OVERRIDE;
182 virtual std::string GetProgressDescription() const APT_OVERRIDE;
183 virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
184
185public:
186 virtual std::string ArchiveURI(std::string const &File) const APT_OVERRIDE;
187 virtual std::string Describe(bool const Short = false) const APT_OVERRIDE;
188 virtual bool Exists() const APT_OVERRIDE;
189 virtual unsigned long Size() const APT_OVERRIDE;
190 IndexTarget GetIndexTarget() const APT_HIDDEN;
191
192 pkgDebianIndexTargetFile(IndexTarget const &Target, bool const Trusted);
193 virtual ~pkgDebianIndexTargetFile();
194};
195
196 class APT_PUBLIC pkgDebianIndexRealFile : public pkgDebianIndexFile
197{
198 void * const d;
199protected:
200 std::string File;
201
202 virtual std::string IndexFileName() const APT_OVERRIDE;
203 virtual std::string GetProgressDescription() const APT_OVERRIDE;
204 virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
205public:
206 virtual std::string Describe(bool const /*Short*/ = false) const APT_OVERRIDE;
207 virtual bool Exists() const APT_OVERRIDE;
208 virtual unsigned long Size() const APT_OVERRIDE;
209 virtual std::string ArchiveURI(std::string const &/*File*/) const APT_OVERRIDE;
210
211 pkgDebianIndexRealFile(std::string const &File, bool const Trusted);
212 virtual ~pkgDebianIndexRealFile();
213};
214
215#endif
FileFd
Definition fileutl.h:41
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:212
pkgCacheGenerator
Definition pkgcachegen.h:43
pkgCacheListParser
Definition pkgcachegen.h:178
pkgCache
Definition cacheiterators.h:47
pkgDebianIndexFile
Definition indexfile.h:155
pkgDebianIndexRealFile
Definition indexfile.h:197
pkgDebianIndexTargetFile
Definition indexfile.h:174
pkgIndexFile::Type
Definition indexfile.h:111
pkgIndexFile
Definition indexfile.h:103
pkgSrcRecords::Parser
Definition srcrecords.h:39
pkgcache.h
pkgCache - Structure definitions for the cache file
pkgSrcRecords::File
Definition srcrecords.h:30