cache.sgml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. <!doctype debiandoc system>
  2. <!-- -*- mode: sgml; mode: fold -*- -->
  3. <book>
  4. <title>APT Cache File Format</title>
  5. <author>Jason Gunthorpe <email>jgg@debian.org</email></author>
  6. <version>$Id: cache.sgml,v 1.2 1998/07/05 05:43:09 jgg Exp $</version>
  7. <abstract>
  8. This document describes the complete implementation and format of the APT
  9. Cache file. The APT Cache file is a way for APT to parse and store a
  10. large number of package files for display in the UI. It's primary design
  11. goal is to make display of a single package in the tree very fast by
  12. pre-linking important things like dependencies and provides.
  13. The specification doubles as documentation for one of the in-memory
  14. structures used by the package library and the APT GUI.
  15. </abstract>
  16. <copyright>
  17. Copyright &copy; Jason Gunthorpe, 1997-1998.
  18. <p>
  19. APT and this document are free software; you can redistribute them and/or
  20. modify them under the terms of the GNU General Public License as published
  21. by the Free Software Foundation; either version 2 of the License, or (at your
  22. option) any later version.
  23. <p>
  24. For more details, on Debian GNU/Linux systems, see the file
  25. /usr/doc/copyright/GPL for the full license.
  26. </copyright>
  27. <toc sect>
  28. <chapt>Introduction
  29. <!-- Purpose {{{ -->
  30. <!-- ===================================================================== -->
  31. <sect>Purpose
  32. <p>
  33. This document describes the implementation of an architecture
  34. dependent binary cache file. The goal of this cache file is two fold,
  35. firstly to speed loading and processing of the package file array and
  36. secondly to reduce memory consumption of the package file array.
  37. <p>
  38. The implementation is aimed at an environment with many primary package
  39. files, for instance someone that has a Package file for their CD-ROM, a
  40. Package file for the latest version of the distribution on the CD-ROM and a
  41. package file for the development version. Always present is the information
  42. contained in the status file which might be considered a separate package
  43. file.
  44. <p>
  45. Please understand, this is designed as a -CACHE FILE- it is not ment to be
  46. used on any system other than the one it was created for. It is not ment to
  47. be authoritative either, ie if a system crash or software failure occures it
  48. must be perfectly acceptable for the cache file to be in an inconsistant
  49. state. Furthermore at any time the cache file may be erased without losing
  50. any information.
  51. <p>
  52. Also the structures and storage layout is optimized for use by the APT
  53. GUI and may not be suitable for all purposes. However it should be possible
  54. to extend it with associate cache files that contain other information.
  55. <p>
  56. To keep memory use down the cache file only contains often used fields and
  57. fields that are inexepensive to store, the Package file has a full list of
  58. fields. Also the client may assume that all items are perfectly valid and
  59. need not perform checks against their correctness. Removal of information
  60. from the cache is possible, but blanks will be left in the file, and
  61. unused strings will also be present. The recommended implementation is to
  62. simply rebuild the cache each time any of the data files change. It is
  63. possible to add a new package file to the cache without any negative side
  64. effects.
  65. <sect1>Note on Pointer access
  66. <p>
  67. Every item in every structure is stored as the index to that structure.
  68. What this means is that once the files is mmaped every data access has to
  69. go through a fixup stage to get a real memory pointer. This is done
  70. by taking the index, multiplying it by the type size and then adding
  71. it to the start address of the memory block. This sounds complex, but
  72. in C it is a single array dereference. Because all items are aligned to
  73. their size and indexs are stored as multiples of the size of the structure
  74. the format is immediately portable to all possible architectures - BUT the
  75. generated files are -NOT-.
  76. <p>
  77. This scheme allows code like this to be written:
  78. <example>
  79. void *Map = mmap(...);
  80. Package *PkgList = (Package *)Map;
  81. Header *Head = (Header *)Map;
  82. char *Strings = (char *)Map;
  83. cout << (Strings + PkgList[Head->HashTable[0]]->Name) << endl;
  84. </example>
  85. <p>
  86. Notice the lack of casting or multiplication. The net result is to return
  87. the name of the first package in the first hash bucket, without error
  88. checks.
  89. <p>
  90. The generator uses allocation pools to group similarly sized structures in
  91. large blocks to eliminate any alignment overhead. The generator also
  92. assures that no structures overlap and all indexes are unique. Although
  93. at first glance it may seem like there is the potential for two structures
  94. to exist at the same point the generator never allows this to happen.
  95. (See the discussion of free space pools)
  96. <!-- }}} -->
  97. <chapt>Structures
  98. <!-- Header {{{ -->
  99. <!-- ===================================================================== -->
  100. <sect>Header
  101. <p>
  102. This is the first item in the file.
  103. <example>
  104. struct Header
  105. {
  106. // Signature information
  107. unsigned long Signature;
  108. short MajorVersion;
  109. short MinorVersion;
  110. bool Dirty;
  111. // Size of structure values
  112. unsigned short HeaderSz;
  113. unsigned short PackageSz;
  114. unsigned short PackageFileSz;
  115. unsigned short VersionSz;
  116. unsigned short DependencySz;
  117. unsigned short ProvidesSz;
  118. unsigned short VerFileSz;
  119. // Structure counts
  120. unsigned long PackageCount;
  121. unsigned long VersionCount;
  122. unsigned long DependsCount;
  123. unsigned long PackageFileCount;
  124. // Offsets
  125. unsigned long FileList; // PackageFile
  126. unsigned long StringList; // StringItem
  127. // Allocation pools
  128. struct
  129. {
  130. unsigned long ItemSize;
  131. unsigned long Start;
  132. unsigned long Count;
  133. } Pools[7];
  134. // Package name lookup
  135. unsigned long HashTable[512]; // Package
  136. };
  137. </example>
  138. <taglist>
  139. <tag>Signature<item>
  140. This must contain the hex value 0x98FE76DC which is designed to verify
  141. that the system loading the image has the same byte order and byte size as
  142. the system saving the image
  143. <tag>MajorVersion
  144. <tag>MinorVersion<item>
  145. These contain the version of the cache file, currently 0.2.
  146. <tag>Dirty<item>
  147. Dirty is true if the cache file was opened for reading, the client expects
  148. to have written things to it and have not fully synced it. The file should
  149. be erased and rebuilt if it is true.
  150. <tag>HeaderSz
  151. <tag>PackageSz
  152. <tag>PackageFileSz
  153. <tag>VersionSz
  154. <tag>DependencySz
  155. <tag>VerFileSz
  156. <tag>ProvidesSz<item>
  157. *Sz contains the sizeof() that particular structure. It is used as an
  158. extra consistancy check on the structure of the file.
  159. If any of the size values do not exactly match what the client expects then
  160. the client should refuse the load the file.
  161. <tag>PackageCount
  162. <tag>VersionCount
  163. <tag>DependsCount
  164. <tag>PackageFileCount<item>
  165. These indicate the number of each structure contianed in the cache.
  166. PackageCount is especially usefull for generating user state structures.
  167. See Package::Id for more info.
  168. <tag>FileList<item>
  169. This contains the index of the first PackageFile structure. The PackageFile
  170. structures are singely linked lists that represent all package files that
  171. have been merged into the cache.
  172. <tag>StringList<item>
  173. This contains a list of all the unique strings (string item type strings) in
  174. the cache. The parser reads this list into memory so it can match strings
  175. against it.
  176. <tag>Pools<item>
  177. The Pool structures manage the allocation pools that the generator uses.
  178. Start indicates the first byte of the pool, Count is the number of objects
  179. remaining in the pool and ItemSize is the structure size (alignment factor)
  180. of the pool. An ItemSize of 0 indicates the pool is empty. There should be
  181. the same number of pools as there are structure types. The generator
  182. stores this information so future additions can make use of any unused pool
  183. blocks.
  184. <tag>HashTable<item>
  185. HashTable is a hash table that provides indexing for all of the packages.
  186. Each package name is inserted into the hash table using the following has
  187. function:
  188. <example>
  189. unsigned long Hash(string Str)
  190. {
  191. unsigned long Hash = 0;
  192. for (const char *I = Str.begin(); I != Str.end(); I++)
  193. Hash += *I * ((Str.end() - I + 1));
  194. return Hash % _count(Head.HashTable);
  195. }
  196. </example>
  197. <p>
  198. By iterating over each entry in the hash table it is possible to iterate over
  199. the entire list of packages. Hash Collisions are handled with a singely linked
  200. list of packages based at the hash item. The linked list contains only
  201. packages that macth the hashing function.
  202. </taglist>
  203. <!-- }}} -->
  204. <!-- Package {{{ -->
  205. <!-- ===================================================================== -->
  206. <sect>Package
  207. <p>
  208. This contians information for a single unique package. There can be any
  209. number of versions of a given package. Package exists in a singly
  210. linked list of package records starting at the hash index of the name in
  211. the Header->HashTable.
  212. <example>
  213. struct Pacakge
  214. {
  215. // Pointers
  216. unsigned long Name; // Stringtable
  217. unsigned long VersionList; // Version
  218. unsigned long TargetVer; // Version
  219. unsigned long CurrentVer; // Version
  220. unsigned long TargetDist; // StringTable (StringItem)
  221. unsigned long Section; // StringTable (StringItem)
  222. // Linked lists
  223. unsigned long NextPackage; // Package
  224. unsigned long RevDepends; // Dependency
  225. unsigned long ProvidesList; // Provides
  226. // Install/Remove/Purge etc
  227. unsigned char SelectedState; // What
  228. unsigned char InstState; // Flags
  229. unsigned char CurrentState; // State
  230. // Unique ID for this pkg
  231. unsigned short ID;
  232. unsigned long Flags;
  233. };
  234. </example>
  235. <taglist>
  236. <tag>Name<item>
  237. Name of the package.
  238. <tag>VersionList<item>
  239. Base of a singely linked list of version structures. Each structure
  240. represents a unique version of the package. The version structures
  241. contain links into PackageFile and the original text file as well as
  242. detailed infromation about the size and dependencies of the specific
  243. package. In this way multiple versions of a package can be cleanly handled
  244. by the system. Furthermore, this linked list is guarenteed to be sorted
  245. from Highest version to lowest version with no duplicate entries.
  246. <tag>TargetVer
  247. <tag>CurrentVer<item>
  248. This is an index (pointer) to the sub version that is being targeted for
  249. upgrading. CurrentVer is an index to the installed version, either can be
  250. 0.
  251. <tag>TargetDist<item>
  252. This indicates the target distribution. Automatic upgrades should not go
  253. outside of the specified dist. If it is 0 then the global target dist should
  254. be used. The string should be contained in the StringItem list.
  255. <tag>Section<item>
  256. This indicates the deduced section. It should be "Unknown" or the section
  257. of the last parsed item.
  258. <tag>NextPackage<item>
  259. Next link in this hash item. This linked list is based at Header.HashTable
  260. and contains only packages with the same hash value.
  261. <tag>RevDepends<item>
  262. Reverse Depends is a linked list of all dependencies linked to this package.
  263. <tag>ProvidesList<item>
  264. This is a linked list of all provides for this package name.
  265. <tag>SelectedState
  266. <tag>InstState
  267. <tag>CurrentState<item>
  268. These corrispond to the 3 items in the Status field found in the status
  269. file. See the section on defines for the possible values.
  270. <p>
  271. SelectedState is the state that the user wishes the package to be
  272. in.
  273. <p>
  274. InstState is the installation state of the package. This normally
  275. should be Ok, but if the installation had an accident it may be otherwise.
  276. <p>
  277. CurrentState indicates if the package is installed, partially installed or
  278. not installed.
  279. <tag>ID<item>
  280. ID is a value from 0 to Header->PackageCount. It is a unique value assigned
  281. by the generator. This allows clients to create an array of size PackageCount
  282. and use it to store state information for the package map. For instance the
  283. status file emitter uses this to track which packages have been emitted
  284. already.
  285. <tag>Flags<item>
  286. Flags are some usefull indicators of the package's state.
  287. </taglist>
  288. <!-- }}} -->
  289. <!-- PackageFile {{{ -->
  290. <!-- ===================================================================== -->
  291. <sect>PackageFile
  292. <p>
  293. This contians information for a single package file. Package files are
  294. referenced by Version structures. This is a singly linked list based from
  295. Header.FileList
  296. <example>
  297. struct PackageFile
  298. {
  299. // Names
  300. unsigned long FileName; // Stringtable
  301. unsigned long Version; // Stringtable
  302. unsigned long Distribution; // Stringtable
  303. unsigned long Size;
  304. // Linked list
  305. unsigned long NextFile; // PackageFile
  306. unsigned short ID;
  307. unsigned long Flags;
  308. time_t mtime; // Modification time
  309. };
  310. </example>
  311. <taglist>
  312. <tag>FileName<item>
  313. Refers the the physical disk file that this PacakgeFile represents.
  314. <tag>Version<item>
  315. Version is the given version, ie 1.3.1, 2.4_revision_1 etc.
  316. <tag>Distribution<item>
  317. Distribution is the symbolic name for this PackageFile, hamm,bo,rexx etc
  318. <tag>Size<item>
  319. Size is provided as a simple check to ensure that the package file has not
  320. been altered.
  321. <tag>ID<item>
  322. See Package::ID.
  323. <tag>Flags<item>
  324. Provides some flags for the PackageFile, see the section on defines.
  325. <tag>mtime<item>
  326. Modification time for the file at time of cache generation.
  327. </taglist>
  328. <!-- }}} -->
  329. <!-- Version {{{ -->
  330. <!-- ===================================================================== -->
  331. <sect>Version
  332. <p>
  333. This contians the information for a single version of a package. This is a
  334. singley linked list based from Package.Versionlist.
  335. <p>
  336. The version list is always sorted from highest version to lowest version by
  337. the generator. Also there may not be any duplicate entries in the list (same
  338. VerStr).
  339. <example>
  340. struct Version
  341. {
  342. unsigned long VerStr; // Stringtable
  343. unsigned long Section; // StringTable (StringItem)
  344. // Lists
  345. unsigned long FileList; // VerFile
  346. unsigned long NextVer; // Version
  347. unsigned long DependsList; // Dependency
  348. unsigned long ParentPkg; // Package
  349. unsigned long ProvidesList; // Provides
  350. unsigned long Size;
  351. unsigned long InstalledSize;
  352. unsigned short ID;
  353. unsigned char Priority;
  354. };
  355. </example>
  356. <taglist>
  357. <tag>VerStr<item>
  358. This is the complete version string.
  359. <tag>FileList<item>
  360. References the all the PackageFile's that this version came out of. FileList
  361. can be used to determine what distribution(s) the Version applies to. If
  362. FileList is 0 then this is a blank version. The structure should also have
  363. a 0 in all other fields excluding VerStr and Possibly NextVer.
  364. <tag>Section<item>
  365. This string indicates which section it is part of. The string should be
  366. contained in the StringItem list.
  367. <tag>NextVer<item>
  368. Next step in the linked list.
  369. <tag>DependsList<item>
  370. This is the base of the dependency list.
  371. <tag>ParentPkg<item>
  372. This links the version to the owning package, allowing reverse dependencies
  373. to determine the package.
  374. <tag>ProvidesList<item>
  375. Head of the linked list of Provides::NextPkgProv, forward provides.
  376. <tag>Size
  377. <tag>InstalledSize<item>
  378. The archive size for this version. For debian this is the size of the .deb
  379. file. Installed size is the uncompressed size for this version
  380. <tag>ID<item>
  381. See Package::ID.
  382. <tag>Priority<item>
  383. This is the parsed priority value of the package.
  384. </taglist>
  385. <!-- }}} -->
  386. <!-- Dependency {{{ -->
  387. <!-- ===================================================================== -->
  388. <sect>Dependency
  389. <p>
  390. Dependency contains the information for a single dependency record. The records
  391. are split up like this to ease processing by the client. The base of list
  392. linked list is Version.DependsList. All forms of dependencies are recorded
  393. here including Conflicts, Suggests and Recommends.
  394. <p>
  395. Multiple depends on the same package must be grouped together in
  396. the Dependency lists. Clients should assume this is always true.
  397. <example>
  398. struct Dependency
  399. {
  400. unsigned long Version; // Stringtable
  401. unsigned long Package; // Package
  402. unsigned long NextDepends; // Dependency
  403. unsigned long NextRevDepends; // Reverse dependency linking
  404. unsigned long ParentVer; // Upwards parent version link
  405. // Specific types of depends
  406. unsigned char Type;
  407. unsigned char CompareOp;
  408. unsigned short ID;
  409. };
  410. </example>
  411. <taglist>
  412. <tag>Version<item>
  413. The string form of the version that the dependency is applied against.
  414. <tag>Package<item>
  415. The index of the package file this depends applies to. If the package file
  416. does not already exist when the dependency is inserted a blank one (no
  417. version records) should be created.
  418. <tag>NextDepends<item>
  419. Linked list based off a Version structure of all the dependencies in that
  420. version.
  421. <tag>NextRevDepends<item>
  422. Reverse dependency linking, based off a Package structure. This linked list
  423. is a list of all packages that have a depends line for a given package.
  424. <tag>ParentVer<item>
  425. Parent version linking, allows the reverse dependency list to link
  426. back to the version and package that the dependency are for.
  427. <tag>Type<item>
  428. Describes weather it is depends, predepends, recommends, suggests, etc.
  429. <tag>CompareOp<item>
  430. Describes the comparison operator specified on the depends line. If the high
  431. bit is set then it is a logical or with the previous record.
  432. <tag>ID<item>
  433. See Package::ID.
  434. </taglist>
  435. <!-- }}} -->
  436. <!-- Provides {{{ -->
  437. <!-- ===================================================================== -->
  438. <sect>Provides
  439. <p>
  440. Provides handles virtual packages. When a Provides: line is encountered
  441. a new provides record is added associating the package with a virtual
  442. package name. The provides structures are linked off the package structures.
  443. This simplifies the analysis of dependencies and other aspects A provides
  444. refers to a specific version of a specific package, not all versions need to
  445. provide that provides.
  446. <p>
  447. There is a linked list of provided package names started from each
  448. version that provides packages. This is the forwards provides mechanism.
  449. <example>
  450. struct Provides
  451. {
  452. unsigned long ParentPkg; // Package
  453. unsigned long Version; // Version
  454. unsigned long ProvideVersion; // Stringtable
  455. unsigned long NextProvides; // Provides
  456. unsigned long NextPkgProv; // Provides
  457. };
  458. </example>
  459. <taglist>
  460. <tag>ParentPkg<item>
  461. The index of the package that head of this linked list is in. ParentPkg->Name
  462. is the name of the provides.
  463. <tag>Version<item>
  464. The index of the version this provide line applies to.
  465. <tag>ProvideVersion<item>
  466. Each provides can specify a version in the provides line. This version allows
  467. dependencies to depend on specific versions of a Provides, as well as allowing
  468. Provides to override existing packages. This is experimental.
  469. <tag>NextProvides<item>
  470. Next link in the singly linked list of provides (based off package)
  471. <tag>NextPkgProv<item>
  472. Next link in the singly linked list of provides for 'Version'.
  473. </taglist>
  474. <!-- }}} -->
  475. <!-- VerFile {{{ -->
  476. <!-- ===================================================================== -->
  477. <sect>VerFile
  478. <p>
  479. VerFile associates a version with a PackageFile, this allows a full
  480. description of all Versions in all files (and hence all sources) under
  481. consideration.
  482. <example>
  483. struct pkgCache::VerFile
  484. {
  485. unsigned long File; // PackageFile
  486. unsigned long NextFile; // PkgVerFile
  487. unsigned long Offset;
  488. unsigned short Size;
  489. }
  490. </example>
  491. <taglist>
  492. <tag>File<item>
  493. The index of the package file that this version was found in.
  494. <tag>NextFile<item>
  495. The next step in the linked list.
  496. <tag>Offset
  497. <tag>Size<item>
  498. These describe the exact position in the package file for the section from
  499. this version.
  500. </taglist>
  501. <!-- }}} -->
  502. <!-- StringItem {{{ -->
  503. <!-- ===================================================================== -->
  504. <sect>StringItem
  505. <p>
  506. StringItem is used for generating single instances of strings. Some things
  507. like Section Name are are usefull to have as unique tags. It is part of
  508. a linked list based at Header::StringList.
  509. <example>
  510. struct StringItem
  511. {
  512. unsigned long String; // Stringtable
  513. unsigned long NextItem; // StringItem
  514. };
  515. </example>
  516. <taglist>
  517. <tag>String<item>
  518. The string this refers to.
  519. <tag>NextItem<item>
  520. Next link in the chain.
  521. </taglist>
  522. <!-- }}} -->
  523. <!-- StringTable {{{ -->
  524. <!-- ===================================================================== -->
  525. <sect>StringTable
  526. <p>
  527. All strings are simply inlined any place in the file that is natural for the
  528. writer. The client should make no assumptions about the positioning of
  529. strings. All stringtable values point to a byte offset from the start of the
  530. file that a null terminated string will begin.
  531. <!-- }}} -->
  532. <!-- Defines {{{ -->
  533. <!-- ===================================================================== -->
  534. <sect>Defines
  535. <p>
  536. Several structures use variables to indicate things. Here is a list of all
  537. of them.
  538. <sect1>Definitions for Dependency::Type
  539. <p>
  540. <example>
  541. #define pkgDEP_Depends 1
  542. #define pkgDEP_PreDepends 2
  543. #define pkgDEP_Suggests 3
  544. #define pkgDEP_Recommends 4
  545. #define pkgDEP_Conflicts 5
  546. #define pkgDEP_Replaces 6
  547. </example>
  548. </sect1>
  549. <sect1>Definitions for Dependency::CompareOp
  550. <p>
  551. <example>
  552. #define pkgOP_OR 0x10
  553. #define pkgOP_LESSEQ 0x1
  554. #define pkgOP_GREATEREQ 0x2
  555. #define pkgOP_LESS 0x3
  556. #define pkgOP_GREATER 0x4
  557. #define pkgOP_EQUALS 0x5
  558. </example>
  559. The lower 4 bits are used to indicate what operator is being specified and
  560. the upper 4 bits are flags. pkgOP_OR indicates that the next package is
  561. or'd with the current package.
  562. </sect1>
  563. <sect1>Definitions for Package::SelectedState
  564. <p>
  565. <example>
  566. #define pkgSTATE_Unkown 0
  567. #define pkgSTATE_Install 1
  568. #define pkgSTATE_Hold 2
  569. #define pkgSTATE_DeInstall 3
  570. #define pkgSTATE_Purge 4
  571. </example>
  572. </sect1>
  573. <sect1>Definitions for Package::InstState
  574. <p>
  575. <example>
  576. #define pkgSTATE_Ok 0
  577. #define pkgSTATE_ReInstReq 1
  578. #define pkgSTATE_Hold 2
  579. #define pkgSTATE_HoldReInstReq 3
  580. </example>
  581. </sect1>
  582. <sect1>Definitions for Package::CurrentState
  583. <p>
  584. <example>
  585. #define pkgSTATE_NotInstalled 0
  586. #define pkgSTATE_UnPacked 1
  587. #define pkgSTATE_HalfConfigured 2
  588. #define pkgSTATE_UnInstalled 3
  589. #define pkgSTATE_HalfInstalled 4
  590. #define pkgSTATE_ConfigFiles 5
  591. #define pkgSTATE_Installed 6
  592. </example>
  593. </sect1>
  594. <sect1>Definitions for Package::Flags
  595. <p>
  596. <example>
  597. #define pkgFLAG_Auto (1 << 0)
  598. #define pkgFLAG_New (1 << 1)
  599. #define pkgFLAG_Obsolete (1 << 2)
  600. #define pkgFLAG_Essential (1 << 3)
  601. #define pkgFLAG_ImmediateConf (1 << 4)
  602. </example>
  603. </sect1>
  604. <sect1>Definitions for Version::Priority
  605. <p>
  606. Zero is used for unparsable or absent Priority fields.
  607. <example>
  608. #define pkgPRIO_Important 1
  609. #define pkgPRIO_Required 2
  610. #define pkgPRIO_Standard 3
  611. #define pkgPRIO_Optional 4
  612. #define pkgPRIO_Extra 5
  613. </example>
  614. </sect1>
  615. <sect1>Definitions for PackageFile::Flags
  616. <p>
  617. <example>
  618. #define pkgFLAG_NotSource (1 << 0)
  619. </example>
  620. </sect1>
  621. <!-- }}} -->
  622. <chapt>Notes on the Generator
  623. <!-- Notes on the Generator {{{ -->
  624. <!-- ===================================================================== -->
  625. <p>
  626. The pkgCache::MergePackageFile function is currently the only generator of
  627. the cache file. It implements a conversion from the normal textual package
  628. file into the cache file.
  629. <p>
  630. The generator assumes any package declaration with a
  631. Status: line is a 'Status of the package' type of package declaration.
  632. A Package with a Target-Version field should also really have a status field.
  633. The processing of a Target-Version field can create a place-holder Version
  634. structure that is empty to refer to the specified version (See Version
  635. for info on what a empty Version looks like). The Target-Version syntax
  636. allows the specification of a specific version and a target distribution.
  637. <p>
  638. Different section names on different versions is supported, but I
  639. do not expect to use it. To simplify the GUI it will mearly use the section
  640. in the Package structure. This should be okay as I hope sections do not change
  641. much.
  642. <p>
  643. The generator goes through a number of post processing steps after producing
  644. a disk file. It sorts all of the version lists to be in descending order
  645. and then generates the reverse dependency lists for all of the packages.
  646. ID numbers and count values are also generated in the post processing step.
  647. <p>
  648. It is possible to extend many of the structures in the cache with extra data.
  649. This is done by using the ID member. ID will be a unique number from 0 to
  650. Header->??Count. For example
  651. <example>
  652. struct MyPkgData;
  653. MyPkgData *Data = new MyPkgData[Header->PackageCount];
  654. Data[Package->ID]->Item = 0;
  655. </example>
  656. This provides a one way reference between package structures and user data. To
  657. get a two way reference would require a member inside the MyPkgData structure.
  658. <p>
  659. The generators use of free space pools tend to make the package file quite
  660. large, and quite full of blank space. This could be fixed with sparse files.
  661. <!-- }}} -->
  662. <chapt>Future Directions
  663. <!-- Future Directions {{{ -->
  664. <!-- ===================================================================== -->
  665. <p>
  666. Some good directions to take the cache file is into a cache directory that
  667. contains many associated caches that cache other important bits of
  668. information. (/var/cache/apt, FHS2)
  669. <p>
  670. Caching of the info/*.list is an excellent place to start, by generating all
  671. the list files into a tree structure and reverse linking them to the package
  672. structures in the main cache file major speed gains in dpkg might be achived.
  673. <!-- }}} -->
  674. </book>