cache.sgml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  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.1 1998/07/02 02:58:12 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.
  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 tndex, 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. // Structure counts
  119. unsigned long PackageCount;
  120. unsigned long VersionCount;
  121. unsigned long DependsCount;
  122. unsigned long PackageFileCount;
  123. // Offsets
  124. unsigned long FileList; // PackageFile
  125. unsigned long StringList; // StringItem
  126. // Pool structures
  127. unsigned long PoolStart[6];
  128. unsigned long PoolSize[6];
  129. unsigned long PoolAln[6];
  130. // Package name lookup
  131. unsigned long HashTable[512]; // Package
  132. };
  133. </example>
  134. <taglist>
  135. <tag>Signature<item>
  136. This must contain the hex value 0x98FE76DC which is designed to verify
  137. that the system loading the image has the same byte order and byte size as
  138. the system saving the image
  139. <tag>MajorVersion
  140. <tag>MinorVersion<item>
  141. These contain the version of the cache file, currently 0.2.
  142. <tag>Dirty<item>
  143. Dirty is true if the cache file was opened for reading, the client expects
  144. to have written things to it and have not fully synced it. The file should
  145. be erased and rebuilt if it is true.
  146. <tag>HeaderSz
  147. <tag>PackageSz
  148. <tag>PackageFileSz
  149. <tag>VersionSz
  150. <tag>DependencySz
  151. <tag>ProvidesSz<item>
  152. *Sz contains the sizeof() that particular structure. It is used as an
  153. extra consistancy check on the structure of the file.
  154. If any of the size values do not exactly match what the client expects then
  155. the client should refuse the load the file.
  156. <tag>PackageCount
  157. <tag>VersionCount
  158. <tag>DependsCount
  159. <tag>PackageFileCount<item>
  160. These indicate the number of each structure contianed in the cache.
  161. PackageCount is especially usefull for generating user state structures.
  162. See Package::Id for more info.
  163. <tag>FileList<item>
  164. This contains the index of the first PackageFile structure. The PackageFile
  165. structures are singely linked lists that represent all package files that
  166. have been merged into the cache.
  167. <tag>StringList<item>
  168. This contains a list of all the unique strings (string item type strings) in
  169. the cache. The parser reads this list into memory so it can match strings
  170. against it.
  171. <tag>PoolStart
  172. <tag>PoolSize
  173. <tag>PoolAln<item>
  174. The Pool structures manage the allocation pools that the generator uses.
  175. Start indicates the first byte of the pool, Size is the number of bytes
  176. remaining in the pool and Aln (alignment) is the structure size of the pool.
  177. An Aln of 0 indicates the slot is empty. There should be the same number of
  178. slots as there are structure types. The generator stores this information
  179. so future additions can make use of any unused pool blocks.
  180. <tag>HashTable<item>
  181. HashTable is a hash table that provides indexing for all of the packages.
  182. Each package name is inserted into the hash table using the following has
  183. function:
  184. <example>
  185. unsigned long Hash(string Str)
  186. {
  187. unsigned long Hash = 0;
  188. for (const char *I = Str.begin(); I != Str.end(); I++)
  189. Hash += *I * ((Str.end() - I + 1));
  190. return Hash % _count(Head.HashTable);
  191. }
  192. </example>
  193. <p>
  194. By iterating over each entry in the hash table it is possible to iterate over
  195. the entire list of packages. Hash Collisions are handled with a singely linked
  196. list of packages based at the hash item. The linked list contains only
  197. packages that macth the hashing function.
  198. </taglist>
  199. <!-- }}} -->
  200. <!-- Package {{{ -->
  201. <!-- ===================================================================== -->
  202. <sect>Package
  203. <p>
  204. This contians information for a single unique package. There can be any
  205. number of versions of a given package. Package exists in a singly
  206. linked list of package records starting at the hash index of the name in
  207. the Header->HashTable.
  208. <example>
  209. struct Pacakge
  210. {
  211. // Pointers
  212. unsigned long Name; // Stringtable
  213. unsigned long VersionList; // Version
  214. unsigned long TargetVer; // Version
  215. unsigned long CurrentVer; // Version
  216. unsigned long TargetDist; // StringTable (StringItem)
  217. unsigned long Section; // StringTable (StringItem)
  218. // Linked lists
  219. unsigned long NextPackage; // Package
  220. unsigned long RevDepends; // Dependency
  221. unsigned long ProvidesList; // Provides
  222. // Install/Remove/Purge etc
  223. unsigned char SelectedState; // What
  224. unsigned char InstState; // Flags
  225. unsigned char CurrentState; // State
  226. // Unique ID for this pkg
  227. unsigned short ID;
  228. unsigned short Flags;
  229. };
  230. </example>
  231. <taglist>
  232. <tag>Name<item>
  233. Name of the package.
  234. <tag>VersionList<item>
  235. Base of a singely linked list of version structures. Each structure
  236. represents a unique version of the package. The version structures
  237. contain links into PackageFile and the original text file as well as
  238. detailed infromation about the size and dependencies of the specific
  239. package. In this way multiple versions of a package can be cleanly handled
  240. by the system. Furthermore, this linked list is guarenteed to be sorted
  241. from Highest version to lowest version with no duplicate entries.
  242. <tag>TargetVer
  243. <tag>CurrentVer<item>
  244. This is an index (pointer) to the sub version that is being targeted for
  245. upgrading. CurrentVer is an index to the installed version, either can be
  246. 0.
  247. <tag>TargetDist<item>
  248. This indicates the target distribution. Automatic upgrades should not go
  249. outside of the specified dist. If it is 0 then the global target dist should
  250. be used. The string should be contained in the StringItem list.
  251. <tag>Section<item>
  252. This indicates the deduced section. It should be "Unknown" or the section
  253. of the last parsed item.
  254. <tag>NextPackage<item>
  255. Next link in this hash item. This linked list is based at Header.HashTable
  256. and contains only packages with the same hash value.
  257. <tag>RevDepends<item>
  258. Reverse Depends is a linked list of all dependencies linked to this package.
  259. <tag>ProvidesList<item>
  260. This is a linked list of all provides for this package name.
  261. <tag>SelectedState
  262. <tag>InstState
  263. <tag>CurrentState<item>
  264. These corrispond to the 3 items in the Status field found in the status
  265. file. See the section on defines for the possible values.
  266. <p>
  267. SelectedState is the state that the user wishes the package to be
  268. in.
  269. <p>
  270. InstState is the installation state of the package. This normally
  271. should be Ok, but if the installation had an accident it may be otherwise.
  272. <p>
  273. CurrentState indicates if the package is installed, partially installed or
  274. not installed.
  275. <tag>ID<item>
  276. ID is a value from 0 to Header->PackageCount. It is a unique value assigned
  277. by the generator. This allows clients to create an array of size PackageCount
  278. and use it to store state information for the package map. For instance the
  279. status file emitter uses this to track which packages have been emitted
  280. already.
  281. <tag>Flags<item>
  282. Flags are some usefull indicators of the package's state.
  283. </taglist>
  284. <!-- }}} -->
  285. <!-- PackageFile {{{ -->
  286. <!-- ===================================================================== -->
  287. <sect>PackageFile
  288. <p>
  289. This contians information for a single package file. Package files are
  290. referenced by Version structures. This is a singly linked list based from
  291. Header.FileList
  292. <example>
  293. struct PackageFile
  294. {
  295. // Names
  296. unsigned long FileName; // Stringtable
  297. unsigned long Version; // Stringtable
  298. unsigned long Distribution; // Stringtable
  299. unsigned long Size;
  300. // Linked list
  301. unsigned long NextFile; // PackageFile
  302. unsigned short ID;
  303. unsigned short Flags;
  304. time_t mtime; // Modification time
  305. };
  306. </example>
  307. <taglist>
  308. <tag>FileName<item>
  309. Refers the the physical disk file that this PacakgeFile represents.
  310. <tag>Version<item>
  311. Version is the given version, ie 1.3.1, 2.4_revision_1 etc.
  312. <tag>Distribution<item>
  313. Distribution is the symbolic name for this PackageFile, hamm,bo,rexx etc
  314. <tag>Size<item>
  315. Size is provided as a simple check to ensure that the package file has not
  316. been altered.
  317. <tag>ID<item>
  318. See Package::ID.
  319. <tag>Flags<item>
  320. Provides some flags for the PackageFile, see the section on defines.
  321. <tag>mtime<item>
  322. Modification time for the file at time of cache generation.
  323. </taglist>
  324. <!-- }}} -->
  325. <!-- Version {{{ -->
  326. <!-- ===================================================================== -->
  327. <sect>Version
  328. <p>
  329. This contians the information for a single version of a package. This is a
  330. singley linked list based from Package.Versionlist.
  331. <p>
  332. The version list is always sorted from highest version to lowest version by
  333. the generator. Also there may not be any duplicate entries in the list (same
  334. VerStr).
  335. <example>
  336. struct Version
  337. {
  338. unsigned long VerStr; // Stringtable
  339. unsigned long File; // PackageFile
  340. unsigned long Section; // StringTable (StringItem)
  341. // Lists
  342. unsigned long NextVer; // Version
  343. unsigned long DependsList; // Dependency
  344. unsigned long ParentPkg; // Package
  345. unsigned long ProvidesList; // Provides
  346. unsigned long Offset;
  347. unsigned long Size;
  348. unsigned long InstalledSize;
  349. unsigned short ID;
  350. unsigned char Priority;
  351. };
  352. </example>
  353. <taglist>
  354. <tag>VerStr<item>
  355. This is the complete version string.
  356. <tag>File<item>
  357. References the PackageFile that this version came out of. File can be used
  358. to determine what distribution the Version applies to. If File is 0 then
  359. this is a blank version. The structure should also have a 0 in all other
  360. fields excluding VerStr and Possibly NextVer.
  361. <tag>Section<item>
  362. This string indicates which section it is part of. The string should be
  363. contained in the StringItem list.
  364. <tag>NextVer<item>
  365. Next step in the linked list.
  366. <tag>DependsList<item>
  367. This is the base of the dependency list.
  368. <tag>ParentPkg<item>
  369. This links the version to the owning package, allowing reverse dependencies
  370. to determine the package.
  371. <tag>ProvidesList<item>
  372. Head of the linked list of Provides::NextPkgProv, forward provides.
  373. <tag>Offset<item>
  374. The byte offset of the first line of this item in the specified
  375. PackageFile
  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. <!-- StringItem {{{ -->
  476. <!-- ===================================================================== -->
  477. <sect>StringItem
  478. <p>
  479. StringItem is used for generating single instances of strings. Some things
  480. like Section Name are are usefull to have as unique tags. It is part of
  481. a linked list based at Header::StringList.
  482. <example>
  483. struct StringItem
  484. {
  485. unsigned long String; // Stringtable
  486. unsigned long NextItem; // StringItem
  487. };
  488. </example>
  489. <taglist>
  490. <tag>String<item>
  491. The string this refers to.
  492. <tag>NextItem<item>
  493. Next link in the chain.
  494. </taglist>
  495. <!-- }}} -->
  496. <!-- StringTable {{{ -->
  497. <!-- ===================================================================== -->
  498. <sect>StringTable
  499. <p>
  500. All strings are simply inlined any place in the file that is natural for the
  501. writer. The client should make no assumptions about the positioning of
  502. strings. All stringtable values point to a byte offset from the start of the
  503. file that a null terminated string will begin.
  504. <!-- }}} -->
  505. <!-- Defines {{{ -->
  506. <!-- ===================================================================== -->
  507. <sect>Defines
  508. <p>
  509. Several structures use variables to indicate things. Here is a list of all
  510. of them.
  511. <sect1>Definitions for Dependency::Type
  512. <p>
  513. <example>
  514. #define pkgDEP_Depends 1
  515. #define pkgDEP_PreDepends 2
  516. #define pkgDEP_Suggests 3
  517. #define pkgDEP_Recommends 4
  518. #define pkgDEP_Conflicts 5
  519. #define pkgDEP_Replaces 6
  520. </example>
  521. </sect1>
  522. <sect1>Definitions for Dependency::CompareOp
  523. <p>
  524. <example>
  525. #define pkgOP_OR 0x10
  526. #define pkgOP_LESSEQ 0x1
  527. #define pkgOP_GREATEREQ 0x2
  528. #define pkgOP_LESS 0x3
  529. #define pkgOP_GREATER 0x4
  530. #define pkgOP_EQUALS 0x5
  531. </example>
  532. The lower 4 bits are used to indicate what operator is being specified and
  533. the upper 4 bits are flags. pkgOP_OR indicates that the next package is
  534. or'd with the current package.
  535. </sect1>
  536. <sect1>Definitions for Package::SelectedState
  537. <p>
  538. <example>
  539. #define pkgSTATE_Unkown 0
  540. #define pkgSTATE_Install 1
  541. #define pkgSTATE_Hold 2
  542. #define pkgSTATE_DeInstall 3
  543. #define pkgSTATE_Purge 4
  544. </example>
  545. </sect1>
  546. <sect1>Definitions for Package::InstState
  547. <p>
  548. <example>
  549. #define pkgSTATE_Ok 0
  550. #define pkgSTATE_ReInstReq 1
  551. #define pkgSTATE_Hold 2
  552. #define pkgSTATE_HoldReInstReq 3
  553. </example>
  554. </sect1>
  555. <sect1>Definitions for Package::CurrentState
  556. <p>
  557. <example>
  558. #define pkgSTATE_NotInstalled 0
  559. #define pkgSTATE_UnPacked 1
  560. #define pkgSTATE_HalfConfigured 2
  561. #define pkgSTATE_UnInstalled 3
  562. #define pkgSTATE_HalfInstalled 4
  563. #define pkgSTATE_ConfigFiles 5
  564. #define pkgSTATE_Installed 6
  565. </example>
  566. </sect1>
  567. <sect1>Definitions for Package::Flags
  568. <p>
  569. <example>
  570. #define pkgFLAG_Auto (1 << 0)
  571. #define pkgFLAG_New (1 << 1)
  572. #define pkgFLAG_Obsolete (1 << 2)
  573. #define pkgFLAG_Essential (1 << 3)
  574. #define pkgFLAG_ImmediateConf (1 << 4)
  575. </example>
  576. </sect1>
  577. <sect1>Definitions for Version::Priority
  578. <p>
  579. Zero is used for unparsable or absent Priority fields.
  580. <example>
  581. #define pkgPRIO_Important 1
  582. #define pkgPRIO_Required 2
  583. #define pkgPRIO_Standard 3
  584. #define pkgPRIO_Optional 4
  585. #define pkgPRIO_Extra 5
  586. </example>
  587. </sect1>
  588. <sect1>Definitions for PackageFile::Flags
  589. <p>
  590. <example>
  591. #define pkgFLAG_NotSource (1 << 0)
  592. </example>
  593. </sect1>
  594. <!-- }}} -->
  595. <chapt>Notes on the Generator
  596. <!-- Notes on the Generator {{{ -->
  597. <!-- ===================================================================== -->
  598. <p>
  599. The pkgCache::MergePackageFile function is currently the only generator of
  600. the cache file. It implements a conversion from the normal textual package
  601. file into the cache file.
  602. <p>
  603. The generator assumes any package declaration with a
  604. Status: line is a 'Status of the package' type of package declaration.
  605. A Package with a Target-Version field should also really have a status field.
  606. The processing of a Target-Version field can create a place-holder Version
  607. structure that is empty to refer to the specified version (See Version
  608. for info on what a empty Version looks like). The Target-Version syntax
  609. allows the specification of a specific version and a target distribution.
  610. <p>
  611. Different section names on different versions is supported, but I
  612. do not expect to use it. To simplify the GUI it will mearly use the section
  613. in the Package structure. This should be okay as I hope sections do not change
  614. much.
  615. <p>
  616. The generator goes through a number of post processing steps after producing
  617. a disk file. It sorts all of the version lists to be in descending order
  618. and then generates the reverse dependency lists for all of the packages.
  619. ID numbers and count values are also generated in the post processing step.
  620. <p>
  621. It is possible to extend many of the structures in the cache with extra data.
  622. This is done by using the ID member. ID will be a unique number from 0 to
  623. Header->??Count. For example
  624. <example>
  625. struct MyPkgData;
  626. MyPkgData *Data = new MyPkgData[Header->PackageCount];
  627. Data[Package->ID]->Item = 0;
  628. </example>
  629. This provides a one way reference between package structures and user data. To
  630. get a two way reference would require a member inside the MyPkgData structure.
  631. <p>
  632. The generators use of free space pools tend to make the package file quite
  633. large, and quite full of blank space. This could be fixed with sparse files.
  634. <!-- }}} -->
  635. <chapt>Future Directions
  636. <!-- Future Directions {{{ -->
  637. <!-- ===================================================================== -->
  638. <p>
  639. Some good directions to take the cache file is into a cache directory that
  640. contains many associated caches that cache other important bits of
  641. information. (/var/cache/apt, FHS2)
  642. <p>
  643. Caching of the info/*.list is an excellent place to start, by generating all
  644. the list files into a tree structure and reverse linking them to the package
  645. structures in the main cache file major speed gains in dpkg might be achived.
  646. <!-- }}} -->
  647. </book>