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