apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pkgcache.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /**\file pkgcache.h
4  \brief pkgCache - Structure definitions for the cache file
5 
6  The goal of the cache file is two fold:
7  Firstly to speed loading and processing of the package file array and
8  secondly to reduce memory consumption of the package file array.
9 
10  The implementation is aimed at an environment with many primary package
11  files, for instance someone that has a Package file for their CD-ROM, a
12  Package file for the latest version of the distribution on the CD-ROM and a
13  package file for the development version. Always present is the information
14  contained in the status file which might be considered a separate package
15  file.
16 
17  Please understand, this is designed as a <b>Cache file</b> it is not meant to be
18  used on any system other than the one it was created for. It is not meant to
19  be authoritative either, i.e. if a system crash or software failure occurs it
20  must be perfectly acceptable for the cache file to be in an inconsistent
21  state. Furthermore at any time the cache file may be erased without losing
22  any information.
23 
24  Also the structures and storage layout is optimized for use by the APT
25  and may not be suitable for all purposes. However it should be possible
26  to extend it with associate cache files that contain other information.
27 
28  To keep memory use down the cache file only contains often used fields and
29  fields that are inexpensive to store, the Package file has a full list of
30  fields. Also the client may assume that all items are perfectly valid and
31  need not perform checks against their correctness. Removal of information
32  from the cache is possible, but blanks will be left in the file, and
33  unused strings will also be present. The recommended implementation is to
34  simply rebuild the cache each time any of the data files change. It is
35  possible to add a new package file to the cache without any negative side
36  effects.
37 
38  <b>Note on Pointer access</b>
39  Clients should always use the CacheIterators classes for access to the
40  cache and the data in it. They also provide a simple STL-like method for
41  traversing the links of the datastructure.
42 
43  Every item in every structure is stored as the index to that structure.
44  What this means is that once the files is mmaped every data access has to
45  go through a fix up stage to get a real memory pointer. This is done
46  by taking the index, multiplying it by the type size and then adding
47  it to the start address of the memory block. This sounds complex, but
48  in C it is a single array dereference. Because all items are aligned to
49  their size and indexes are stored as multiples of the size of the structure
50  the format is immediately portable to all possible architectures - BUT the
51  generated files are -NOT-.
52 
53  This scheme allows code like this to be written:
54  <example>
55  void *Map = mmap(...);
56  Package *PkgList = (Package *)Map;
57  Header *Head = (Header *)Map;
58  char *Strings = (char *)Map;
59  cout << (Strings + PkgList[Head->HashTable[0]]->Name) << endl;
60  </example>
61  Notice the lack of casting or multiplication. The net result is to return
62  the name of the first package in the first hash bucket, without error
63  checks.
64 
65  The generator uses allocation pools to group similarly sized structures in
66  large blocks to eliminate any alignment overhead. The generator also
67  assures that no structures overlap and all indexes are unique. Although
68  at first glance it may seem like there is the potential for two structures
69  to exist at the same point the generator never allows this to happen.
70  (See the discussion of free space pools)
71 
72  See \ref pkgcachegen.h for more information about generating cache structures. */
73  /*}}}*/
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>
79 
80 #include <cstddef> // required for nullptr_t
81 #include <string>
82 #include <stdint.h>
83 #include <time.h>
84 
85 #include <apt-pkg/string_view.h>
86 
87 
88 // size of (potentially big) files like debs or the install size of them
89 typedef uint64_t map_filesize_t;
90 // storing file sizes of indexes, which are way below 4 GB for now
91 typedef uint32_t map_filesize_small_t;
92 // each package/group/dependency gets an id
93 typedef uint32_t map_id_t;
94 // some files get an id, too, but in far less absolute numbers
95 typedef uint16_t map_fileid_t;
96 
97 // relative pointer from cache start
98 template <typename T> class map_pointer {
99  uint32_t val;
100 public:
101  map_pointer() noexcept : val(0) {}
102  map_pointer(std::nullptr_t) noexcept : val(0) {}
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; }
106 };
107 
108 template<typename T> inline T *operator +(T *p, map_pointer<T> m) { return p + uint32_t(m); }
109 template<typename T> inline bool operator ==(map_pointer<T> u, map_pointer<T> m) { return uint32_t(u) == uint32_t(m); }
110 template<typename T> inline bool operator !=(map_pointer<T> u, map_pointer<T> m) { return uint32_t(u) != uint32_t(m); }
111 template<typename T> inline bool operator <(map_pointer<T> u, map_pointer<T> m) { return uint32_t(u) < uint32_t(m); }
112 template<typename T> inline bool operator >(map_pointer<T> u, map_pointer<T> m) { return uint32_t(u) > uint32_t(m); }
113 template<typename T> inline uint32_t operator -(map_pointer<T> u, map_pointer<T> m) { return uint32_t(u) - uint32_t(m); }
114 template<typename T> bool operator ==(map_pointer<T> m, std::nullptr_t) { return uint32_t(m) == 0; }
115 template<typename T> bool operator !=(map_pointer<T> m, std::nullptr_t) { return uint32_t(m) != 0; }
116 
117 // same as the previous, but documented to be to a string item
119 
120 // we have only a small amount of flags for each item
121 typedef uint8_t map_flags_t;
122 typedef uint8_t map_number_t;
123 
124 class pkgVersioningSystem;
125 class APT_PUBLIC pkgCache /*{{{*/
126 {
127  public:
128  // Cache element predeclarations
129  struct Header;
130  struct Group;
131  struct Package;
132  struct ReleaseFile;
133  struct PackageFile;
134  struct Version;
135  struct Description;
136  struct Provides;
137  struct Dependency;
138  struct DependencyData;
139  struct StringItem;
140  struct VerFile;
141  struct DescFile;
142 
143  // Iterators
144  template<typename Str, typename Itr> class Iterator;
145  class GrpIterator;
146  class PkgIterator;
147  class VerIterator;
148  class DescIterator;
149  class DepIterator;
150  class PrvIterator;
151  class RlsFileIterator;
152  class PkgFileIterator;
153  class VerFileIterator;
154  class DescFileIterator;
155 
156  class Namespace;
157 
158  // These are all the constants used in the cache structures
159 
160  // WARNING - if you change these lists you must also edit
161  // the stringification in pkgcache.cc and also consider whether
162  // the cache file will become incompatible.
163  struct Dep
164  {
165  enum DepType {Depends=1,PreDepends=2,Suggests=3,Recommends=4,
166  Conflicts=5,Replaces=6,Obsoletes=7,DpkgBreaks=8,Enhances=9};
167  /** \brief available compare operators
168 
169  The lower 4 bits are used to indicate what operator is being specified and
170  the upper 4 bits are flags. OR indicates that the next package is
171  or'd with the current package. */
172  enum DepCompareOp {NoOp=0,LessEq=0x1,GreaterEq=0x2,Less=0x3,
173  Greater=0x4,Equals=0x5,NotEquals=0x6,
174  Or=0x10, /*!< or'ed with the next dependency */
175  MultiArchImplicit=0x20, /*!< generated internally, not spelled out in the index */
176  ArchSpecific=0x40 /*!< was decorated with an explicit architecture in index */
177  };
178  };
179 
180  struct State
181  {
182  /** \brief priority of a package version
183 
184  Zero is used for unparsable or absent Priority fields. */
185  enum VerPriority {Required=1,Important=2,Standard=3,Optional=4,Extra=5};
186  enum PkgSelectedState {Unknown=0,Install=1,Hold=2,DeInstall=3,Purge=4};
187  enum PkgInstState {Ok=0,ReInstReq=1,HoldInst=2,HoldReInstReq=3};
188  enum PkgCurrentState {NotInstalled=0,UnPacked=1,HalfConfigured=2,
189  HalfInstalled=4,ConfigFiles=5,Installed=6,
190  TriggersAwaited=7,TriggersPending=8};
191  };
192 
193  struct Flag
194  {
195  enum PkgFlags {Auto=(1<<0),Essential=(1<<3),Important=(1<<4)};
196  enum PkgFFlags {
197  NotSource=(1<<0), /*!< packages can't be fetched from here, e.g. dpkg/status file */
198  LocalSource=(1<<1), /*!< local sources can't and will not be verified by hashes */
199  NoPackages=(1<<2), /*!< the file includes no package records itself, but additions like Translations */
200  };
202  NotAutomatic=(1<<0), /*!< archive has a default pin of 1 */
203  ButAutomaticUpgrades=(1<<1), /*!< (together with the previous) archive has a default pin of 100 */
204  };
206  MultiArchImplicit=pkgCache::Dep::MultiArchImplicit, /*!< generated internally, not spelled out in the index */
207  ArchSpecific=pkgCache::Dep::ArchSpecific /*!< was decorated with an explicit architecture in index */
208  };
209  };
210 
211  protected:
212 
213  // Memory mapped cache file
214  std::string CacheFile;
216  map_id_t sHash(APT::StringView S) const APT_PURE;
217 
218  public:
219 
220  // Pointers to the arrays of items
233  char *StrP;
234  void *reserved[12];
235 
236  virtual bool ReMap(bool const &Errorchecks = true);
237  inline bool Sync() {return Map.Sync();}
238  inline MMap &GetMap() {return Map;}
239  inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();}
240 
241  // String hashing function (512 range)
242  inline map_id_t Hash(APT::StringView S) const {return sHash(S);}
243 
244  APT_HIDDEN uint32_t CacheHash();
245 
246  // Useful transformation things
247  static const char *Priority(unsigned char Priority);
248 
249  // Accessors
250  GrpIterator FindGrp(APT::StringView Name);
251  PkgIterator FindPkg(APT::StringView Name);
252  PkgIterator FindPkg(APT::StringView Name, APT::StringView Arch);
253 
255  {
256  char *name = StrP + idx;
257  uint16_t len = *reinterpret_cast<const uint16_t*>(name - sizeof(uint16_t));
258  return APT::StringView(name, len);
259  }
260 
261  Header &Head() {return *HeaderP;}
262  inline GrpIterator GrpBegin();
263  inline GrpIterator GrpEnd();
264  inline PkgIterator PkgBegin();
265  inline PkgIterator PkgEnd();
266  inline PkgFileIterator FileBegin();
267  inline PkgFileIterator FileEnd();
268  inline RlsFileIterator RlsFileBegin();
269  inline RlsFileIterator RlsFileEnd();
270 
271  inline bool MultiArchCache() const { return MultiArchEnabled; }
272  inline char const * NativeArch();
273 
274  // Make me a function
276 
277  // Converters
278  static const char *CompTypeDeb(unsigned char Comp) APT_PURE;
279  static const char *CompType(unsigned char Comp) APT_PURE;
280  static const char *DepType(unsigned char Dep);
281 
282  pkgCache(MMap *Map,bool DoMap = true);
283  virtual ~~pkgCache();
284 
285 private:
286  void * const d;
288 };
289  /*}}}*/
290 // Header structure /*{{{*/
292 {
293  /** \brief Signature information
294 
295  This must contain the hex value 0x98FE76DC which is designed to
296  verify that the system loading the image has the same byte order
297  and byte size as the system saving the image */
298  uint32_t Signature;
299  /** These contain the version of the cache file */
302  /** \brief indicates if the cache should be erased
303 
304  Dirty is true if the cache file was opened for reading, the client
305  expects to have written things to it and have not fully synced it.
306  The file should be erased and rebuilt if it is true. */
307  bool Dirty;
308 
309  /** \brief Size of structure values
310 
311  All *Sz variables contains the sizeof() that particular structure.
312  It is used as an extra consistency check on the structure of the file.
313 
314  If any of the size values do not exactly match what the client expects
315  then the client should refuse the load the file. */
316  uint16_t HeaderSz;
328 
329  /** \brief Structure counts
330 
331  These indicate the number of each structure contained in the cache.
332  PackageCount is especially useful for generating user state structures.
333  See Package::Id for more info. */
345 
346  /** \brief index of the first PackageFile structure
347 
348  The PackageFile structures are singly linked lists that represent
349  all package files that have been merged into the cache. */
351  /** \brief index of the first ReleaseFile structure */
353 
354  /** \brief String representing the version system used */
356  /** \brief native architecture the cache was built against */
358  /** \brief all architectures the cache was built against */
360  /** \brief The maximum size of a raw entry from the original Package file */
362  /** \brief The maximum size of a raw entry from the original Translation file */
364 
365  /** \brief The Pool structures manage the allocation pools that the generator uses
366 
367  Start indicates the first byte of the pool, Count is the number of objects
368  remaining in the pool and ItemSize is the structure size (alignment factor)
369  of the pool. An ItemSize of 0 indicates the pool is empty. There should be
370  twice the number of pools as there are non-private structure types. The generator
371  stores this information so future additions can make use of any unused pool
372  blocks. */
374 
375  /** \brief hash tables providing rapid group/package name lookup
376 
377  Each group/package name is inserted into a hash table using pkgCache::Hash(const &string)
378  By iterating over each entry in the hash table it is possible to iterate over
379  the entire list of packages. Hash Collisions are handled with a singly linked
380  list of packages based at the hash item. The linked list contains only
381  packages that match the hashing function.
382  In the PkgHashTable is it possible that multiple packages have the same name -
383  these packages are stored as a sequence in the list.
384  The size of both tables is the same. */
385  uint32_t HashTableSize;
386  uint32_t GetHashTableSize() const { return HashTableSize; }
387  void SetHashTableSize(unsigned int const sz) { HashTableSize = sz; }
390 
391 #ifdef APT_COMPILING_APT
392  map_pointer<Group> * GrpHashTableP() const { return (map_pointer<Group>*) (this + 1); }
393  map_pointer<Package> * PkgHashTableP() const { return reinterpret_cast<map_pointer<Package> *>(GrpHashTableP() + GetHashTableSize()); }
394 #endif
395 
396  /** \brief Hash of the file (TODO: Rename) */
398 
399  bool CheckSizes(Header &Against) const APT_PURE;
400  Header();
401 };
402  /*}}}*/
403 // Group structure /*{{{*/
404 /** \brief groups architecture depending packages together
405 
406  On or more packages with the same name form a group, so we have
407  a simple way to access a package built for different architectures
408  Group exists in a singly linked list of group records starting at
409  the hash index of the name in the pkgCache::Header::GrpHashTable
410 
411  They also act as a representation of source packages, allowing you to
412  iterate over all binaries produced by a source package.
413  */
415 {
416  /** \brief Name of the group */
418 
419  // Linked List
420  /** \brief Link to the first package which belongs to the group */
422  /** \brief Link to the last package which belongs to the group */
424 
425  /** \brief Link to the next Group */
427  /** \brief unique sequel ID */
429 
430  /** \brief List of binary produces by source package with this name. */
432 
433  /** \brief Private pointer */
435 };
436  /*}}}*/
437 // Package structure /*{{{*/
438 /** \brief contains information for a single unique package
439 
440  There can be any number of versions of a given package.
441  Package exists in a singly linked list of package records starting at
442  the hash index of the name in the pkgCache::Header::PkgHashTable
443 
444  A package can be created for every architecture so package names are
445  not unique, but it is guaranteed that packages with the same name
446  are sequencel ordered in the list. Packages with the same name can be
447  accessed with the Group.
448 */
450 {
451  /** \brief Architecture of the package */
453  /** \brief Base of a singly linked list of versions
454 
455  Each structure represents a unique version of the package.
456  The version structures contain links into PackageFile and the
457  original text file as well as detailed information about the size
458  and dependencies of the specific package. In this way multiple
459  versions of a package can be cleanly handled by the system.
460  Furthermore, this linked list is guaranteed to be sorted
461  from Highest version to lowest version with no duplicate entries. */
463  /** \brief index to the installed version */
465  /** \brief index of the group this package belongs to */
467 
468  // Linked list
469  /** \brief Link to the next package in the same bucket */
471  /** \brief List of all dependencies on this package */
473  /** \brief List of all "packages" this package provide */
475 
476  // Install/Remove/Purge etc
477  /** \brief state that the user wishes the package to be in */
479  /** \brief installation state of the package
480 
481  This should be "ok" but in case the installation failed
482  it will be different.
483  */
485  /** \brief indicates if the package is installed */
487 
488  /** \brief unique sequel ID
489 
490  ID is a unique value from 0 to Header->PackageCount assigned by the generator.
491  This allows clients to create an array of size PackageCount and use it to store
492  state information for the package map. For instance the status file emitter uses
493  this to track which packages have been emitted already. */
495  /** \brief some useful indicators of the package's state */
497 
498  /** \brief Private pointer */
500 };
501  /*}}}*/
502 // Release File structure /*{{{*/
503 /** \brief stores information about the release files used to generate the cache
504 
505  PackageFiles reference ReleaseFiles as we need to keep record of which
506  version belongs to which release e.g. for pinning. */
508 {
509  /** \brief physical disk file that this ReleaseFile represents */
511  /** \brief the release information
512 
513  Please see the files document for a description of what the
514  release information means. */
520  /** \brief The site the index file was fetched from */
522 
523  /** \brief Size of the file
524 
525  Used together with the modification time as a
526  simple check to ensure that the Packages
527  file has not been altered since Cache generation. */
529  /** \brief Modification time for the file */
530  time_t mtime;
531 
532  /** @TODO document PackageFile::Flags */
534 
535  // Linked list
536  /** \brief Link to the next ReleaseFile in the Cache */
538  /** \brief unique sequel ID */
540 
541  /** \brief Private pointer */
543 };
544  /*}}}*/
545 // Package File structure /*{{{*/
546 /** \brief stores information about the files used to generate the cache
547 
548  Package files are referenced by Version structures to be able to know
549  after the generation still from which Packages file includes this Version
550  as we need this information later on e.g. for pinning. */
552 {
553  /** \brief physical disk file that this PackageFile represents */
555  /** \brief the release information */
557 
560 
561  /** \brief indicates what sort of index file this is
562 
563  @TODO enumerate at least the possible indexes */
565  /** \brief Size of the file
566 
567  Used together with the modification time as a
568  simple check to ensure that the Packages
569  file has not been altered since Cache generation. */
571  /** \brief Modification time for the file */
572  time_t mtime;
573 
574  /** @TODO document PackageFile::Flags */
576 
577  // Linked list
578  /** \brief Link to the next PackageFile in the Cache */
580  /** \brief unique sequel ID */
582 
583  /** \brief Private pointer */
585 };
586  /*}}}*/
587 // VerFile structure /*{{{*/
588 /** \brief associates a version with a PackageFile
589 
590  This allows a full description of all Versions in all files
591  (and hence all sources) under consideration. */
593 {
594  /** \brief index of the package file that this version was found in */
596  /** \brief next step in the linked list */
598  /** \brief position in the package file */
599  map_filesize_t Offset; // File offset
600  /** @TODO document pkgCache::VerFile::Size */
602 };
603  /*}}}*/
604 // DescFile structure /*{{{*/
605 /** \brief associates a description with a Translation file */
607 {
608  /** \brief index of the file that this description was found in */
610  /** \brief next step in the linked list */
612  /** \brief position in the file */
613  map_filesize_t Offset; // File offset
614  /** @TODO document pkgCache::DescFile::Size */
616 };
617  /*}}}*/
618 // Version structure /*{{{*/
619 /** \brief information for a single version of a package
620 
621  The version list is always sorted from highest version to lowest
622  version by the generator. Equal version numbers are either merged
623  or handled as separate versions based on the Hash value. */
625 {
626  struct Extra;
627 
628  /** \brief complete version string */
630  /** \brief section this version is filled in */
632  /** \brief source package name this version comes from
633  Always contains the name, even if it is the same as the binary name */
635  /** \brief source version this version comes from
636  Always contains the version string, even if it is the same as the binary version */
638 
639  /** \brief Multi-Arch capabilities of a package version */
640  enum VerMultiArch { No = 0, /*!< is the default and doesn't trigger special behaviour */
641  All = (1<<0), /*!< will cause that Ver.Arch() will report "all" */
642  Foreign = (1<<1), /*!< can satisfy dependencies in another architecture */
643  Same = (1<<2), /*!< can be co-installed with itself from other architectures */
644  Allowed = (1<<3), /*!< other packages are allowed to depend on thispkg:any */
647 
648  /** \brief stores the MultiArch capabilities of this version
649 
650  Flags used are defined in pkgCache::Version::VerMultiArch
651  */
653 
654  /** \brief references all the PackageFile's that this version came from
655 
656  FileList can be used to determine what distribution(s) the Version
657  applies to. If FileList is 0 then this is a blank version.
658  The structure should also have a 0 in all other fields excluding
659  pkgCache::Version::VerStr and Possibly pkgCache::Version::NextVer. */
661  /** \brief next (lower or equal) version in the linked list */
663  /** \brief next description in the linked list */
665  /** \brief base of the dependency list */
667  /** \brief links to the owning package
668 
669  This allows reverse dependencies to determine the package */
671  /** \brief list of pkgCache::Provides */
673 
674  /** \brief archive size for this version
675 
676  For Debian this is the size of the .deb file. */
677  map_filesize_t Size; // These are the .deb size
678  /** \brief uncompressed size for this version */
680  /** \brief characteristic value representing this version
681 
682  No two packages in existence should have the same VerStr
683  and Hash with different contents. */
684  uint32_t Hash;
685  /** \brief unique sequel ID */
687  /** \brief parsed priority value */
689  /** \brief next version in the source package (might be different binary) */
691 
692  /** \brief Private pointer */
694 };
695 
696 #ifdef APT_COMPILING_APT
697 /// \brief Extra information for packages. APT-internal use only.
698 struct pkgCache::Version::Extra
699 {
700  uint8_t PhasedUpdatePercentage;
701 };
702 #endif
703  /*}}}*/
704 // Description structure /*{{{*/
705 /** \brief datamember of a linked list of available description for a version */
707 {
708  /** \brief Language code of this description (translation)
709 
710  If the value has a 0 length then this is read using the Package
711  file else the Translation-CODE file is used. */
713  /** \brief MD5sum of the original description
714 
715  Used to map Translations of a description to a version
716  and to check that the Translation is up-to-date. */
718 
719  /** @TODO document pkgCache::Description::FileList */
721  /** \brief next translation for this description */
723  /** \brief the text is a description of this package */
725 
726  /** \brief unique sequel ID */
728 };
729  /*}}}*/
730 // Dependency structure /*{{{*/
731 /** \brief information for a single dependency record
732 
733  The records are split up like this to ease processing by the client.
734  The base of the linked list is pkgCache::Version::DependsList.
735  All forms of dependencies are recorded here including Depends,
736  Recommends, Suggests, Enhances, Conflicts, Replaces and Breaks. */
738 {
739  /** \brief string of the version the dependency is applied against */
741  /** \brief index of the package this depends applies to
742 
743  The generator will - if the package does not already exist -
744  create a blank (no version records) package. */
746 
747  /** \brief Dependency type - Depends, Recommends, Conflicts, etc */
749  /** \brief comparison operator specified on the depends line
750 
751  If the high bit is set then it is a logical OR with the previous record. */
753 
755 };
757 {
759  /** \brief version of the package which has the depends */
761  /** \brief next reverse dependency of this package */
763  /** \brief next dependency of this version */
765 
766  /** \brief unique sequel ID */
768 };
769  /*}}}*/
770 // Provides structure /*{{{*/
771 /** \brief handles virtual packages
772 
773  When a Provides: line is encountered a new provides record is added
774  associating the package with a virtual package name.
775  The provides structures are linked off the package structures.
776  This simplifies the analysis of dependencies and other aspects A provides
777  refers to a specific version of a specific package, not all versions need to
778  provide that provides.*/
780 {
781  /** \brief index of the package providing this */
783  /** \brief index of the version this provide line applies to */
785  /** \brief version in the provides line (if any)
786 
787  This version allows dependencies to depend on specific versions of a
788  Provides, as well as allowing Provides to override existing packages. */
791  /** \brief next provides (based of package) */
793  /** \brief next provides (based of version) */
795 };
796  /*}}}*/
797 
798 inline char const * pkgCache::NativeArch()
799  { return StrP + HeaderP->Architecture; }
800 
801 #include <apt-pkg/cacheiterators.h>
802 
804  {
805  return GrpIterator(*this);
806  }
808  {
809  return GrpIterator(*this, GrpP);}
811  {return PkgIterator(*this);}
813  {return PkgIterator(*this,PkgP);}
815  {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);}
817  {return PkgFileIterator(*this,PkgFileP);}
819  {return RlsFileIterator(*this,RlsFileP + HeaderP->RlsFileList);}
821  {return RlsFileIterator(*this,RlsFileP);}
822 
823 
824 // Oh I wish for Real Name Space Support
825 class pkgCache::Namespace /*{{{*/
826 {
827  public:
843 };
844  /*}}}*/
845 #undef __PKGLIB_IN_PKGCACHE_H
846 #endif
Simple subset of std::string_view from C++17.
Definition: string_view.h:27
Definition: mmap.h:41
bool Sync()
Definition: mmap.cc:161
void * Data()
Definition: mmap.h:63
unsigned long long Size()
Definition: mmap.h:64
uint32_t val
Definition: pkgcache.h:99
map_pointer(uint32_t n) noexcept
Definition: pkgcache.h:103
map_pointer(std::nullptr_t) noexcept
Definition: pkgcache.h:102
map_pointer() noexcept
Definition: pkgcache.h:101
pkgCache::Description Description
Definition: pkgcache.h:838
pkgCache::Package Package
Definition: pkgcache.h:839
pkgCache::Dep Dep
Definition: pkgcache.h:841
pkgCache::Header Header
Definition: pkgcache.h:840
pkgCache::Flag Flag
Definition: pkgcache.h:842
pkgCache::VerFileIterator VerFileIterator
Definition: pkgcache.h:836
pkgCache::DescIterator DescIterator
Definition: pkgcache.h:831
pkgCache::PrvIterator PrvIterator
Definition: pkgcache.h:833
pkgCache::PkgIterator PkgIterator
Definition: pkgcache.h:829
pkgCache::VerIterator VerIterator
Definition: pkgcache.h:830
pkgCache::PkgFileIterator PkgFileIterator
Definition: pkgcache.h:835
pkgCache::DepIterator DepIterator
Definition: pkgcache.h:832
pkgCache::Version Version
Definition: pkgcache.h:837
pkgCache::GrpIterator GrpIterator
Definition: pkgcache.h:828
pkgCache::RlsFileIterator RlsFileIterator
Definition: pkgcache.h:834
RlsFileIterator RlsFileBegin()
Definition: pkgcache.h:818
bool Sync()
Definition: pkgcache.h:237
map_id_t Hash(APT::StringView S) const
Definition: pkgcache.h:242
Provides * ProvideP
Definition: pkgcache.h:230
PkgFileIterator FileEnd()
Definition: pkgcache.h:816
ReleaseFile * RlsFileP
Definition: pkgcache.h:226
char const * NativeArch()
Definition: pkgcache.h:798
Dependency * DepP
Definition: pkgcache.h:231
PkgIterator PkgEnd()
Definition: pkgcache.h:812
RlsFileIterator RlsFileEnd()
Definition: pkgcache.h:820
DependencyData * DepDataP
Definition: pkgcache.h:232
Package * PkgP
Definition: pkgcache.h:223
pkgVersioningSystem * VS
Definition: pkgcache.h:275
Version * VerP
Definition: pkgcache.h:228
Description * DescP
Definition: pkgcache.h:229
Group * GrpP
Definition: pkgcache.h:222
PkgFileIterator FileBegin()
Definition: pkgcache.h:814
GrpIterator GrpEnd()
Definition: pkgcache.h:807
GrpIterator GrpBegin()
Definition: pkgcache.h:803
DescFile * DescFileP
Definition: pkgcache.h:225
Header * HeaderP
Definition: pkgcache.h:221
void * DataEnd()
Definition: pkgcache.h:239
MMap & Map
Definition: pkgcache.h:215
char * StrP
Definition: pkgcache.h:233
MMap & GetMap()
Definition: pkgcache.h:238
PkgIterator PkgBegin()
Definition: pkgcache.h:810
bool MultiArchEnabled
Definition: pkgcache.h:287
PackageFile * PkgFileP
Definition: pkgcache.h:227
APT::StringView ViewString(map_stringitem_t idx) const
Definition: pkgcache.h:254
VerFile * VerFileP
Definition: pkgcache.h:224
void *const d
Definition: pkgcache.h:286
std::string CacheFile
Definition: pkgcache.h:214
Header & Head()
Definition: pkgcache.h:261
bool MultiArchCache() const
Definition: pkgcache.h:271
#define APT_PURE
Definition: macros.h:56
#define APT_PUBLIC
Definition: macros.h:77
#define APT_HIDDEN
Definition: macros.h:78
bool operator==(map_pointer< T > u, map_pointer< T > m)
Definition: pkgcache.h:109
T * operator+(T *p, map_pointer< T > m)
Definition: pkgcache.h:108
uint8_t map_number_t
Definition: pkgcache.h:122
uint32_t map_id_t
Definition: pkgcache.h:93
uint64_t map_filesize_t
Definition: pkgcache.h:89
uint32_t operator-(map_pointer< T > u, map_pointer< T > m)
Definition: pkgcache.h:113
uint32_t map_filesize_small_t
Definition: pkgcache.h:91
uint8_t map_flags_t
Definition: pkgcache.h:121
uint16_t map_fileid_t
Definition: pkgcache.h:95
bool operator<(map_pointer< T > u, map_pointer< T > m)
Definition: pkgcache.h:111
bool operator>(map_pointer< T > u, map_pointer< T > m)
Definition: pkgcache.h:112
map_pointer< char > map_stringitem_t
Definition: pkgcache.h:118
bool operator!=(map_pointer< T > u, map_pointer< T > m)
Definition: pkgcache.h:110
bool Depends(CommandLine &CmdL)
DepCompareOp
available compare operators
Definition: pkgcache.h:172
@ MultiArchImplicit
Definition: pkgcache.h:175
information for a single dependency record
Definition: pkgcache.h:738
map_flags_t CompareOp
comparison operator specified on the depends line
Definition: pkgcache.h:752
map_stringitem_t Version
string of the version the dependency is applied against
Definition: pkgcache.h:740
map_pointer< pkgCache::Package > Package
index of the package this depends applies to
Definition: pkgcache.h:745
map_pointer< DependencyData > NextData
Definition: pkgcache.h:754
map_number_t Type
Dependency type - Depends, Recommends, Conflicts, etc.
Definition: pkgcache.h:748
map_pointer< Dependency > NextRevDepends
next reverse dependency of this package
Definition: pkgcache.h:762
map_pointer< Dependency > NextDepends
next dependency of this version
Definition: pkgcache.h:764
map_pointer< pkgCache::DependencyData > DependencyData
Definition: pkgcache.h:758
map_pointer< Version > ParentVer
version of the package which has the depends
Definition: pkgcache.h:760
map_id_t ID
unique sequel ID
Definition: pkgcache.h:767
associates a description with a Translation file
Definition: pkgcache.h:607
map_pointer< DescFile > NextFile
next step in the linked list
Definition: pkgcache.h:611
map_filesize_t Offset
position in the file
Definition: pkgcache.h:613
map_filesize_t Size
Definition: pkgcache.h:615
map_pointer< PackageFile > File
index of the file that this description was found in
Definition: pkgcache.h:609
datamember of a linked list of available description for a version
Definition: pkgcache.h:707
map_pointer< Description > NextDesc
next translation for this description
Definition: pkgcache.h:722
map_pointer< Package > ParentPkg
the text is a description of this package
Definition: pkgcache.h:724
map_stringitem_t md5sum
MD5sum of the original description.
Definition: pkgcache.h:717
map_id_t ID
unique sequel ID
Definition: pkgcache.h:727
map_pointer< DescFile > FileList
Definition: pkgcache.h:720
map_stringitem_t language_code
Language code of this description (translation)
Definition: pkgcache.h:712
groups architecture depending packages together
Definition: pkgcache.h:415
map_stringitem_t Name
Name of the group.
Definition: pkgcache.h:417
map_pointer< Group > Next
Link to the next Group.
Definition: pkgcache.h:426
map_pointer< Version > VersionsInSource
List of binary produces by source package with this name.
Definition: pkgcache.h:431
map_pointer< Package > FirstPackage
Link to the first package which belongs to the group.
Definition: pkgcache.h:421
map_pointer< Package > LastPackage
Link to the last package which belongs to the group.
Definition: pkgcache.h:423
map_pointer< void > d
Private pointer.
Definition: pkgcache.h:434
map_id_t ID
unique sequel ID
Definition: pkgcache.h:428
uint32_t GetHashTableSize() const
Definition: pkgcache.h:386
uint32_t HashTableSize
hash tables providing rapid group/package name lookup
Definition: pkgcache.h:385
map_id_t ProvidesCount
Definition: pkgcache.h:344
map_id_t DependsDataCount
Definition: pkgcache.h:339
map_number_t PackageSz
Definition: pkgcache.h:318
map_number_t DescFileSz
Definition: pkgcache.h:327
map_number_t MajorVersion
Definition: pkgcache.h:300
bool CheckSizes(Header &Against) const APT_PURE
Definition: pkgcache.cc:106
uint32_t Signature
Signature information.
Definition: pkgcache.h:298
map_stringitem_t GetArchitectures() const
Definition: pkgcache.h:388
map_number_t GroupSz
Definition: pkgcache.h:317
map_fileid_t DescFileCount
Definition: pkgcache.h:343
DynamicMMap::Pool Pools[2 *12]
The Pool structures manage the allocation pools that the generator uses.
Definition: pkgcache.h:373
void SetHashTableSize(unsigned int const sz)
Definition: pkgcache.h:387
map_number_t ReleaseFileSz
Definition: pkgcache.h:319
map_fileid_t ReleaseFileCount
Definition: pkgcache.h:340
map_filesize_small_t CacheFileSize
Hash of the file (TODO: Rename)
Definition: pkgcache.h:397
map_number_t PackageFileSz
Definition: pkgcache.h:320
map_id_t DescriptionCount
Definition: pkgcache.h:337
map_number_t VersionSz
Definition: pkgcache.h:321
map_number_t DescriptionSz
Definition: pkgcache.h:322
map_number_t ProvidesSz
Definition: pkgcache.h:325
uint16_t HeaderSz
Size of structure values.
Definition: pkgcache.h:316
map_stringitem_t VerSysName
String representing the version system used.
Definition: pkgcache.h:355
map_filesize_t MaxVerFileSize
The maximum size of a raw entry from the original Package file.
Definition: pkgcache.h:361
map_number_t VerFileSz
Definition: pkgcache.h:326
map_id_t VersionCount
Definition: pkgcache.h:336
void SetArchitectures(map_stringitem_t const idx)
Definition: pkgcache.h:389
map_number_t DependencyDataSz
Definition: pkgcache.h:324
map_filesize_t MaxDescFileSize
The maximum size of a raw entry from the original Translation file.
Definition: pkgcache.h:363
map_pointer< ReleaseFile > RlsFileList
index of the first ReleaseFile structure
Definition: pkgcache.h:352
map_id_t PackageCount
Definition: pkgcache.h:335
map_fileid_t VerFileCount
Definition: pkgcache.h:342
map_stringitem_t Architectures
all architectures the cache was built against
Definition: pkgcache.h:359
map_stringitem_t Architecture
native architecture the cache was built against
Definition: pkgcache.h:357
map_number_t DependencySz
Definition: pkgcache.h:323
map_fileid_t PackageFileCount
Definition: pkgcache.h:341
map_id_t DependsCount
Definition: pkgcache.h:338
map_number_t MinorVersion
Definition: pkgcache.h:301
map_id_t GroupCount
Structure counts.
Definition: pkgcache.h:334
map_pointer< PackageFile > FileList
index of the first PackageFile structure
Definition: pkgcache.h:350
bool Dirty
indicates if the cache should be erased
Definition: pkgcache.h:307
stores information about the files used to generate the cache
Definition: pkgcache.h:552
map_stringitem_t Component
Definition: pkgcache.h:558
map_pointer< PackageFile > NextFile
Link to the next PackageFile in the Cache.
Definition: pkgcache.h:579
map_fileid_t ID
unique sequel ID
Definition: pkgcache.h:581
time_t mtime
Modification time for the file.
Definition: pkgcache.h:572
map_stringitem_t FileName
physical disk file that this PackageFile represents
Definition: pkgcache.h:554
map_flags_t Flags
Definition: pkgcache.h:575
map_stringitem_t IndexType
indicates what sort of index file this is
Definition: pkgcache.h:564
map_filesize_t Size
Size of the file.
Definition: pkgcache.h:570
map_pointer< void > d
Private pointer.
Definition: pkgcache.h:584
map_stringitem_t Architecture
Definition: pkgcache.h:559
map_pointer< ReleaseFile > Release
the release information
Definition: pkgcache.h:556
contains information for a single unique package
Definition: pkgcache.h:450
map_pointer< Dependency > RevDepends
List of all dependencies on this package.
Definition: pkgcache.h:472
map_number_t CurrentState
indicates if the package is installed
Definition: pkgcache.h:486
map_stringitem_t Arch
Architecture of the package.
Definition: pkgcache.h:452
map_pointer< Version > VersionList
Base of a singly linked list of versions.
Definition: pkgcache.h:462
map_number_t InstState
installation state of the package
Definition: pkgcache.h:484
map_pointer< pkgCache::Group > Group
index of the group this package belongs to
Definition: pkgcache.h:466
map_pointer< Version > CurrentVer
index to the installed version
Definition: pkgcache.h:464
map_flags_t Flags
some useful indicators of the package's state
Definition: pkgcache.h:496
map_pointer< Package > NextPackage
Link to the next package in the same bucket.
Definition: pkgcache.h:470
map_number_t SelectedState
state that the user wishes the package to be in
Definition: pkgcache.h:478
map_pointer< void > d
Private pointer.
Definition: pkgcache.h:499
map_pointer< Provides > ProvidesList
List of all "packages" this package provide.
Definition: pkgcache.h:474
map_id_t ID
unique sequel ID
Definition: pkgcache.h:494
handles virtual packages
Definition: pkgcache.h:780
map_pointer< Provides > NextPkgProv
next provides (based of version)
Definition: pkgcache.h:794
map_pointer< pkgCache::Version > Version
index of the version this provide line applies to
Definition: pkgcache.h:784
map_flags_t Flags
Definition: pkgcache.h:790
map_pointer< Package > ParentPkg
index of the package providing this
Definition: pkgcache.h:782
map_pointer< Provides > NextProvides
next provides (based of package)
Definition: pkgcache.h:792
map_stringitem_t ProvideVersion
version in the provides line (if any)
Definition: pkgcache.h:789
stores information about the release files used to generate the cache
Definition: pkgcache.h:508
map_stringitem_t Archive
the release information
Definition: pkgcache.h:515
map_fileid_t ID
unique sequel ID
Definition: pkgcache.h:539
map_stringitem_t Site
The site the index file was fetched from.
Definition: pkgcache.h:521
map_pointer< ReleaseFile > NextFile
Link to the next ReleaseFile in the Cache.
Definition: pkgcache.h:537
time_t mtime
Modification time for the file.
Definition: pkgcache.h:530
map_stringitem_t Origin
Definition: pkgcache.h:518
map_stringitem_t Codename
Definition: pkgcache.h:516
map_stringitem_t FileName
physical disk file that this ReleaseFile represents
Definition: pkgcache.h:510
map_flags_t Flags
Definition: pkgcache.h:533
map_stringitem_t Label
Definition: pkgcache.h:519
map_filesize_t Size
Size of the file.
Definition: pkgcache.h:528
map_stringitem_t Version
Definition: pkgcache.h:517
map_pointer< void > d
Private pointer.
Definition: pkgcache.h:542
VerPriority
priority of a package version
Definition: pkgcache.h:185
associates a version with a PackageFile
Definition: pkgcache.h:593
map_pointer< VerFile > NextFile
next step in the linked list
Definition: pkgcache.h:597
map_filesize_t Offset
position in the package file
Definition: pkgcache.h:599
map_filesize_t Size
Definition: pkgcache.h:601
map_pointer< PackageFile > File
index of the package file that this version was found in
Definition: pkgcache.h:595
information for a single version of a package
Definition: pkgcache.h:625
map_number_t MultiArch
stores the MultiArch capabilities of this version
Definition: pkgcache.h:652
map_stringitem_t VerStr
complete version string
Definition: pkgcache.h:626
map_number_t Priority
parsed priority value
Definition: pkgcache.h:688
map_pointer< Version > NextVer
next (lower or equal) version in the linked list
Definition: pkgcache.h:662
map_stringitem_t Section
section this version is filled in
Definition: pkgcache.h:631
map_stringitem_t SourcePkgName
source package name this version comes from Always contains the name, even if it is the same as the b...
Definition: pkgcache.h:634
uint32_t Hash
characteristic value representing this version
Definition: pkgcache.h:684
map_filesize_t InstalledSize
uncompressed size for this version
Definition: pkgcache.h:679
VerMultiArch
Multi-Arch capabilities of a package version.
Definition: pkgcache.h:640
map_filesize_t Size
archive size for this version
Definition: pkgcache.h:677
map_pointer< Package > ParentPkg
links to the owning package
Definition: pkgcache.h:670
map_pointer< Version > NextInSource
next version in the source package (might be different binary)
Definition: pkgcache.h:690
map_pointer< Dependency > DependsList
base of the dependency list
Definition: pkgcache.h:666
map_pointer< Provides > ProvidesList
list of pkgCache::Provides
Definition: pkgcache.h:672
map_id_t ID
unique sequel ID
Definition: pkgcache.h:686
map_stringitem_t SourceVerStr
source version this version comes from Always contains the version string, even if it is the same as ...
Definition: pkgcache.h:637
map_pointer< Extra > d
Private pointer.
Definition: pkgcache.h:693
map_pointer< VerFile > FileList
references all the PackageFile's that this version came from
Definition: pkgcache.h:660
map_pointer< Description > DescriptionList
next description in the linked list
Definition: pkgcache.h:664