dpkg-tech.dbk 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- -*- DocBook -*- -->
  3. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  4. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  5. <!ENTITY % aptverbatiment SYSTEM "apt-verbatim.ent"> %aptverbatiment;
  6. ]>
  7. <book lang="en">
  8. <title>dpkg technical manual</title>
  9. <bookinfo>
  10. <authorgroup>
  11. <author>
  12. <personname>Tom Lees</personname><email>tom@lpsg.demon.co.uk</email>
  13. </author>
  14. </authorgroup>
  15. <releaseinfo>Version &apt-product-version;</releaseinfo>
  16. <abstract>
  17. <para>
  18. This document describes the minimum necessary workings for the APT dselect
  19. replacement. It gives an overall specification of what its external interface
  20. must look like for compatibility, and also gives details of some internal
  21. quirks.
  22. </para>
  23. </abstract>
  24. <copyright><year>1997</year><holder>Tom Lees</holder></copyright>
  25. <legalnotice>
  26. <title>License Notice</title>
  27. <para>
  28. APT and this document are free software; you can redistribute them and/or
  29. modify them under the terms of the GNU General Public License as published by
  30. the Free Software Foundation; either version 2 of the License, or (at your
  31. option) any later version.
  32. </para>
  33. <para>
  34. For more details, on Debian systems, see the file
  35. /usr/share/common-licenses/GPL for the full license.
  36. </para>
  37. </legalnotice>
  38. </bookinfo>
  39. <chapter id="ch1"><title>Quick summary of dpkg's external interface</title>
  40. <section id="control"><title>Control files</title>
  41. <para>
  42. The basic dpkg package control file supports the following major features:-
  43. </para>
  44. <itemizedlist>
  45. <listitem>
  46. <para>
  47. 5 types of dependencies:-
  48. </para>
  49. <itemizedlist>
  50. <listitem>
  51. <para>
  52. Pre-Depends, which must be satisfied before a package may be unpacked
  53. </para>
  54. </listitem>
  55. <listitem>
  56. <para>
  57. Depends, which must be satisfied before a package may be configured
  58. </para>
  59. </listitem>
  60. <listitem>
  61. <para>
  62. Recommends, to specify a package which if not installed may severely limit the
  63. usefulness of the package
  64. </para>
  65. </listitem>
  66. <listitem>
  67. <para>
  68. Suggests, to specify a package which may increase the productivity of the
  69. package
  70. </para>
  71. </listitem>
  72. <listitem>
  73. <para>
  74. Conflicts, to specify a package which must NOT be installed in order for the
  75. package to be configured
  76. </para>
  77. </listitem>
  78. <listitem>
  79. <para>
  80. Breaks, to specify a package which is broken by the package and which should
  81. therefore not be configured while broken
  82. </para>
  83. </listitem>
  84. </itemizedlist>
  85. <para>
  86. Each of these dependencies can specify a version and a depedency on that
  87. version, for example "&lt;= 0.5-1", "== 2.7.2-1", etc. The comparators
  88. available are:-
  89. </para>
  90. <itemizedlist>
  91. <listitem>
  92. <para>
  93. "&lt;&lt;" - less than
  94. </para>
  95. </listitem>
  96. <listitem>
  97. <para>
  98. "&lt;=" - less than or equal to
  99. </para>
  100. </listitem>
  101. <listitem>
  102. <para>
  103. "&gt;&gt;" - greater than
  104. </para>
  105. </listitem>
  106. <listitem>
  107. <para>
  108. "&gt;=" - greater than or equal to
  109. </para>
  110. </listitem>
  111. <listitem>
  112. <para>
  113. "==" - equal to
  114. </para>
  115. </listitem>
  116. </itemizedlist>
  117. </listitem>
  118. <listitem>
  119. <para>
  120. The concept of "virtual packages", which many other packages may provide,
  121. using the Provides mechanism. An example of this is the "httpd" virtual
  122. package, which all web servers should provide. Virtual package names may be
  123. used in dependency headers. However, current policy is that virtual packages
  124. do not support version numbers, so dependencies on virtual packages with
  125. versions will always fail.
  126. </para>
  127. </listitem>
  128. <listitem>
  129. <para>
  130. Several other control fields, such as Package, Version, Description, Section,
  131. Priority, etc., which are mainly for classification purposes. The package
  132. name must consist entirely of lowercase characters, plus the characters '+',
  133. '-', and '.'. Fields can extend across multiple lines - on the second and
  134. subsequent lines, there is a space at the beginning instead of a field name
  135. and a ':'. Empty lines must consist of the text " .", which will be ignored,
  136. as will the initial space for other continuation lines. This feature is
  137. usually only used in the Description field.
  138. </para>
  139. </listitem>
  140. </itemizedlist>
  141. </section>
  142. <section id="s1.2"><title>The dpkg status area</title>
  143. <para>
  144. The "dpkg status area" is the term used to refer to the directory where dpkg
  145. keeps its various status files (GNU would have you call it the dpkg shared
  146. state directory). This is always, on Debian systems, /var/lib/dpkg. However,
  147. the default directory name should not be hard-coded, but #define'd, so that
  148. alteration is possible (it is available via configure in dpkg 1.4.0.9 and
  149. above). Of course, in a library, code should be allowed to override the
  150. default directory, but the default should be part of the library (so that
  151. the user may change the dpkg admin dir simply by replacing the library).
  152. </para>
  153. <para>
  154. Dpkg keeps a variety of files in its status area. These are discussed later
  155. on in this document, but a quick summary of the files is here:-
  156. </para>
  157. <itemizedlist>
  158. <listitem>
  159. <para>
  160. available - this file contains a concatenation of control information from all
  161. the packages which dpkg knows about. This is updated using the dpkg commands
  162. "--update-avail &lt;file&gt;", "--merge-avail &lt;file&gt;", and
  163. "--clear-avail".
  164. </para>
  165. </listitem>
  166. <listitem>
  167. <para>
  168. status - this file contains information on the following things for every
  169. package:-
  170. </para>
  171. <itemizedlist>
  172. <listitem>
  173. <para>
  174. Whether it is installed, not installed, unpacked, removed, failed
  175. configuration, or half-installed (deconfigured in favour of another package).
  176. </para>
  177. </listitem>
  178. <listitem>
  179. <para>
  180. Whether it is selected as install, hold, remove, or purge.
  181. </para>
  182. </listitem>
  183. <listitem>
  184. <para>
  185. If it is "ok" (no installation problems), or "not-ok".
  186. </para>
  187. </listitem>
  188. <listitem>
  189. <para>
  190. It usually also contains the section and priority (so that dselect may classify
  191. packages not in available)
  192. </para>
  193. </listitem>
  194. <listitem>
  195. <para>
  196. For packages which did not initially appear in the "available" file when they
  197. were installed, the other control information for them.
  198. </para>
  199. </listitem>
  200. </itemizedlist>
  201. <para>
  202. The exact format for the "Status:" field is:
  203. </para>
  204. <screen>
  205. Status: Want Flag Status
  206. </screen>
  207. <para>
  208. Where <replaceable>Want</replaceable> may be one of
  209. <emphasis>unknown</emphasis>, <emphasis>install</emphasis>,
  210. <emphasis>hold</emphasis>, <emphasis>deinstall</emphasis>,
  211. <emphasis>purge</emphasis>. <replaceable>Flag</replaceable> may
  212. be one of <emphasis>ok</emphasis>, <emphasis>reinstreq</emphasis>,
  213. <emphasis>hold</emphasis>,
  214. <emphasis>hold-reinstreq</emphasis>. <replaceable>Status</replaceable> may
  215. be one of <emphasis>not-installed</emphasis>, <emphasis>unpacked</emphasis>,
  216. <emphasis>half-configured</emphasis>, <emphasis>installed</emphasis>,
  217. <emphasis>half-installed</emphasis> <emphasis>config-files</emphasis>,
  218. <emphasis>post-inst-failed</emphasis>, <emphasis>removal-failed</emphasis>.
  219. The states are as follows:-
  220. </para>
  221. <variablelist>
  222. <varlistentry>
  223. <term>not-installed</term>
  224. <listitem>
  225. <para>
  226. No files are installed from the package, it has no config files left, it
  227. uninstalled cleanly if it ever was installed.
  228. </para>
  229. </listitem>
  230. </varlistentry>
  231. <varlistentry>
  232. <term>unpacked</term>
  233. <listitem>
  234. <para>
  235. The basic files have been unpacked (and are listed in
  236. /var/lib/dpkg/info/[package].list. There are config files present, but the
  237. postinst script has _NOT_ been run.
  238. </para>
  239. </listitem>
  240. </varlistentry>
  241. <varlistentry>
  242. <term>half-configured</term>
  243. <listitem>
  244. <para>
  245. The package was installed and unpacked, but the postinst script failed in some
  246. way.
  247. </para>
  248. </listitem>
  249. </varlistentry>
  250. <varlistentry>
  251. <term>installed</term>
  252. <listitem>
  253. <para>
  254. All files for the package are installed, and the configuration was also
  255. successful.
  256. </para>
  257. </listitem>
  258. </varlistentry>
  259. <varlistentry>
  260. <term>half-installed</term>
  261. <listitem>
  262. <para>
  263. An attempt was made to remove the packagem but there was a failure in the
  264. prerm script.
  265. </para>
  266. </listitem>
  267. </varlistentry>
  268. <varlistentry>
  269. <term>config-files</term>
  270. <listitem>
  271. <para>
  272. The package was "removed", not "purged". The config files are left, but
  273. nothing else.
  274. </para>
  275. </listitem>
  276. </varlistentry>
  277. <varlistentry>
  278. <term>post-inst-failed</term>
  279. <listitem>
  280. <para>
  281. Old name for half-configured. Do not use.
  282. </para>
  283. </listitem>
  284. </varlistentry>
  285. <varlistentry>
  286. <term>removal-failed</term>
  287. <listitem>
  288. <para>
  289. Old name for half-installed. Do not use.
  290. </para>
  291. </listitem>
  292. </varlistentry>
  293. </variablelist>
  294. <para>
  295. The two last items are only left in dpkg for compatibility - they are
  296. understood by it, but never written out in this form.
  297. </para>
  298. <para>
  299. Please see the dpkg source code, <literal>lib/parshelp.c</literal>,
  300. <emphasis>statusinfos</emphasis>, <emphasis>eflaginfos</emphasis> and
  301. <emphasis>wantinfos</emphasis> for more details.
  302. </para>
  303. </listitem>
  304. <listitem>
  305. <para>
  306. info - this directory contains files from the control archive of every
  307. package currently installed. They are installed with a prefix of
  308. "&lt;packagename&gt;.". In addition to this, it also contains a file
  309. called &lt;package&gt;.list for every package, which contains a list
  310. of files. Note also that the control file is not copied into here; it
  311. is instead found as part of status or available.
  312. </para>
  313. </listitem>
  314. <listitem>
  315. <para>
  316. methods - this directory is reserved for "method"-specific files - each
  317. "method" has a subdirectory underneath this directory (or at least,
  318. it can have). In addition, there is another subdirectory "mnt", where
  319. misc. filesystems (floppies, CD-ROMs, etc.) are mounted.
  320. </para>
  321. </listitem>
  322. <listitem>
  323. <para>
  324. alternatives - directory used by the "update-alternatives" program. It
  325. contains one file for each "alternatives" interface, which contains
  326. information about all the needed symlinked files for each alternative.
  327. </para>
  328. </listitem>
  329. <listitem>
  330. <para>
  331. diversions - file used by the "dpkg-divert" program. Each diversion takes
  332. three lines. The first is the package name (or ":" for user diversion), the
  333. second the original filename, and the third the diverted filename.
  334. </para>
  335. </listitem>
  336. <listitem>
  337. <para>
  338. updates - directory used internally by dpkg. This is discussed later, in the
  339. section <xref linkend="updates"/>.
  340. </para>
  341. </listitem>
  342. <listitem>
  343. <para>
  344. parts - temporary directory used by dpkg-split
  345. </para>
  346. </listitem>
  347. </itemizedlist>
  348. </section>
  349. <section id="s1.3"><title>The dpkg library files</title>
  350. <para>
  351. These files are installed under /usr/lib/dpkg (usually), but
  352. /usr/local/lib/dpkg is also a possibility (as Debian policy dictates). Under
  353. this directory, there is a "methods" subdirectory. The methods subdirectory in
  354. turn contains any number of subdirectories for each general method processor
  355. (note that one set of method scripts can, and is, used for more than one of
  356. the methods listed under dselect).
  357. </para>
  358. <para>
  359. The following files may be found in each of these subdirectories:-
  360. </para>
  361. <itemizedlist>
  362. <listitem>
  363. <para>
  364. names - One line per method, two-digit priority to appear on menu at
  365. beginning, followed by a space, the name, and then another space and
  366. the short description.
  367. </para>
  368. </listitem>
  369. <listitem>
  370. <para>
  371. desc.&lt;name&gt; - Contains the long description displayed by dselect
  372. when the cursor is put over the &lt;name&gt; method.
  373. </para>
  374. </listitem>
  375. <listitem>
  376. <para>
  377. setup - Script or program which sets up the initial values to be used
  378. by this method. Called with first argument as the status area directory
  379. (/var/lib/dpkg), second argument as the name of the method (as in the
  380. directory name), and the third argument as the option (as in the names file).
  381. </para>
  382. </listitem>
  383. <listitem>
  384. <para>
  385. install - Script/program called when the "install" option of dselect is run
  386. with this method. Same arguments as for setup.
  387. </para>
  388. </listitem>
  389. <listitem>
  390. <para>
  391. update - Script/program called when the "update" option of dselect is
  392. run. Same arguments as for setup/install.
  393. </para>
  394. </listitem>
  395. </itemizedlist>
  396. </section>
  397. <section id="s1.4"><title>The "dpkg" command-line utility</title>
  398. <section id="s1.4.1"><title>"Documented" command-line interfaces</title>
  399. <para>
  400. As yet unwritten. You can refer to the other manuals for now. See
  401. <citerefentry><refentrytitle>dpkg</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
  402. </para>
  403. </section>
  404. <section id="s1.4.2"><title>Environment variables which dpkg responds to</title>
  405. <itemizedlist>
  406. <listitem>
  407. <para>
  408. DPKG_NO_TSTP - if set to a non-null value, this variable causes dpkg to run a
  409. child shell process instead of sending itself a SIGTSTP, when the user selects
  410. to background the dpkg process when it asks about conffiles.
  411. </para>
  412. </listitem>
  413. <listitem>
  414. <para>
  415. SHELL - used to determine which shell to run in the case when DPKG_NO_TSTP
  416. is set.
  417. </para>
  418. </listitem>
  419. <listitem>
  420. <para>
  421. CC - used as the C compiler to call to determine the target architecture. The
  422. default is "gcc".
  423. </para>
  424. </listitem>
  425. <listitem>
  426. <para>
  427. PATH - dpkg checks that it can find at least the following files in the path
  428. when it wants to run package installation scripts, and gives an error if it
  429. cannot find all of them:-
  430. </para>
  431. <itemizedlist>
  432. <listitem>
  433. <para>
  434. ldconfig
  435. </para>
  436. </listitem>
  437. <listitem>
  438. <para>
  439. start-stop-daemon
  440. </para>
  441. </listitem>
  442. <listitem>
  443. <para>
  444. install-info
  445. </para>
  446. </listitem>
  447. <listitem>
  448. <para>
  449. update-rc.d
  450. </para>
  451. </listitem>
  452. </itemizedlist>
  453. </listitem>
  454. </itemizedlist>
  455. </section>
  456. <section id="s1.4.3"><title>Assertions</title>
  457. <para>
  458. The dpkg utility itself is required for quite a number of packages, even if
  459. they have been installed with a tool totally separate from dpkg. The reason
  460. for this is that some packages, in their pre-installation scripts, check that
  461. your version of dpkg supports certain features. This was broken from the
  462. start, and it should have actually been a control file header "Dpkg-requires",
  463. or similar. What happens is that the configuration scripts will abort or
  464. continue according to the exit code of a call to dpkg, which will stop them
  465. from being wrongly configured.
  466. </para>
  467. <para>
  468. These special command-line options, which simply return as true or false are
  469. all prefixed with "--assert-". Here is a list of them (without the prefix):-
  470. </para>
  471. <itemizedlist>
  472. <listitem>
  473. <para>
  474. support-predepends - Returns success or failure according to whether a version
  475. of dpkg which supports predepends properly (1.1.0 or above) is installed,
  476. according to the database.
  477. </para>
  478. </listitem>
  479. <listitem>
  480. <para>
  481. working-epoch - Return success or failure according to whether a version of
  482. dpkg which supports epochs in version properly (1.4.0.7 or above) is installed,
  483. according to the database.
  484. </para>
  485. </listitem>
  486. </itemizedlist>
  487. <para>
  488. Both these options check the status database to see what version of the
  489. "dpkg" package is installed, and check it against a known working version.
  490. </para>
  491. </section>
  492. <section id="s1.4.4"><title>--predep-package</title>
  493. <para>
  494. This strange option is described as follows in the source code:
  495. </para>
  496. <screen>
  497. /* Print a single package which:
  498. * (a) is the target of one or more relevant predependencies.
  499. * (b) has itself no unsatisfied pre-dependencies.
  500. * If such a package is present output is the Packages file entry,
  501. * which can be massaged as appropriate.
  502. * Exit status:
  503. * 0 = a package printed, OK
  504. * 1 = no suitable package available
  505. * 2 = error
  506. */
  507. </screen>
  508. <para>
  509. On further inspection of the source code, it appears that what is does is
  510. this:-
  511. </para>
  512. <itemizedlist>
  513. <listitem>
  514. <para>
  515. Looks at the packages in the database which are selected as "install",
  516. and are installed.
  517. </para>
  518. </listitem>
  519. <listitem>
  520. <para>
  521. It then looks at the Pre-Depends information for each of these packages
  522. from the available file. When it find a package for which any of the
  523. pre-dependencies are not satisfied, it breaks from the loop through the
  524. packages.
  525. </para>
  526. </listitem>
  527. <listitem>
  528. <para>
  529. It then looks through the unsatisfied pre-dependencies, and looks for
  530. packages which would satisfy this pre-dependency, stopping on the first
  531. it finds. If it finds none, it bombs out with an error.
  532. </para>
  533. </listitem>
  534. <listitem>
  535. <para>
  536. It then continues this for every dependency of the initial package.
  537. </para>
  538. </listitem>
  539. </itemizedlist>
  540. <para>
  541. Eventually, it writes out the record of all the packages to satisfy the
  542. pre-dependencies. This is used by the disk method to make sure that its
  543. dependency ordering is correct. What happens is that all pre-depending
  544. packages are first installed, then it runs dpkg -iGROEB on the directory,
  545. which installs in the order package files are found. Since pre-dependencies
  546. mean that a package may not even be unpacked unless they are satisfied, it
  547. is necessary to do this (usually, since all the package files are unpacked
  548. in one phase, the configured in another, this is not needed).
  549. </para>
  550. </section>
  551. </section>
  552. </chapter>
  553. <chapter id="ch2"><title>dpkg-deb and .deb file internals</title>
  554. <para>
  555. This chapter describes the internals to the "dpkg-deb" tool, which is used by
  556. "dpkg" as a back-end. dpkg-deb has its own tar extraction functions, which is
  557. the source of many problems, as it does not support long filenames, using
  558. extension blocks.
  559. </para>
  560. <section id="s2.1"><title>The .deb archive format</title>
  561. <para>
  562. The main principal of the new-format Debian archive (I won't describe the old
  563. format - for that have a look at deb-old.5), is that the archive really is an
  564. archive - as used by "ar" and friends. However, dpkg-deb uses this format
  565. internally, rather than calling "ar". Inside this archive, there are usually
  566. the following members:-
  567. </para>
  568. <itemizedlist>
  569. <listitem>
  570. <para>
  571. debian-binary
  572. </para>
  573. </listitem>
  574. <listitem>
  575. <para>
  576. control.tar.gz
  577. </para>
  578. </listitem>
  579. <listitem>
  580. <para>
  581. data.tar.gz
  582. </para>
  583. </listitem>
  584. </itemizedlist>
  585. <para>
  586. The debian-binary member consists simply of the string "2.0", indicating
  587. the format version. control.tar.gz contains the control files (and scripts),
  588. and the data.tar.gz contains the actual files to populate the filesystem
  589. with. Both tarfiles extract straight into the current directory. Information
  590. on the tar formats can be found in the GNU tar info page. Since dpkg-deb
  591. calls "tar -cf" to build packages, the Debian packages use the GNU extensions.
  592. </para>
  593. </section>
  594. <section id="s2.2"><title>The dpkg-deb command-line</title>
  595. <para>
  596. dpkg-deb documents itself thoroughly with its '--help' command-line
  597. option. However, I am including a reference to these for
  598. completeness. dpkg-deb supports the following options:-
  599. </para>
  600. <itemizedlist>
  601. <listitem>
  602. <para>
  603. --build (-b) &lt;dir&gt; - builds a .deb archive, takes a directory which
  604. contains all the files as an argument. Note that the directory
  605. &lt;dir&gt;/DEBIAN will be packed separately into the control archive.
  606. </para>
  607. </listitem>
  608. <listitem>
  609. <para>
  610. --contents (-c) &lt;debfile&gt; - Lists the contents of the "data.tar.gz"
  611. member.
  612. </para>
  613. </listitem>
  614. <listitem>
  615. <para>
  616. --control (-e) &lt;debfile&gt; - Extracts the control archive into a directory
  617. called DEBIAN. Alternatively, with another argument, it will extract it into a
  618. different directory.
  619. </para>
  620. </listitem>
  621. <listitem>
  622. <para>
  623. --info (-I) &lt;debfile&gt; - Prints the contents of the "control" file in the
  624. control archive to stdout. Alternatively, giving it other arguments will cause
  625. it to print the contents of those files instead.
  626. </para>
  627. </listitem>
  628. <listitem>
  629. <para>
  630. --field (-f) &lt;debfile&gt; &lt;field&gt; ... - Prints any number of fields
  631. from the "control" file. Giving it extra arguments limits the fields it prints
  632. to only those specified. With no command-line arguments other than a filename,
  633. it is equivalent to -I and just the .deb filename.
  634. </para>
  635. </listitem>
  636. <listitem>
  637. <para>
  638. --extract (-x) &lt;debfile&gt; &lt;dir&gt; - Extracts the data archive of a
  639. debian package under the directory &lt;dir&gt;.
  640. </para>
  641. </listitem>
  642. <listitem>
  643. <para>
  644. --vextract (-X) &lt;debfile&gt; &lt;dir&gt; - Same as --extract, except it
  645. is equivalent of giving tar the '-v' option - it prints the filenames as it
  646. extracts them.
  647. </para>
  648. </listitem>
  649. <listitem>
  650. <para>
  651. --fsys-tarfile &lt;debfile&gt; - This option outputs a gunzip'd version of
  652. data.tar.gz to stdout.
  653. </para>
  654. </listitem>
  655. <listitem>
  656. <para>
  657. --new - sets the archive format to be used to the new Debian format
  658. </para>
  659. </listitem>
  660. <listitem>
  661. <para>
  662. --old - sets the archive format to be used to the old Debian format
  663. </para>
  664. </listitem>
  665. <listitem>
  666. <para>
  667. --debug - Tells dpkg-deb to produce debugging output
  668. </para>
  669. </listitem>
  670. <listitem>
  671. <para>
  672. --nocheck - Tells dpkg-deb not to check the sanity of the control file
  673. </para>
  674. </listitem>
  675. <listitem>
  676. <para>
  677. --help (-h) - Gives a help message
  678. </para>
  679. </listitem>
  680. <listitem>
  681. <para>
  682. --version - Shows the version number
  683. </para>
  684. </listitem>
  685. <listitem>
  686. <para>
  687. --licence/--license (UK/US spellings) - Shows a brief outline of the GPL
  688. </para>
  689. </listitem>
  690. </itemizedlist>
  691. <section id="s2.2.1"><title>Internal checks used by dpkg-deb when building packages</title>
  692. <para>
  693. Here is a list of the internal checks used by dpkg-deb when building
  694. packages. It is in the order they are done.
  695. </para>
  696. <itemizedlist>
  697. <listitem>
  698. <para>
  699. First, the output Debian archive argument, if it is given, is checked using
  700. stat. If it is a directory, an internal flag is set. This check is only made
  701. if the archive name is specified explicitly on the command-line. If the
  702. argument was not given, the default is the directory name, with ".deb"
  703. appended.
  704. </para>
  705. </listitem>
  706. <listitem>
  707. <para>
  708. Next, the control file is checked, unless the --nocheck flag was specified on
  709. the command-line. dpkg-deb will bomb out if the second argument to --build was
  710. a directory, and --nocheck was specified. Note that dpkg-deb will not be able
  711. to determine the name of the package in this case. In the control file, the
  712. following things are checked:-
  713. </para>
  714. <itemizedlist>
  715. <listitem>
  716. <para>
  717. The package name is checked to see if it contains any invalid characters (see
  718. <xref linkend="control"/> for this).
  719. </para>
  720. </listitem>
  721. <listitem>
  722. <para>
  723. The priority field is checked to see if it uses standard values, and
  724. user-defined values are warned against. However, note that this check is now
  725. redundant, since the control file no longer contains the priority - the
  726. changes file now does this.
  727. </para>
  728. </listitem>
  729. <listitem>
  730. <para>
  731. The control file fields are then checked against the standard list of fields
  732. which appear in control files, and any "user-defined" fields are reported as
  733. warnings.
  734. </para>
  735. </listitem>
  736. <listitem>
  737. <para>
  738. dpkg-deb then checks that the control file contains a valid version number.
  739. </para>
  740. </listitem>
  741. </itemizedlist>
  742. </listitem>
  743. <listitem>
  744. <para>
  745. After this, in the case where a directory was specified to build the .deb file
  746. in, the filename is created as "directory/pkg_ver.deb" or
  747. "directory/pkg_ver_arch.deb", depending on whether the control file contains
  748. an architecture field.
  749. </para>
  750. </listitem>
  751. <listitem>
  752. <para>
  753. Next, dpkg-deb checks for the &lt;dir&gt;/DEBIAN directory. It complains if it
  754. doesn't exist, or if it has permissions &lt; 0755, or &gt; 0775.
  755. </para>
  756. </listitem>
  757. <listitem>
  758. <para>
  759. It then checks that all the files in this subdir are either symlinks or plain
  760. files, and have permissions between 0555 and 0775.
  761. </para>
  762. </listitem>
  763. <listitem>
  764. <para>
  765. The conffiles file is then checked to see if the filenames are too
  766. long. Warnings are produced for each that is. After this, it checks
  767. that the package provides initial copies of each of these conffiles,
  768. and that they are all plain files.
  769. </para>
  770. </listitem>
  771. </itemizedlist>
  772. </section>
  773. </section>
  774. </chapter>
  775. <chapter id="ch3"><title>dpkg internals</title>
  776. <para>
  777. This chapter describes the internals of dpkg itself. Although the low-level
  778. formats are quite simple, what dpkg does in certain cases often does not make
  779. sense.
  780. </para>
  781. <section id="updates"><title>Updates</title>
  782. <para>
  783. This describes the /var/lib/dpkg/updates directory. The function of this
  784. directory is somewhat strange, and seems only to be used internally. A
  785. function called cleanupdates is called whenever the database is scanned. This
  786. function in turn uses
  787. <citerefentry><refentrytitle>scandir</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
  788. to sort the files in this directory. Files who names do not consist entirely
  789. of digits are discarded. dpkg also causes a fatal error if any of the
  790. filenames are different lengths.
  791. </para>
  792. <para>
  793. After having scanned the directory, dpkg in turn parses each file the same way
  794. it parses the status file (they are sorted by the scandir to be in numerical
  795. order). After having done this, it then writes the status information back to
  796. the "status" file, and removes all the "updates" files.
  797. </para>
  798. <para>
  799. These files are created internally by dpkg's "checkpoint" function, and are
  800. cleaned up when dpkg exits cleanly.
  801. </para>
  802. <para>
  803. Juding by the use of the updates directory I would call it a Journal. Inorder
  804. to efficiently ensure the complete integrity of the status file dpkg will
  805. "checkpoint" or journal all of it's activities in the updates directory. By
  806. merging the contents of the updates directory (in order!!) against the original
  807. status file it can get the precise current state of the system, even in the
  808. event of a system failure while dpkg is running.
  809. </para>
  810. <para>
  811. The other option would be to sync-rewrite the status file after each operation,
  812. which would kill performance.
  813. </para>
  814. <para>
  815. It is very important that any program that uses the status file abort if the
  816. updates directory is not empty! The user should be informed to run dpkg
  817. manually (what options though??) to correct the situation.
  818. </para>
  819. </section>
  820. <section id="s3.2"><title>What happens when dpkg reads the database</title>
  821. <para>
  822. First, the status file is read. This gives dpkg an initial idea of the
  823. packages that are there. Next, the updates files are read in, overriding the
  824. status file, and if necessary, the status file is re-written, and updates files
  825. are removed. Finally, the available file is read. The available file is read
  826. with flags which preclude dpkg from updating any status information from it,
  827. though - installed version, etc., and is also told to record that the packages
  828. it reads this time are available, not installed.
  829. </para>
  830. <para>
  831. More information on updates is given above.
  832. </para>
  833. </section>
  834. <section id="s3.3"><title>How dpkg compares version numbers</title>
  835. <para>
  836. Version numbers consist of three parts: the epoch, the upstream version, and
  837. the Debian revision. Dpkg compares these parts in that order. If the epochs
  838. are different, it returns immediately, and so on.
  839. </para>
  840. <para>
  841. However, the important part is how it compares the versions which are
  842. essentially stored as just strings. These are compared in two distinct
  843. parts: those consisting of numerical characters (which are evaluated, and
  844. then compared), and those consisting of other characters. When comparing
  845. non-numerical parts, they are compared as the character values (ASCII),
  846. but non-alphabetical characters are considered "greater than" alphabetical
  847. ones. Also note that longer strings (after excluding differences where
  848. numerical values are equal) are considered "greater than" shorter ones.
  849. </para>
  850. <para>
  851. Here are a few examples of how these rules apply:-
  852. </para>
  853. <screen>
  854. 15 &gt; 10
  855. 0010 == 10
  856. d.r &gt; dsr
  857. 32.d.r == 0032.d.r
  858. d.rnr &lt; d.rnrn
  859. </screen>
  860. </section>
  861. </chapter>
  862. </book>