]> git.saurik.com Git - apt.git/blob - apt-pkg/pkgcache.h
fba6929826c1e21897ee1468509fa0be8e3b5304
[apt.git] / apt-pkg / pkgcache.h
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
77 #include <apt-pkg/mmap.h>
78 #include <apt-pkg/macros.h>
79
80 #include <string>
81 #include <time.h>
82 #include <stdint.h>
83
84 #ifndef APT_8_CLEANER_HEADERS
85 using std::string;
86 #endif
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 // relative pointer from cache start
97 typedef uint32_t map_pointer_t;
98 // same as the previous, but documented to be to a string item
99 typedef map_pointer_t map_stringitem_t;
100 // we have only a small amount of flags for each item
101 typedef uint8_t map_flags_t;
102 typedef uint8_t map_number_t;
103
104 class pkgVersioningSystem;
105 class pkgCache /*{{{*/
106 {
107 public:
108 // Cache element predeclarations
109 struct Header;
110 struct Group;
111 struct Package;
112 struct ReleaseFile;
113 struct PackageFile;
114 struct Version;
115 struct Description;
116 struct Provides;
117 struct Dependency;
118 struct DependencyData;
119 struct StringItem;
120 struct VerFile;
121 struct DescFile;
122
123 // Iterators
124 template<typename Str, typename Itr> class Iterator;
125 class GrpIterator;
126 class PkgIterator;
127 class VerIterator;
128 class DescIterator;
129 class DepIterator;
130 class PrvIterator;
131 class RlsFileIterator;
132 class PkgFileIterator;
133 class VerFileIterator;
134 class DescFileIterator;
135
136 class Namespace;
137
138 // These are all the constants used in the cache structures
139
140 // WARNING - if you change these lists you must also edit
141 // the stringification in pkgcache.cc and also consider whether
142 // the cache file will become incompatible.
143 struct Dep
144 {
145 enum DepType {Depends=1,PreDepends=2,Suggests=3,Recommends=4,
146 Conflicts=5,Replaces=6,Obsoletes=7,DpkgBreaks=8,Enhances=9};
147 /** \brief available compare operators
148
149 The lower 4 bits are used to indicate what operator is being specified and
150 the upper 4 bits are flags. OR indicates that the next package is
151 or'd with the current package. */
152 enum DepCompareOp {Or=0x10,NoOp=0,LessEq=0x1,GreaterEq=0x2,Less=0x3,
153 Greater=0x4,Equals=0x5,NotEquals=0x6};
154 };
155
156 struct State
157 {
158 /** \brief priority of a package version
159
160 Zero is used for unparsable or absent Priority fields. */
161 enum VerPriority {Required=1,Important=2,Standard=3,Optional=4,Extra=5};
162 enum PkgSelectedState {Unknown=0,Install=1,Hold=2,DeInstall=3,Purge=4};
163 enum PkgInstState {Ok=0,ReInstReq=1,HoldInst=2,HoldReInstReq=3};
164 enum PkgCurrentState {NotInstalled=0,UnPacked=1,HalfConfigured=2,
165 HalfInstalled=4,ConfigFiles=5,Installed=6,
166 TriggersAwaited=7,TriggersPending=8};
167 };
168
169 struct Flag
170 {
171 enum PkgFlags {Auto=(1<<0),Essential=(1<<3),Important=(1<<4)};
172 enum PkgFFlags {
173 NotSource=(1<<0), /*!< packages can't be fetched from here, e.g. dpkg/status file */
174 LocalSource=(1<<1), /*!< local sources can't and will not be verified by hashes */
175 NoPackages=(1<<2), /*!< the file includes no package records itself, but additions like Translations */
176 };
177 enum ReleaseFileFlags {
178 NotAutomatic=(1<<0), /*!< archive has a default pin of 1 */
179 ButAutomaticUpgrades=(1<<1), /*!< (together with the previous) archive has a default pin of 100 */
180 };
181 };
182
183 protected:
184
185 // Memory mapped cache file
186 std::string CacheFile;
187 MMap &Map;
188
189 map_id_t sHash(const std::string &S) const APT_PURE;
190 map_id_t sHash(const char *S) const APT_PURE;
191
192 public:
193
194 // Pointers to the arrays of items
195 Header *HeaderP;
196 Group *GrpP;
197 Package *PkgP;
198 VerFile *VerFileP;
199 DescFile *DescFileP;
200 ReleaseFile *RlsFileP;
201 PackageFile *PkgFileP;
202 Version *VerP;
203 Description *DescP;
204 Provides *ProvideP;
205 Dependency *DepP;
206 DependencyData *DepDataP;
207 APT_DEPRECATED StringItem *StringItemP;
208 char *StrP;
209
210 virtual bool ReMap(bool const &Errorchecks = true);
211 inline bool Sync() {return Map.Sync();}
212 inline MMap &GetMap() {return Map;}
213 inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();}
214
215 // String hashing function (512 range)
216 inline map_id_t Hash(const std::string &S) const {return sHash(S);}
217 inline map_id_t Hash(const char *S) const {return sHash(S);}
218
219 // Useful transformation things
220 const char *Priority(unsigned char Priority);
221
222 // Accessors
223 GrpIterator FindGrp(const std::string &Name);
224 PkgIterator FindPkg(const std::string &Name);
225 PkgIterator FindPkg(const std::string &Name, const std::string &Arch);
226
227 Header &Head() {return *HeaderP;}
228 inline GrpIterator GrpBegin();
229 inline GrpIterator GrpEnd();
230 inline PkgIterator PkgBegin();
231 inline PkgIterator PkgEnd();
232 inline PkgFileIterator FileBegin();
233 inline PkgFileIterator FileEnd();
234 inline RlsFileIterator RlsFileBegin();
235 inline RlsFileIterator RlsFileEnd();
236
237 inline bool MultiArchCache() const { return MultiArchEnabled; }
238 inline char const * NativeArch();
239
240 // Make me a function
241 pkgVersioningSystem *VS;
242
243 // Converters
244 static const char *CompTypeDeb(unsigned char Comp) APT_CONST;
245 static const char *CompType(unsigned char Comp) APT_CONST;
246 static const char *DepType(unsigned char Dep);
247
248 pkgCache(MMap *Map,bool DoMap = true);
249 virtual ~pkgCache();
250
251 private:
252 void * const d;
253 bool MultiArchEnabled;
254 APT_HIDDEN PkgIterator SingleArchFindPkg(const std::string &Name);
255 };
256 /*}}}*/
257 // Header structure /*{{{*/
258 struct pkgCache::Header
259 {
260 /** \brief Signature information
261
262 This must contain the hex value 0x98FE76DC which is designed to
263 verify that the system loading the image has the same byte order
264 and byte size as the system saving the image */
265 uint32_t Signature;
266 /** These contain the version of the cache file */
267 map_number_t MajorVersion;
268 map_number_t MinorVersion;
269 /** \brief indicates if the cache should be erased
270
271 Dirty is true if the cache file was opened for reading, the client
272 expects to have written things to it and have not fully synced it.
273 The file should be erased and rebuilt if it is true. */
274 bool Dirty;
275
276 /** \brief Size of structure values
277
278 All *Sz variables contains the sizeof() that particular structure.
279 It is used as an extra consistency check on the structure of the file.
280
281 If any of the size values do not exactly match what the client expects
282 then the client should refuse the load the file. */
283 uint16_t HeaderSz;
284 map_number_t GroupSz;
285 map_number_t PackageSz;
286 map_number_t ReleaseFileSz;
287 map_number_t PackageFileSz;
288 map_number_t VersionSz;
289 map_number_t DescriptionSz;
290 map_number_t DependencySz;
291 map_number_t DependencyDataSz;
292 map_number_t ProvidesSz;
293 map_number_t VerFileSz;
294 map_number_t DescFileSz;
295
296 /** \brief Structure counts
297
298 These indicate the number of each structure contained in the cache.
299 PackageCount is especially useful for generating user state structures.
300 See Package::Id for more info. */
301 map_id_t GroupCount;
302 map_id_t PackageCount;
303 map_id_t VersionCount;
304 map_id_t DescriptionCount;
305 map_id_t DependsCount;
306 map_id_t DependsDataCount;
307 map_fileid_t ReleaseFileCount;
308 map_fileid_t PackageFileCount;
309 map_fileid_t VerFileCount;
310 map_fileid_t DescFileCount;
311 map_id_t ProvidesCount;
312
313 /** \brief index of the first PackageFile structure
314
315 The PackageFile structures are singly linked lists that represent
316 all package files that have been merged into the cache. */
317 map_pointer_t FileList;
318 /** \brief index of the first ReleaseFile structure */
319 map_pointer_t RlsFileList;
320
321 /** \brief String representing the version system used */
322 map_pointer_t VerSysName;
323 /** \brief native architecture the cache was built against */
324 map_pointer_t Architecture;
325 /** \brief all architectures the cache was built against */
326 map_pointer_t Architectures;
327 /** \brief The maximum size of a raw entry from the original Package file */
328 map_filesize_t MaxVerFileSize;
329 /** \brief The maximum size of a raw entry from the original Translation file */
330 map_filesize_t MaxDescFileSize;
331
332 /** \brief The Pool structures manage the allocation pools that the generator uses
333
334 Start indicates the first byte of the pool, Count is the number of objects
335 remaining in the pool and ItemSize is the structure size (alignment factor)
336 of the pool. An ItemSize of 0 indicates the pool is empty. There should be
337 the same number of pools as there are structure types. The generator
338 stores this information so future additions can make use of any unused pool
339 blocks. */
340 DynamicMMap::Pool Pools[12];
341
342 /** \brief hash tables providing rapid group/package name lookup
343
344 Each group/package name is inserted into a hash table using pkgCache::Hash(const &string)
345 By iterating over each entry in the hash table it is possible to iterate over
346 the entire list of packages. Hash Collisions are handled with a singly linked
347 list of packages based at the hash item. The linked list contains only
348 packages that match the hashing function.
349 In the PkgHashTable is it possible that multiple packages have the same name -
350 these packages are stored as a sequence in the list.
351 The size of both tables is the same. */
352 uint32_t HashTableSize;
353 uint32_t GetHashTableSize() const { return HashTableSize; }
354 void SetHashTableSize(unsigned int const sz) { HashTableSize = sz; }
355 map_pointer_t GetArchitectures() const { return Architectures; }
356 void SetArchitectures(map_pointer_t const idx) { Architectures = idx; }
357 map_pointer_t * PkgHashTableP() const { return (map_pointer_t*) (this + 1); }
358 map_pointer_t * GrpHashTableP() const { return PkgHashTableP() + GetHashTableSize(); }
359
360 /** \brief Size of the complete cache file */
361 map_filesize_small_t CacheFileSize;
362
363 bool CheckSizes(Header &Against) const APT_PURE;
364 Header();
365 };
366 /*}}}*/
367 // Group structure /*{{{*/
368 /** \brief groups architecture depending packages together
369
370 On or more packages with the same name form a group, so we have
371 a simple way to access a package built for different architectures
372 Group exists in a singly linked list of group records starting at
373 the hash index of the name in the pkgCache::Header::GrpHashTable */
374 struct pkgCache::Group
375 {
376 /** \brief Name of the group */
377 map_stringitem_t Name;
378
379 // Linked List
380 /** \brief Link to the first package which belongs to the group */
381 map_pointer_t FirstPackage; // Package
382 /** \brief Link to the last package which belongs to the group */
383 map_pointer_t LastPackage; // Package
384 /** \brief Link to the next Group */
385 map_pointer_t Next; // Group
386 /** \brief unique sequel ID */
387 map_id_t ID;
388
389 };
390 /*}}}*/
391 // Package structure /*{{{*/
392 /** \brief contains information for a single unique package
393
394 There can be any number of versions of a given package.
395 Package exists in a singly linked list of package records starting at
396 the hash index of the name in the pkgCache::Header::PkgHashTable
397
398 A package can be created for every architecture so package names are
399 not unique, but it is guaranteed that packages with the same name
400 are sequencel ordered in the list. Packages with the same name can be
401 accessed with the Group.
402 */
403 struct pkgCache::Package
404 {
405 /** \brief Name of the package
406 * Note that the access method Name() will remain. It is just this data member
407 * deprecated as this information is already stored and available via the
408 * associated Group – so it is wasting precious binary cache space */
409 APT_DEPRECATED map_stringitem_t Name;
410 /** \brief Architecture of the package */
411 map_stringitem_t Arch;
412 /** \brief Base of a singly linked list of versions
413
414 Each structure represents a unique version of the package.
415 The version structures contain links into PackageFile and the
416 original text file as well as detailed information about the size
417 and dependencies of the specific package. In this way multiple
418 versions of a package can be cleanly handled by the system.
419 Furthermore, this linked list is guaranteed to be sorted
420 from Highest version to lowest version with no duplicate entries. */
421 map_pointer_t VersionList; // Version
422 /** \brief index to the installed version */
423 map_pointer_t CurrentVer; // Version
424 /** \brief indicates nothing (consistently)
425 This field used to contain ONE section the package belongs to,
426 if those differs between versions it is a RANDOM one.
427 The Section() method tries to reproduce it, but the only sane
428 thing to do is use the Section field from the version! */
429 APT_DEPRECATED map_ptrloc Section; // StringItem
430 /** \brief index of the group this package belongs to */
431 map_pointer_t Group; // Group the Package belongs to
432
433 // Linked list
434 /** \brief Link to the next package in the same bucket */
435 map_pointer_t NextPackage; // Package
436 /** \brief List of all dependencies on this package */
437 map_pointer_t RevDepends; // Dependency
438 /** \brief List of all "packages" this package provide */
439 map_pointer_t ProvidesList; // Provides
440
441 // Install/Remove/Purge etc
442 /** \brief state that the user wishes the package to be in */
443 map_number_t SelectedState; // What
444 /** \brief installation state of the package
445
446 This should be "ok" but in case the installation failed
447 it will be different.
448 */
449 map_number_t InstState; // Flags
450 /** \brief indicates if the package is installed */
451 map_number_t CurrentState; // State
452
453 /** \brief unique sequel ID
454
455 ID is a unique value from 0 to Header->PackageCount assigned by the generator.
456 This allows clients to create an array of size PackageCount and use it to store
457 state information for the package map. For instance the status file emitter uses
458 this to track which packages have been emitted already. */
459 map_id_t ID;
460 /** \brief some useful indicators of the package's state */
461 map_flags_t Flags;
462 };
463 /*}}}*/
464 // Release File structure /*{{{*/
465 /** \brief stores information about the release files used to generate the cache
466
467 PackageFiles reference ReleaseFiles as we need to keep record of which
468 version belongs to which release e.g. for pinning. */
469 struct pkgCache::ReleaseFile
470 {
471 /** \brief physical disk file that this ReleaseFile represents */
472 map_stringitem_t FileName;
473 /** \brief the release information
474
475 Please see the files document for a description of what the
476 release information means. */
477 map_stringitem_t Archive;
478 map_stringitem_t Codename;
479 map_stringitem_t Version;
480 map_stringitem_t Origin;
481 map_stringitem_t Label;
482 /** \brief The site the index file was fetched from */
483 map_stringitem_t Site;
484
485 /** \brief Size of the file
486
487 Used together with the modification time as a
488 simple check to ensure that the Packages
489 file has not been altered since Cache generation. */
490 map_filesize_t Size;
491 /** \brief Modification time for the file */
492 time_t mtime;
493
494 /** @TODO document PackageFile::Flags */
495 map_flags_t Flags;
496
497 // Linked list
498 /** \brief Link to the next ReleaseFile in the Cache */
499 map_pointer_t NextFile;
500 /** \brief unique sequel ID */
501 map_fileid_t ID;
502 };
503 /*}}}*/
504 // Package File structure /*{{{*/
505 /** \brief stores information about the files used to generate the cache
506
507 Package files are referenced by Version structures to be able to know
508 after the generation still from which Packages file includes this Version
509 as we need this information later on e.g. for pinning. */
510 struct pkgCache::PackageFile
511 {
512 /** \brief physical disk file that this PackageFile represents */
513 map_stringitem_t FileName;
514 /** \brief the release information */
515 map_pointer_t Release;
516
517 map_stringitem_t Component;
518 map_stringitem_t Architecture;
519
520 /** \brief indicates what sort of index file this is
521
522 @TODO enumerate at least the possible indexes */
523 map_stringitem_t IndexType;
524 /** \brief Size of the file
525
526 Used together with the modification time as a
527 simple check to ensure that the Packages
528 file has not been altered since Cache generation. */
529 map_filesize_t Size;
530 /** \brief Modification time for the file */
531 time_t mtime;
532
533 /** @TODO document PackageFile::Flags */
534 map_flags_t Flags;
535
536 // Linked list
537 /** \brief Link to the next PackageFile in the Cache */
538 map_pointer_t NextFile; // PackageFile
539 /** \brief unique sequel ID */
540 map_fileid_t ID;
541 };
542 /*}}}*/
543 // VerFile structure /*{{{*/
544 /** \brief associates a version with a PackageFile
545
546 This allows a full description of all Versions in all files
547 (and hence all sources) under consideration. */
548 struct pkgCache::VerFile
549 {
550 /** \brief index of the package file that this version was found in */
551 map_pointer_t File; // PackageFile
552 /** \brief next step in the linked list */
553 map_pointer_t NextFile; // PkgVerFile
554 /** \brief position in the package file */
555 map_filesize_t Offset; // File offset
556 /** @TODO document pkgCache::VerFile::Size */
557 map_filesize_t Size;
558 };
559 /*}}}*/
560 // DescFile structure /*{{{*/
561 /** \brief associates a description with a Translation file */
562 struct pkgCache::DescFile
563 {
564 /** \brief index of the file that this description was found in */
565 map_pointer_t File; // PackageFile
566 /** \brief next step in the linked list */
567 map_pointer_t NextFile; // PkgVerFile
568 /** \brief position in the file */
569 map_filesize_t Offset; // File offset
570 /** @TODO document pkgCache::DescFile::Size */
571 map_filesize_t Size;
572 };
573 /*}}}*/
574 // Version structure /*{{{*/
575 /** \brief information for a single version of a package
576
577 The version list is always sorted from highest version to lowest
578 version by the generator. Equal version numbers are either merged
579 or handled as separate versions based on the Hash value. */
580 struct pkgCache::Version
581 {
582 /** \brief complete version string */
583 map_stringitem_t VerStr;
584 /** \brief section this version is filled in */
585 map_stringitem_t Section;
586 /** \brief source package name this version comes from
587 Always contains the name, even if it is the same as the binary name */
588 map_stringitem_t SourcePkgName;
589 /** \brief source version this version comes from
590 Always contains the version string, even if it is the same as the binary version */
591 map_stringitem_t SourceVerStr;
592
593 /** \brief Multi-Arch capabilities of a package version */
594 enum VerMultiArch { None = 0, /*!< is the default and doesn't trigger special behaviour */
595 All = (1<<0), /*!< will cause that Ver.Arch() will report "all" */
596 Foreign = (1<<1), /*!< can satisfy dependencies in another architecture */
597 Same = (1<<2), /*!< can be co-installed with itself from other architectures */
598 Allowed = (1<<3), /*!< other packages are allowed to depend on thispkg:any */
599 AllForeign = All | Foreign,
600 AllAllowed = All | Allowed };
601 /** \brief stores the MultiArch capabilities of this version
602
603 Flags used are defined in pkgCache::Version::VerMultiArch
604 */
605 map_number_t MultiArch;
606
607 /** \brief references all the PackageFile's that this version came from
608
609 FileList can be used to determine what distribution(s) the Version
610 applies to. If FileList is 0 then this is a blank version.
611 The structure should also have a 0 in all other fields excluding
612 pkgCache::Version::VerStr and Possibly pkgCache::Version::NextVer. */
613 map_pointer_t FileList; // VerFile
614 /** \brief next (lower or equal) version in the linked list */
615 map_pointer_t NextVer; // Version
616 /** \brief next description in the linked list */
617 map_pointer_t DescriptionList; // Description
618 /** \brief base of the dependency list */
619 map_pointer_t DependsList; // Dependency
620 /** \brief links to the owning package
621
622 This allows reverse dependencies to determine the package */
623 map_pointer_t ParentPkg; // Package
624 /** \brief list of pkgCache::Provides */
625 map_pointer_t ProvidesList; // Provides
626
627 /** \brief archive size for this version
628
629 For Debian this is the size of the .deb file. */
630 map_filesize_t Size; // These are the .deb size
631 /** \brief uncompressed size for this version */
632 map_filesize_t InstalledSize;
633 /** \brief characteristic value representing this version
634
635 No two packages in existence should have the same VerStr
636 and Hash with different contents. */
637 unsigned short Hash;
638 /** \brief unique sequel ID */
639 map_id_t ID;
640 /** \brief parsed priority value */
641 map_number_t Priority;
642 };
643 /*}}}*/
644 // Description structure /*{{{*/
645 /** \brief datamember of a linked list of available description for a version */
646 struct pkgCache::Description
647 {
648 /** \brief Language code of this description (translation)
649
650 If the value has a 0 length then this is read using the Package
651 file else the Translation-CODE file is used. */
652 map_stringitem_t language_code;
653 /** \brief MD5sum of the original description
654
655 Used to map Translations of a description to a version
656 and to check that the Translation is up-to-date. */
657 map_stringitem_t md5sum;
658
659 /** @TODO document pkgCache::Description::FileList */
660 map_pointer_t FileList; // DescFile
661 /** \brief next translation for this description */
662 map_pointer_t NextDesc; // Description
663 /** \brief the text is a description of this package */
664 map_pointer_t ParentPkg; // Package
665
666 /** \brief unique sequel ID */
667 map_id_t ID;
668 };
669 /*}}}*/
670 // Dependency structure /*{{{*/
671 /** \brief information for a single dependency record
672
673 The records are split up like this to ease processing by the client.
674 The base of the linked list is pkgCache::Version::DependsList.
675 All forms of dependencies are recorded here including Depends,
676 Recommends, Suggests, Enhances, Conflicts, Replaces and Breaks. */
677 struct pkgCache::DependencyData
678 {
679 /** \brief string of the version the dependency is applied against */
680 map_stringitem_t Version;
681 /** \brief index of the package this depends applies to
682
683 The generator will - if the package does not already exist -
684 create a blank (no version records) package. */
685 map_pointer_t Package; // Package
686
687 /** \brief Dependency type - Depends, Recommends, Conflicts, etc */
688 map_number_t Type;
689 /** \brief comparison operator specified on the depends line
690
691 If the high bit is set then it is a logical OR with the previous record. */
692 map_flags_t CompareOp;
693
694 map_pointer_t NextData;
695 };
696 struct pkgCache::Dependency
697 {
698 map_pointer_t DependencyData; // DependencyData
699 /** \brief version of the package which has the depends */
700 map_pointer_t ParentVer; // Version
701 /** \brief next reverse dependency of this package */
702 map_pointer_t NextRevDepends; // Dependency
703 /** \brief next dependency of this version */
704 map_pointer_t NextDepends; // Dependency
705
706 /** \brief unique sequel ID */
707 map_id_t ID;
708 };
709 /*}}}*/
710 // Provides structure /*{{{*/
711 /** \brief handles virtual packages
712
713 When a Provides: line is encountered a new provides record is added
714 associating the package with a virtual package name.
715 The provides structures are linked off the package structures.
716 This simplifies the analysis of dependencies and other aspects A provides
717 refers to a specific version of a specific package, not all versions need to
718 provide that provides.*/
719 struct pkgCache::Provides
720 {
721 /** \brief index of the package providing this */
722 map_pointer_t ParentPkg; // Package
723 /** \brief index of the version this provide line applies to */
724 map_pointer_t Version; // Version
725 /** \brief version in the provides line (if any)
726
727 This version allows dependencies to depend on specific versions of a
728 Provides, as well as allowing Provides to override existing packages.
729 This is experimental. Note that Debian doesn't allow versioned provides */
730 map_stringitem_t ProvideVersion;
731 /** \brief next provides (based of package) */
732 map_pointer_t NextProvides; // Provides
733 /** \brief next provides (based of version) */
734 map_pointer_t NextPkgProv; // Provides
735 };
736 /*}}}*/
737 // UNUSED StringItem structure /*{{{*/
738 struct APT_DEPRECATED pkgCache::StringItem
739 {
740 /** \brief string this refers to */
741 map_ptrloc String; // StringItem
742 /** \brief Next link in the chain */
743 map_ptrloc NextItem; // StringItem
744 };
745 /*}}}*/
746
747 inline char const * pkgCache::NativeArch()
748 { return StrP + HeaderP->Architecture; }
749
750 #include <apt-pkg/cacheiterators.h>
751
752 inline pkgCache::GrpIterator pkgCache::GrpBegin()
753 {return GrpIterator(*this);}
754 inline pkgCache::GrpIterator pkgCache::GrpEnd()
755 {return GrpIterator(*this,GrpP);}
756 inline pkgCache::PkgIterator pkgCache::PkgBegin()
757 {return PkgIterator(*this);}
758 inline pkgCache::PkgIterator pkgCache::PkgEnd()
759 {return PkgIterator(*this,PkgP);}
760 inline pkgCache::PkgFileIterator pkgCache::FileBegin()
761 {return PkgFileIterator(*this,PkgFileP + HeaderP->FileList);}
762 inline pkgCache::PkgFileIterator pkgCache::FileEnd()
763 {return PkgFileIterator(*this,PkgFileP);}
764 inline pkgCache::RlsFileIterator pkgCache::RlsFileBegin()
765 {return RlsFileIterator(*this,RlsFileP + HeaderP->RlsFileList);}
766 inline pkgCache::RlsFileIterator pkgCache::RlsFileEnd()
767 {return RlsFileIterator(*this,RlsFileP);}
768
769
770 // Oh I wish for Real Name Space Support
771 class pkgCache::Namespace /*{{{*/
772 {
773 public:
774 typedef pkgCache::GrpIterator GrpIterator;
775 typedef pkgCache::PkgIterator PkgIterator;
776 typedef pkgCache::VerIterator VerIterator;
777 typedef pkgCache::DescIterator DescIterator;
778 typedef pkgCache::DepIterator DepIterator;
779 typedef pkgCache::PrvIterator PrvIterator;
780 typedef pkgCache::RlsFileIterator RlsFileIterator;
781 typedef pkgCache::PkgFileIterator PkgFileIterator;
782 typedef pkgCache::VerFileIterator VerFileIterator;
783 typedef pkgCache::Version Version;
784 typedef pkgCache::Description Description;
785 typedef pkgCache::Package Package;
786 typedef pkgCache::Header Header;
787 typedef pkgCache::Dep Dep;
788 typedef pkgCache::Flag Flag;
789 };
790 /*}}}*/
791 #endif