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