1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
7
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
9
<title>The Debian GNU/Linux FAQ - Basics of the Debian package management system</title>
15
<p><a name="ch-pkg_basics"></a></p>
19
[ <a href="ch-ftparchives.en.html">previous</a> ]
20
[ <a href="index.en.html#contents">Contents</a> ]
21
[ <a href="ch-basic_defs.en.html">1</a> ]
22
[ <a href="ch-getting.en.html">2</a> ]
23
[ <a href="ch-compat.en.html">3</a> ]
24
[ <a href="ch-software.en.html">4</a> ]
25
[ <a href="ch-ftparchives.en.html">5</a> ]
27
[ <a href="ch-pkgtools.en.html">7</a> ]
28
[ <a href="ch-uptodate.en.html">8</a> ]
29
[ <a href="ch-kernel.en.html">9</a> ]
30
[ <a href="ch-customizing.en.html">10</a> ]
31
[ <a href="ch-support.en.html">11</a> ]
32
[ <a href="ch-contributing.en.html">12</a> ]
33
[ <a href="ch-redistrib.en.html">13</a> ]
34
[ <a href="ch-nexttime.en.html">14</a> ]
35
[ <a href="ch-faqinfo.en.html">15</a> ]
36
[ <a href="ch-pkgtools.en.html">next</a> ]
42
The Debian GNU/Linux FAQ
43
<br>Chapter 6 - Basics of the Debian package management system
48
<h2><a name="s-package"></a>6.1 What is a Debian package?</h2>
51
Packages generally contain all of the files necessary to implement a set of
52
related commands or features. There are two types of Debian packages:
57
<em>Binary packages</em>, which contain executables, configuration files,
58
man/info pages, copyright information, and other documentation. These packages
59
are distributed in a Debian-specific archive format (see <a
60
href="#s-deb-format">What is the format of a Debian binary package?, Section
61
6.2</a>); they are usually distinguished by having a '.deb' file extension.
62
Binary packages can be unpacked using the Debian utility <samp>dpkg</samp>;
63
details are given in its manual page.
70
<em>Source packages</em>, which consist of a <samp>.dsc</samp> file describing
71
the source package (including the names of the following files), a
72
<samp>.orig.tar.gz</samp> file that contains the original unmodified source in
73
gzip-compressed tar format and usually a <samp>.diff.gz</samp> file that
74
contains the Debian-specific changes to the original source. The utility
75
<samp>dpkg-source</samp> packs and unpacks Debian source archives; details are
76
provided in its manual page.
82
Installation of software by the package system uses "dependencies"
83
which are carefully designed by the package maintainers. These dependencies
84
are documented in the <samp>control</samp> file associated with each package.
85
For example, the package containing the GNU C compiler (<code>gcc</code>)
86
"depends" on the package <code>binutils</code> which includes the
87
linker and assembler. If a user attempts to install <code>gcc</code> without
88
having first installed <code>binutils</code>, the package management system
89
(dpkg) will send an error message that it also needs <code>binutils</code>, and
90
stop installing <code>gcc</code>. (However, this facility can be overridden by
91
the insistent user, see <code>dpkg(8)</code>.) See more in <a
92
href="#s-depends">What is meant by saying that a package <em>Depends</em>,
93
<em>Recommends</em>, <em>Suggests</em>, <em>Conflicts</em>, <em>Replaces</em>
94
or <em>Provides</em> another package?, Section 6.9</a> below.
98
Debian's packaging tools can be used to:
103
manipulate and manage packages or parts of packages,
110
aid the user in the break-up of packages that must be transmitted through a
111
limited-size medium such as floppy disks,
118
aid developers in the construction of package archives, and
125
aid users in the installation of packages which reside on a remote FTP site.
132
<h2><a name="s-deb-format"></a>6.2 What is the format of a Debian binary package?</h2>
135
A Debian "package", or a Debian archive file, contains the executable
136
files, libraries, and documentation associated with a particular suite of
137
program or set of related programs. Normally, a Debian archive file has a
138
filename that ends in <samp>.deb</samp>.
142
The internals of this Debian binary packages format are described in the
143
<code>deb(5)</code> manual page. This internal format is subject to change
144
(between major releases of Debian GNU/Linux), therefore please always use
145
<code>dpkg-deb(1)</code> for manipulating <samp>.deb</samp> files.
150
<h2><a name="s-pkgname"></a>6.3 Why are Debian package file names so long?</h2>
153
The Debian binary package file names conform to the following convention:
154
<foo>_<VersionNumber>-<DebianRevisionNumber>.deb
158
Note that <samp>foo</samp> is supposed to be the package name. As a check, one
159
can learn the package name associated with a particular Debian archive file
160
(.deb file) in one of these ways:
165
inspect the "Packages" file in the directory where it was stored at a
166
Debian FTP archive site. This file contains a stanza describing each package;
167
the first field in each stanza is the formal package name.
174
use the command <samp>dpkg --info foo_VVV-RRR.deb</samp> (where VVV and RRR are
175
the version and revision of the package in question, respectively). This
176
displays, among other things, the package name corresponding to the archive
183
The <samp>VVV</samp> component is the version number specified by the upstream
184
developer. There are no standards in place here, so the version number may
185
have formats as different as "19990513" and "1.3.8pre1".
189
The <samp>RRR</samp> component is the Debian revision number, and is specified
190
by the Debian developer (or an individual user if he chooses to build the
191
package himself). This number corresponds to the revision level of the Debian
192
package, thus, a new revision level usually signifies changes in the Debian
193
Makefile (<samp>debian/rules</samp>), the Debian control file
194
(<samp>debian/control</samp>), the installation or removal scripts
195
(<samp>debian/p*</samp>), or in the configuration files used with the package.
200
<h2><a name="s-controlfile"></a>6.4 What is a Debian control file?</h2>
203
Specifics regarding the contents of a Debian control file are provided in the
204
Debian Policy Manual, section 5, see <a
205
href="ch-support.en.html#s-debiandocs">What other documentation exists on and
206
for a Debian system?, Section 11.1</a>.
210
Briefly, a sample control file is shown below for the Debian package hello:
218
Maintainer: Adam Heath <doogie@debian.org>
221
Depends: libc6 (>= 2.1)
222
Description: The classic greeting, and a good example
223
The GNU hello program produces a familiar, friendly greeting. It
224
allows nonprogrammers to use a classic computer science tool which
225
would otherwise be unavailable to them.
227
Seriously, though: this is an example of how to do a Debian package.
228
It is the Debian version of the GNU Project's `hello world' program
229
(which is itself an example for the GNU Project).
233
The Package field gives the package name. This is the name by which the
234
package can be manipulated by the package tools, and usually similar to but not
235
necessarily the same as the first component string in the Debian archive file
240
The Version field gives both the upstream developer's version number and (in
241
the last component) the revision level of the Debian package of this program as
242
explained in <a href="#s-pkgname">Why are Debian package file names so long?,
247
The Architecture field specifies the chip for which this particular binary was
252
The Depends field gives a list of packages that have to be installed in order
253
to install this package successfully.
257
The Installed-Size indicates how much disk space the installed package will
258
consume. This is intended to be used by installation front-ends in order to
259
show whether there is enough disk space available to install the program.
263
The Section line gives the "section" where this Debian package is
264
stored at the Debian FTP sites. This is the name of a subdirectory (within one
265
of the main directories, see <a href="ch-ftparchives.en.html#s-dirtree">What
266
are all those directories at the Debian FTP archives?, Section 5.1</a>) where
267
the package is stored.
271
The Priority indicates how important is this package for installation, so that
272
semi-intelligent software like dselect or console-apt can sort the package into
273
a category of e.g. packages optionally installed. See <a
274
href="#s-priority">What is an <em>Essential</em> <em>Required</em>,
275
<em>Important</em>, <em>Standard</em>, <em>Optional</em>, or <em>Extra</em>
276
package?, Section 6.7</a>.
280
The Maintainer field gives the e-mail address of the person who is currently
281
responsible for maintaining this package.
285
The Description field gives a brief summary of the package's features.
289
For more information about all possible fields a package can have, please see
290
the Debian Policy Manual, section 5., "Control files and their
296
<h2><a name="s-conffile"></a>6.5 What is a Debian conffile?</h2>
299
Conffiles is a list of configuration files (usually placed in
300
<samp>/etc</samp>) that the package management system will not overwrite when
301
the package is upgraded. This ensures that local values for the contents of
302
these files will be preserved, and is a critical feature enabling the in-place
303
upgrade of packages on a running system.
307
To determine exactly which files are preserved during an upgrade, run:
311
dpkg --status package
315
And look under "Conffiles:".
320
<h2><a name="s-maintscripts"></a>6.6 What is a Debian preinst, postinst, prerm, and postrm script?</h2>
323
These files are executable scripts which are automatically run before or after
324
a package is installed. Along with a file named <samp>control</samp>, all of
325
these files are part of the "control" section of a Debian archive
330
The individual files are:
336
This script executes before that package will be unpacked from its Debian
337
archive (".deb") file. Many 'preinst' scripts stop services for
338
packages which are being upgraded until their installation or upgrade is
339
completed (following the successful execution of the 'postinst' script).
347
This script typically completes any required configuration of the package
348
<samp>foo</samp> once <samp>foo</samp> has been unpacked from its Debian
349
archive (".deb") file. Often, 'postinst' scripts ask the user for
350
input, and/or warn the user that if he accepts default values, he should
351
remember to go back and re-configure that package as the situation warrants.
352
Many 'postinst' scripts then execute any commands necessary to start or restart
353
a service once a new package has been installed or upgraded.
361
This script typically stops any daemons which are associated with a package.
362
It is executed before the removal of files associated with the package.
370
This script typically modifies links or other files associated with
371
<samp>foo</samp>, and/or removes files created by the package. (Also see <a
372
href="#s-virtual">What is a Virtual Package?, Section 6.8</a>.)
378
Currently all of the control files can be found in directory
379
<samp>/var/lib/dpkg/info</samp>. The files relevant to package
380
<samp>foo</samp> begin with the name "foo" and have file extensions
381
of "preinst", "postinst", etc., as appropriate. The file
382
<samp>foo.list</samp> in that directory lists all of the files that were
383
installed with the package <samp>foo</samp>. (Note that the location of these
384
files is a dpkg internal; you should not rely on it.)
389
<h2><a name="s-priority"></a>6.7 What is an <em>Essential</em> <em>Required</em>, <em>Important</em>, <em>Standard</em>, <em>Optional</em>, or <em>Extra</em> package?</h2>
392
Each Debian package is assigned a <em>priority</em> by the distribution
393
maintainers, as an aid to the package management system. The priorities are:
398
<strong>Required</strong>: packages that are necessary for the proper
399
functioning of the system.
403
This includes all tools that are necessary to repair system defects. You must
404
not remove these packages or your system may become totally broken and you may
405
probably not even be able to use dpkg to put things back. Systems with only
406
the Required packages are probably unusable, but they do have enough
407
functionality to allow the sysadmin to boot and install more software.
414
<strong>Important</strong> packages should be found on any Unix-like system.
418
Other packages which the system will not run well or be usable without will be
419
here. This does <em>NOT</em> include Emacs or X11 or TeX or any other large
420
applications. These packages only constitute the bare infrastructure.
427
<strong>Standard</strong> packages are standard on any Linux system, including
428
a reasonably small but not too limited character-mode system. Tools are
429
included to be able to browse the web (using w3m), send e-mail (with mutt) and
430
download files from FTP servers.
434
This is what will install by default if users do not select anything else. It
435
does not include many large applications, but it does include the Python
436
interpreter and some server software like OpenSSH (for remote administration),
437
Exim (for mail delivery, although it can be configured for local delivery
438
only), an identd server (pidentd) and the RPC portmapper
439
(<samp>portmap</samp>). It also includes some common generic documentation
440
that most users will find helpful.
447
<strong>Optional</strong> packages include all those that you might reasonably
448
want to install if you did not know what it was, or do not have specialized
453
This includes X11, a full TeX distribution, and lots of applications.
460
<strong>Extra</strong>: packages that either conflict with others with higher
461
priorities, are only likely to be useful if you already know what they are, or
462
have specialized requirements that make them unsuitable for
463
"Optional".
469
If you do a default Debian installation all the packages of priority
470
<strong>Standard</strong> or higher will be installed in your system. If you
471
select pre-defined tasks you will get lower priority packages too.
475
Additionally, some packages are marked as <strong>Essential</strong> since they
476
are absolutely necessary for the proper functioning of the system. The package
477
management tools will refuse to remove these.
482
<h2><a name="s-virtual"></a>6.8 What is a Virtual Package?</h2>
485
A virtual package is a generic name that applies to any one of a group of
486
packages, all of which provide similar basic functionality. For example, both
487
the <samp>tin</samp> and <samp>trn</samp> programs are news readers, and should
488
therefore satisfy any dependency of a program that required a news reader on a
489
system, in order to work or to be useful. They are therefore both said to
490
provide the "virtual package" called <samp>news-reader</samp>.
494
Similarly, <samp>smail</samp> and <samp>sendmail</samp> both provide the
495
functionality of a mail transport agent. They are therefore said to provide
496
the virtual package, "mail transport agent". If either one is
497
installed, then any program depending on the installation of a
498
<samp>mail-transport-agent</samp> will be satisfied by the existence of this
503
Debian provides a mechanism so that, if more than one package which provide the
504
same virtual package is installed on a system, then system administrators can
505
set one as the preferred package. The relevant command is
506
<samp>update-alternatives</samp>, and is described further in <a
507
href="ch-customizing.en.html#s-diverse">Some users like mawk, others like gawk;
508
some like vim, others like elvis; some like trn, others like tin; how does
509
Debian support diversity?, Section 10.10</a>.
514
<h2><a name="s-depends"></a>6.9 What is meant by saying that a package <em>Depends</em>, <em>Recommends</em>, <em>Suggests</em>, <em>Conflicts</em>, <em>Replaces</em> or <em>Provides</em> another package?</h2>
517
The Debian package system has a range of package "dependencies" which
518
are designed to indicate (in a single flag) the level at which Program A can
519
operate independently of the existence of Program B on a given system:
524
Package A <em>depends</em> on Package B if B absolutely must be installed in
525
order to run A. In some cases, A depends not only on B, but on a version of B.
526
In this case, the version dependency is usually a lower limit, in the sense
527
that A depends on any version of B more recent than some specified version.
534
Package A <em>recommends</em> Package B, if the package maintainer judges that
535
most users would not want A without also having the functionality provided by
543
Package A <em>suggests</em> Package B if B contains files that are related to
544
(and usually enhance) the functionality of A.
551
Package A <em>conflicts</em> with Package B when A will not operate if B is
552
installed on the system. Most often, conflicts are cases where A contains
553
files which are an improvement over those in B. "Conflicts" are
554
often combined with "replaces".
561
Package A <em>replaces</em> Package B when files installed by B are removed and
562
(in some cases) over-written by files in A.
569
Package A <em>provides</em> Package B when all of the files and functionality
570
of B are incorporated into A. This mechanism provides a way for users with
571
constrained disk space to get only that part of package A which they really
578
More detailed information on the use of each these terms can be found in the
584
<h2><a name="s-pre-depends"></a>6.10 What is meant by Pre-Depends?</h2>
587
"Pre-Depends" is a special dependency. In the case of most packages,
588
<samp>dpkg</samp> will unpack its archive file (i.e., its <samp>.deb</samp>
589
file) independently of whether or not the files on which it depends exist on
590
the system. Simplistically, unpacking means that <samp>dpkg</samp> will
591
extract the files from the archive file that were meant to be installed on your
592
file system, and put them in place. If those packages <em>depend</em> on the
593
existence of some other packages on your system, <samp>dpkg</samp> will refuse
594
to complete the installation (by executing its "configure" action)
595
until the other packages are installed.
599
However, for some packages, <samp>dpkg</samp> will refuse even to unpack them
600
until certain dependencies are resolved. Such packages are said to
601
"Pre-depend" on the presence of some other packages. The Debian
602
project provided this mechanism to support the safe upgrading of systems from
603
<samp>a.out</samp> format to <samp>ELF</samp> format, where the <em>order</em>
604
in which packages were unpacked was critical. There are other large upgrade
605
situations where this method is useful, e.g. the packages with the required
606
priority and their LibC dependency.
610
As before, more detailed information about this can be found in the Policy
616
<h2><a name="s-pkgstatus"></a>6.11 What is meant by <em>unknown</em>, <em>install</em>, <em>remove</em> <em>purge</em> and <em>hold</em> in the package status?</h2>
619
These "want" flags tell what the user wanted to do with a package (as
620
indicated either by the user's actions in the "Select" section of
621
<samp>dselect</samp>, or by the user's direct invocations of
631
unknown - the user has never indicated whether he wants the package
638
install - the user wants the package installed or upgraded
645
remove - the user wants the package removed, but does not want to remove any
646
existing configuration files.
653
purge - the user wants the package to be removed completely, including its
661
hold - the user wants this package not to be processed, i.e., he wants to keep
662
the current version with the current status whatever that is.
669
<h2><a name="s-puttingonhold"></a>6.12 How do I put a package on hold?</h2>
672
There are three ways of holding back packages, with dpkg, aptitude or with
677
With dpkg, you just have to export the list of package selections, with:
681
dpkg --get-selections \* > selections.txt
685
Then edit the resulting file <code>selections.txt</code>, change the line
686
containing the package you wish to hold, e.g. <code>libc6</code>, from this:
702
Save the file, and reload it into dpkg database with:
706
dpkg --set-selections < selections.txt
710
With aptitude, you can hold a package using
714
aptitude hold package_name
718
and remove the hold with
722
aptitude unhold package_name
726
With dselect, you just have to enter the [S]elect screen, find the package you
727
wish to hold in its present state, and press the `=' key (or `H'). The changes
728
will go live immediately after you exit the [S]elect screen.
733
<h2><a name="s-sourcepkgs"></a>6.13 How do I install a source package?</h2>
736
Debian source packages can't actually be "installed", they are just
737
unpacked in whatever directory you want to build the binary packages they
742
Source packages are distributed on most of the same mirrors where you can
743
obtain the binary packages. If you set up your APT's
744
<code>sources.list(5)</code> to include the appropriate "deb-src"
745
lines, you'll be able to easily download any source packages by running
753
To help you in actually building the source package, Debian source package
754
provide the so-called build-dependencies mechanism. This means that the source
755
package maintainer keeps a list of other packages that are required to build
756
their package. To see how this is useful, run
760
apt-get build-dep foo
764
before building the source.
769
<h2><a name="s-sourcebuild"></a>6.14 How do I build binary packages from a source package?</h2>
772
You will need all of foo_*.dsc, foo_*.tar.gz and foo_*.diff.gz to compile the
773
source (note: there is no .diff.gz for some packages that are native to
778
Once you have them (<a href="#s-sourcepkgs">How do I install a source package?,
779
Section 6.13</a>), if you have the <code>dpkg-dev</code> package installed, the
784
dpkg-source -x foo_version-revision.dsc
788
will extract the package into a directory called <samp>foo-version</samp>.
792
If you want just to compile the package, you may cd into
793
<samp>foo-version</samp> directory and issue the command
797
dpkg-buildpackage -rfakeroot -b
801
to build the package (note that this also requires the <code>fakeroot</code>
806
dpkg -i ../foo_version-revision_arch.deb
810
to install the newly-built package(s).
815
<h2><a name="s-creatingdebs"></a>6.15 How do I create Debian packages myself?</h2>
818
For more detailed description on this, read the New Maintainers' Guide,
819
available in the <code>maint-guide</code> package, or at <code><a
820
href="http://www.debian.org/doc/devel-manuals#maint-guide">http://www.debian.org/doc/devel-manuals#maint-guide</a></code>.
826
[ <a href="ch-ftparchives.en.html">previous</a> ]
827
[ <a href="index.en.html#contents">Contents</a> ]
828
[ <a href="ch-basic_defs.en.html">1</a> ]
829
[ <a href="ch-getting.en.html">2</a> ]
830
[ <a href="ch-compat.en.html">3</a> ]
831
[ <a href="ch-software.en.html">4</a> ]
832
[ <a href="ch-ftparchives.en.html">5</a> ]
834
[ <a href="ch-pkgtools.en.html">7</a> ]
835
[ <a href="ch-uptodate.en.html">8</a> ]
836
[ <a href="ch-kernel.en.html">9</a> ]
837
[ <a href="ch-customizing.en.html">10</a> ]
838
[ <a href="ch-support.en.html">11</a> ]
839
[ <a href="ch-contributing.en.html">12</a> ]
840
[ <a href="ch-redistrib.en.html">13</a> ]
841
[ <a href="ch-nexttime.en.html">14</a> ]
842
[ <a href="ch-faqinfo.en.html">15</a> ]
843
[ <a href="ch-pkgtools.en.html">next</a> ]
849
The Debian GNU/Linux FAQ
853
version 3.1.5, 17 January 2007<br>
855
Authors are listed at <a href="ch-faqinfo.en.html#s-authors">Debian FAQ Authors</a><br>