Previous Next Contents

6. Basics of the Debian Package Management System

6.1 What is a Debian package?

Packages generally contain all of the files necessary to implement a set of related commands or features. There are two types of Debian packages:

Installation of software by the package system uses "dependencies" which are carefully designed by the package maintainers. These dependencies are documented in the control file associated with each package. For example, the package containing the GNU C compiler (gcc) "depends" on the package binutils which includes the linker and assembler. If a user attempts to install gcc without having first installed binutils, Debian's package system will send an error message that it also needs binutils, and will install gcc only if the user agrees to install binutils first. (However, this facility can be overridden by the insistent user.) See more details on package dependencies below.

Debian's packaging tools can be used to:

6.2 What is the format of a Debian binary package?

A Debian "package", or a Debian archive file, contains the executable files, libraries, and documentation associated with a particular suite of program or set of related programs. Normally, a Debian archive file has a filename that ends in .deb.

The internals of this Debian binary packages format are described in the deb(5) manual page. This internal format is subject to change, therefore always use dpkg-deb(8) for manipulating .deb files.

6.3 Why are Debian package file names so long?

The Debian binary package file names conform to the following convention: <foo>_<VersionNumber>-<DebianRevisionNumber>.deb

Note that foo is supposed to be the package name. As a check, one can learn the package name associated with a particular Debian archive file (.deb file) in one of these ways:

The VVV component is the version number specified by the upstream developer. There are no standards in place here, so the version number may have formats as different as "960428" and "2.7.2.l.3".

The RRR component is the Debian revision number, and is specified by the Debian developer (or an individual user if he chooses to build the package himself). This number corresponds to the revision level of the Debian package (which includes the Debian-specific Makefile, called debian/rules, as well as the Debian control file, usually called debian/control). Thus, a new revision level usually signifies changes in the Debian Makefile, the Debian control file, the installation or removal scripts, or in the configuration files used with the package.

6.4 What is a Debian control file?

Specifics regarding the contents of a Debian control file are provided in the dpkg programmer's manual. Briefly, a sample control file is shown below for the Debian package hello:

Package: hello
Version: 1.3-13
Architecture: i386
Depends: libc5 (>= 5.2.18)
Installed-Size: 31
Maintainer: Ian Jackson <ian@chiark.greenend.org.uk>
Description: The classic greeting, and a good example
 The GNU hello program produces a familiar, friendly greeting.  It
 allows nonprogrammers to use a classic computer science tool which
 would otherwise be unavailable to them.
 .
 Seriously, though: this is an example of how to do a Debian package.
 It is the Debian version of the GNU Project's `hello world' program
 (which is itself an example for the GNU Project).

The Package field gives the package name. This is the name by which the package can be manipulated by the package tools, and usually similar to but not necessarily the same as the first component string in the Debian archive file name.

The version field gives both the upstream developer's version number and (in the last component) the revision level of the Debian package of this program as explained in pkgname .

The Architecture field specifies the chip for which this particular binary was compiled.

The Depends field gives a list of packages that have to be installed in order to install this package successfully.

The Installed-Size indicates how much disk space the installed package will consume. This is intended to be used by installation front-ends in order to show whether there is enough disk space available to install the program .

The Maintainer field gives the e-mail address of the person who is currently responsible for maintaining this package.

The Description field gives a brief summary of the package's features.

6.5 What is a Debian conffile?

Conffiles are listings of configuration files, usually placed in /etc, that the package management system will not overwrite when a package is upgraded. This ensures that local values for the contents of these files will be preserved, and is a critical feature enabling the in-place upgrade of packages on a running system.

To determine exactly which files are preserved during an upgrade, run dpkg --status package.

6.6 What is a Debian preinst, postinst, prerm, and postrm script?

These files are executable scripts which are automatically run before or after a package is installed. Along with a file named control, all of these files are part of the "control" section of a Debian archive file.

The individual files are:

preinst

This script executes before that package will be unpacked from its Debian archive (".deb") file. Many 'preinst' scripts stop services for packages which are being upgraded until their installation or upgrade is completed (following the successful execution of the 'postinst' script).

postinst

This script typically completes any required configuration of the package foo once foo has been unpacked from its Debian archive (".deb") file. Often, 'postinst' scripts ask the user for input, and/or warn the user that if he accepts default values, he should remember to go back and re-configure that package as the situation warrants. Many 'postinst' scripts then execute any commands necessary to start or restart a service once a new package has been installed or upgraded. It is a good idea to check the contents of the 'postinst' script for any configuration advice, when trying out a package for the first time.

prerm

This script typically stops any daemons which are associated with a package. It is executed before the removal of files associated with the package.

postrm

This script typically modifies links or other files associated with foo. (See notes on Virtual packages.)

Currently all of the control files can be found in /var/lib/dpkg/info. The files relevant to package foo begin with the name "foo" and have file extensions of "preinst", "postinst", etc., as appropriate. The file foo.list in that directory lists all of the files that were installed with the package foo. (Note that the location of these files is a dpkg internal; you should not rely on it.)

6.7 What is a Required/Important/Standard/Optional/Extra package?

Each Debian package is assigned a priority by the distribution maintainers, as an aid to the package management system. The priorities are:

6.8 What is a Virtual Package?

A virtual package is a generic name that applies to any one of a group of packages, all of which provide similar basic functionality. For example, both the tin and trn programs are both news readers, and should therefore satisfy any dependency of a program that required a news reader on a system in order to work or to be useful. They are therefore both said to provide the "virtual package" called news-reader.

Similarly, smail and sendmail both provide the functionality of a mail transport agent. They are therefore said to provide the virtual package, "mail transport agent". If either one is installed, then any program depending on the installation of a mail-transport-agent will be satisfied by the existence of this virtual package.

Debian provides a mechanism so that, if more than one package which provide the same virtual package is installed on a system, then system administrators can set one as the preferred package. The relevant command is update-alternatives, and is described further in the section on diversions.

6.9 What is meant by saying that a file Depends/Recommends/Suggests/Conflicts/Replaces/Provides another package ?

The Debian package system has a range of package "dependencies" which are designed to indicate (in a single flag) the level at which Program A can operate independently of the existence of Program B on a given system:

More detailed information on the use of these terms can be found in the Debian programmer's manual.

6.10 What is meant by Pre-Depends?

"Pre-Depends" is a special dependency.

In the case of most packages, dpkg will unpack its archive file (i.e., its .deb file) independently of whether or not the files on which it depends exist on the system. Simplistically, unpacking means that dpkg will extract the files from the archive file that were meant to be installed on your filesystem, and put them in place. If those packages depend on the existence of some other packages on your system, dpkg will refuse to complete the installation by executing its "configure" action until the other packages are installed.

However, for some packages, dpkg will refuse even to unpack them until certain dependencies are resolved. Such packages are said to "Pre-depend" on the presence of some other packages. The Debian project provided this mechanism to support the safe upgrading of systems from a.out format to ELF format, where the order in which packages were unpacked was critical.

More detailed information on the use of these terms can be found in the Debian programmer's manual.

6.11 What is meant by unknown/install/remove/purge/hold in the package status?

These "want" flags tell what the user wanted to do with a package (as indicated either by the user's actions in the "Select" section of dselect, or by the user's direct invocations of dpkg). Their meanings are:

6.12 Where will I get detailed info on creating Debian packages?

See the dpkg programmer's manual and the Debian policy manual


Previous Next Contents