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