74#ifndef PKGLIB_PKGCACHE_H
75#define PKGLIB_PKGCACHE_H
76#define __PKGLIB_IN_PKGCACHE_H
77#include <apt-pkg/macros.h>
78#include <apt-pkg/mmap.h>
89typedef uint64_t map_filesize_t;
91typedef uint32_t map_filesize_small_t;
93typedef uint32_t map_id_t;
95typedef uint16_t map_fileid_t;
103 explicit map_pointer(uint32_t n) noexcept : val(n) {}
104 explicit operator uint32_t()
noexcept {
return val; }
105 explicit operator bool()
noexcept {
return val != 0; }
108template<
typename T>
inline T *operator +(T *p,
map_pointer<T> m) {
return p + uint32_t(m); }
114template<
typename T>
bool operator ==(
map_pointer<T> m, std::nullptr_t) {
return uint32_t(m) == 0; }
115template<
typename T>
bool operator !=(
map_pointer<T> m, std::nullptr_t) {
return uint32_t(m) != 0; }
121typedef uint8_t map_flags_t;
122typedef uint8_t map_number_t;
134 struct SourceVersion;
139 struct DependencyData;
145 template<
typename Str,
typename Itr>
class Iterator;
149 class SrcVerIterator;
153 class RlsFileIterator;
154 class PkgFileIterator;
155 class VerFileIterator;
156 class DescFileIterator;
167 enum DepType {Depends=1,PreDepends=2,Suggests=3,Recommends=4,
168 Conflicts=5,Replaces=6,Obsoletes=7,DpkgBreaks=8,Enhances=9};
175 Greater=0x4,Equals=0x5,NotEquals=0x6,
177 MultiArchImplicit=0x20,
187 enum VerPriority {Required=1,Important=2,Standard=3,Optional=4,Extra=5};
188 enum PkgSelectedState {Unknown=0,Install=1,Hold=2,DeInstall=3,Purge=4};
189 enum PkgInstState {Ok=0,ReInstReq=1,HoldInst=2,HoldReInstReq=3};
190 enum PkgCurrentState {NotInstalled=0,UnPacked=1,HalfConfigured=2,
191 HalfInstalled=4,ConfigFiles=5,Installed=6,
192 TriggersAwaited=7,TriggersPending=8};
197 enum PkgFlags {Auto=(1<<0),Essential=(1<<3),Important=(1<<4)};
205 ButAutomaticUpgrades=(1<<1),
216 std::string CacheFile;
218 map_id_t sHash(std::string_view S)
const APT_PURE;
228 ReleaseFile *RlsFileP;
229 PackageFile *PkgFileP;
230 SourceVersion *SrcVerP;
235 DependencyData *DepDataP;
239 virtual bool ReMap(
bool const &Errorchecks =
true);
240 inline bool Sync() {
return Map.Sync();}
241 inline MMap &GetMap() {
return Map;}
242 inline void *DataEnd() {
return ((
unsigned char *)Map.Data()) + Map.Size();}
245 inline map_id_t Hash(std::string_view S)
const {
return sHash(S);}
247 APT_HIDDEN uint32_t CacheHash();
250 static const char *Priority(
unsigned char Priority);
251 static std::string_view Priority_NoL10n(
unsigned char Prio);
254 GrpIterator FindGrp(std::string_view Name);
255 PkgIterator FindPkg(std::string_view Name);
256 PkgIterator FindPkg(std::string_view Name, std::string_view Arch);
260 char *name = StrP + idx;
261 size_t len = *
reinterpret_cast<const uint16_t*
>(name -
sizeof(uint16_t));
265 Header &Head() {
return *HeaderP;}
266 inline GrpIterator GrpBegin();
267 inline GrpIterator GrpEnd();
268 inline PkgIterator PkgBegin();
269 inline PkgIterator PkgEnd();
270 inline PkgFileIterator FileBegin();
271 inline PkgFileIterator FileEnd();
272 inline RlsFileIterator RlsFileBegin();
273 inline RlsFileIterator RlsFileEnd();
275 inline bool MultiArchCache()
const {
return MultiArchEnabled; }
276 inline char const * NativeArch();
282 static const char *CompTypeDeb(
unsigned char Comp) APT_PURE;
283 static const char *CompType(
unsigned char Comp) APT_PURE;
284 static const char *DepType(
unsigned char Dep);
285 static std::string_view DepType_NoL10n(
unsigned char Dep);
292 bool MultiArchEnabled;
306 map_number_t MinorVersion;
322 map_number_t GroupSz;
323 map_number_t PackageSz;
324 map_number_t ReleaseFileSz;
325 map_number_t PackageFileSz;
326 map_number_t VersionSz;
327 map_number_t SourceVersionSz;
328 map_number_t DescriptionSz;
329 map_number_t DependencySz;
330 map_number_t DependencyDataSz;
331 map_number_t ProvidesSz;
332 map_number_t VerFileSz;
333 map_number_t DescFileSz;
341 map_id_t PackageCount;
342 map_id_t VersionCount;
343 map_id_t SourceVersionCount;
344 map_id_t DescriptionCount;
345 map_id_t DependsCount;
346 map_id_t DependsDataCount;
347 map_fileid_t ReleaseFileCount;
348 map_fileid_t PackageFileCount;
349 map_id_t VerFileCount;
350 map_id_t DescFileCount;
351 map_id_t ProvidesCount;
394 void SetHashTableSize(
unsigned int const sz) {
HashTableSize = sz; }
398#ifdef APT_COMPILING_APT
406 bool CheckSizes(
Header &Against)
const APT_PURE;
722#ifdef APT_COMPILING_APT
724struct pkgCache::Version::Extra
726 uint8_t PhasedUpdatePercentage;
824inline char const * pkgCache::NativeArch()
825 {
return StrP + HeaderP->Architecture; }
827#include <apt-pkg/cacheiterators.h>
829 inline pkgCache::GrpIterator pkgCache::GrpBegin()
831 return GrpIterator(*
this);
833 inline pkgCache::GrpIterator pkgCache::GrpEnd()
835 return GrpIterator(*
this, GrpP);}
836inline pkgCache::PkgIterator pkgCache::PkgBegin()
837 {
return PkgIterator(*
this);}
838inline pkgCache::PkgIterator pkgCache::PkgEnd()
839 {
return PkgIterator(*
this,PkgP);}
840inline pkgCache::PkgFileIterator pkgCache::FileBegin()
841 {
return PkgFileIterator(*
this,PkgFileP + HeaderP->FileList);}
842inline pkgCache::PkgFileIterator pkgCache::FileEnd()
843 {
return PkgFileIterator(*
this,PkgFileP);}
844inline pkgCache::RlsFileIterator pkgCache::RlsFileBegin()
845 {
return RlsFileIterator(*
this,RlsFileP + HeaderP->RlsFileList);}
846inline pkgCache::RlsFileIterator pkgCache::RlsFileEnd()
847 {
return RlsFileIterator(*
this,RlsFileP);}
854 typedef pkgCache::GrpIterator GrpIterator;
855 typedef pkgCache::PkgIterator PkgIterator;
856 typedef pkgCache::VerIterator VerIterator;
857 typedef pkgCache::SrcVerIterator SrcVerIterator;
858 typedef pkgCache::DescIterator DescIterator;
859 typedef pkgCache::DepIterator DepIterator;
860 typedef pkgCache::PrvIterator PrvIterator;
861 typedef pkgCache::RlsFileIterator RlsFileIterator;
862 typedef pkgCache::PkgFileIterator PkgFileIterator;
863 typedef pkgCache::VerFileIterator VerFileIterator;
872#undef __PKGLIB_IN_PKGCACHE_H
Definition pkgcache.h:145
Definition pkgcache.h:852
Definition cacheiterators.h:47
Definition pkgcache.h:166
DepCompareOp
available compare operators
Definition pkgcache.h:174
@ ArchSpecific
Definition pkgcache.h:178
@ MultiArchImplicit
Definition pkgcache.h:177
information for a single dependency record
Definition pkgcache.h:764
map_flags_t CompareOp
comparison operator specified on the depends line
Definition pkgcache.h:778
map_stringitem_t Version
string of the version the dependency is applied against
Definition pkgcache.h:766
map_pointer< pkgCache::Package > Package
index of the package this depends applies to
Definition pkgcache.h:771
map_number_t Type
Dependency type - Depends, Recommends, Conflicts, etc.
Definition pkgcache.h:774
Definition pkgcache.h:783
map_pointer< Dependency > NextRevDepends
next reverse dependency of this package
Definition pkgcache.h:788
map_pointer< Dependency > NextDepends
next dependency of this version
Definition pkgcache.h:790
map_pointer< Version > ParentVer
version of the package which has the depends
Definition pkgcache.h:786
map_id_t ID
unique sequel ID
Definition pkgcache.h:793
associates a description with a Translation file
Definition pkgcache.h:615
map_pointer< DescFile > NextFile
next step in the linked list
Definition pkgcache.h:619
map_filesize_t Offset
position in the file
Definition pkgcache.h:621
map_pointer< PackageFile > File
index of the file that this description was found in
Definition pkgcache.h:617
datamember of a linked list of available description for a version
Definition pkgcache.h:733
map_pointer< Description > NextDesc
next translation for this description
Definition pkgcache.h:748
map_pointer< Package > ParentPkg
the text is a description of this package
Definition pkgcache.h:750
map_stringitem_t md5sum
MD5sum of the original description.
Definition pkgcache.h:743
map_id_t ID
unique sequel ID
Definition pkgcache.h:753
map_pointer< DescFile > FileList
Definition pkgcache.h:746
map_stringitem_t language_code
Language code of this description (translation)
Definition pkgcache.h:738
Definition pkgcache.h:196
ProvidesFlags
Definition pkgcache.h:207
ReleaseFileFlags
Definition pkgcache.h:203
PkgFFlags
Definition pkgcache.h:198
groups architecture depending packages together
Definition pkgcache.h:422
map_stringitem_t Name
Name of the group.
Definition pkgcache.h:424
map_pointer< Group > Next
Link to the next Group.
Definition pkgcache.h:433
map_pointer< Version > VersionsInSource
List of binary produces by source package with this name.
Definition pkgcache.h:438
map_pointer< Package > FirstPackage
Link to the first package which belongs to the group.
Definition pkgcache.h:428
map_pointer< Package > LastPackage
Link to the last package which belongs to the group.
Definition pkgcache.h:430
map_pointer< void > d
Private pointer.
Definition pkgcache.h:444
map_id_t ID
unique sequel ID
Definition pkgcache.h:435
map_pointer< SourceVersion > SourceVersionList
SourceVersionList.
Definition pkgcache.h:441
stores information about the files used to generate the cache
Definition pkgcache.h:562
map_pointer< PackageFile > NextFile
Link to the next PackageFile in the Cache.
Definition pkgcache.h:589
map_fileid_t ID
unique sequel ID
Definition pkgcache.h:591
time_t mtime
Modification time for the file.
Definition pkgcache.h:582
map_stringitem_t FileName
physical disk file that this PackageFile represents
Definition pkgcache.h:564
map_flags_t Flags
Definition pkgcache.h:585
map_stringitem_t IndexType
indicates what sort of index file this is
Definition pkgcache.h:574
map_filesize_t Size
Size of the file.
Definition pkgcache.h:580
map_pointer< void > d
Private pointer.
Definition pkgcache.h:594
map_pointer< ReleaseFile > Release
the release information
Definition pkgcache.h:566
contains information for a single unique package
Definition pkgcache.h:460
map_pointer< Dependency > RevDepends
List of all dependencies on this package.
Definition pkgcache.h:482
map_number_t CurrentState
indicates if the package is installed
Definition pkgcache.h:496
map_stringitem_t Arch
Architecture of the package.
Definition pkgcache.h:462
map_pointer< Version > VersionList
Base of a singly linked list of versions.
Definition pkgcache.h:472
map_number_t InstState
installation state of the package
Definition pkgcache.h:494
map_pointer< pkgCache::Group > Group
index of the group this package belongs to
Definition pkgcache.h:476
map_pointer< Version > CurrentVer
index to the installed version
Definition pkgcache.h:474
map_flags_t Flags
some useful indicators of the package's state
Definition pkgcache.h:506
map_pointer< Package > NextPackage
Link to the next package in the same bucket.
Definition pkgcache.h:480
map_number_t SelectedState
state that the user wishes the package to be in
Definition pkgcache.h:488
map_pointer< void > d
Private pointer.
Definition pkgcache.h:509
map_pointer< Provides > ProvidesList
List of all "packages" this package provide.
Definition pkgcache.h:484
map_id_t ID
unique sequel ID
Definition pkgcache.h:504
handles virtual packages
Definition pkgcache.h:806
map_pointer< Provides > NextPkgProv
next provides (based of version)
Definition pkgcache.h:820
map_pointer< pkgCache::Version > Version
index of the version this provide line applies to
Definition pkgcache.h:810
map_pointer< Package > ParentPkg
index of the package providing this
Definition pkgcache.h:808
map_pointer< Provides > NextProvides
next provides (based of package)
Definition pkgcache.h:818
map_stringitem_t ProvideVersion
version in the provides line (if any)
Definition pkgcache.h:815
stores information about the release files used to generate the cache
Definition pkgcache.h:518
map_stringitem_t Archive
the release information
Definition pkgcache.h:525
map_fileid_t ID
unique sequel ID
Definition pkgcache.h:549
map_stringitem_t Site
The site the index file was fetched from.
Definition pkgcache.h:531
map_pointer< ReleaseFile > NextFile
Link to the next ReleaseFile in the Cache.
Definition pkgcache.h:547
time_t mtime
Modification time for the file.
Definition pkgcache.h:540
map_stringitem_t FileName
physical disk file that this ReleaseFile represents
Definition pkgcache.h:520
map_flags_t Flags
Definition pkgcache.h:543
map_filesize_t Size
Size of the file.
Definition pkgcache.h:538
map_pointer< void > d
Private pointer.
Definition pkgcache.h:552
information for a single version of a source package
Definition pkgcache.h:631
map_stringitem_t VerStr
complete version string
Definition pkgcache.h:637
map_pointer< pkgCache::Group > Group
Group the source package belongs too.
Definition pkgcache.h:635
map_pointer< void > d
Private pointer.
Definition pkgcache.h:642
map_id_t ID
unique sequel ID
Definition pkgcache.h:633
Definition pkgcache.h:183
VerPriority
priority of a package version
Definition pkgcache.h:187
associates a version with a PackageFile
Definition pkgcache.h:603
map_pointer< VerFile > NextFile
next step in the linked list
Definition pkgcache.h:607
map_filesize_t Offset
position in the package file
Definition pkgcache.h:609
map_pointer< PackageFile > File
index of the package file that this version was found in
Definition pkgcache.h:605
information for a single version of a package
Definition pkgcache.h:652
map_number_t MultiArch
stores the MultiArch capabilities of this version
Definition pkgcache.h:678
map_pointer< Version > NextInSourceVersion
next version in the source package (might be different binary)
Definition pkgcache.h:663
map_stringitem_t VerStr
complete version string
Definition pkgcache.h:656
map_number_t Priority
parsed priority value
Definition pkgcache.h:714
map_pointer< Version > NextVer
next (lower or equal) version in the linked list
Definition pkgcache.h:688
map_stringitem_t Section
section this version is filled in
Definition pkgcache.h:658
uint32_t Hash
characteristic value representing this version
Definition pkgcache.h:710
map_filesize_t InstalledSize
uncompressed size for this version
Definition pkgcache.h:705
VerMultiArch
Multi-Arch capabilities of a package version.
Definition pkgcache.h:666
@ Same
Definition pkgcache.h:669
@ Foreign
Definition pkgcache.h:668
@ Allowed
Definition pkgcache.h:670
@ All
Definition pkgcache.h:667
@ No
Definition pkgcache.h:666
map_filesize_t Size
archive size for this version
Definition pkgcache.h:703
map_pointer< Package > ParentPkg
links to the owning package
Definition pkgcache.h:696
map_pointer< Version > NextInSource
next version in the source package (might be different binary)
Definition pkgcache.h:716
map_pointer< Dependency > DependsList
base of the dependency list
Definition pkgcache.h:692
map_pointer< Provides > ProvidesList
list of pkgCache::Provides
Definition pkgcache.h:698
map_id_t ID
unique sequel ID
Definition pkgcache.h:712
map_pointer< Extra > d
Private pointer.
Definition pkgcache.h:719
map_pointer< VerFile > FileList
references all the PackageFile's that this version came from
Definition pkgcache.h:686
map_pointer< Description > DescriptionList
next description in the linked list
Definition pkgcache.h:690
map_pointer< pkgCache::SourceVersion > SourceVersion
the source version object
Definition pkgcache.h:661