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