1 <?xml version=
"1.0" encoding=
"utf-8" standalone=
"no"?>
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
5 <!ENTITY % aptent SYSTEM
"apt.ent">
8 <!ENTITY % aptverbatiment SYSTEM
"apt-verbatim.ent">
11 <!ENTITY % aptvendor SYSTEM
"apt-vendor.ent">
21 <!-- The last update date -->
22 <date>2012-
06-
09T00:
00:
00Z
</date>
26 <refentrytitle>apt_preferences
</refentrytitle>
27 <manvolnum>5</manvolnum>
28 <refmiscinfo class=
"manual">APT
</refmiscinfo>
31 <!-- Man page title -->
33 <refname>apt_preferences
</refname>
34 <refpurpose>Preference control file for APT
</refpurpose>
38 <title>Description
</title>
39 <para>The APT preferences file
<filename>/etc/apt/preferences
</filename>
40 and the fragment files in the
<filename>/etc/apt/preferences.d/
</filename>
41 folder can be used to control which versions of packages will be selected
42 for installation.
</para>
44 <para>Several versions of a package may be available for installation when
45 the &sources-list; file contains references to more than one distribution
46 (for example,
<literal>stable
</literal> and
<literal>testing
</literal>).
47 APT assigns a priority to each version that is available.
48 Subject to dependency constraints,
<command>apt-get
</command> selects the
49 version with the highest priority for installation.
50 The APT preferences override the priorities that APT assigns to
51 package versions by default, thus giving the user control over which
52 one is selected for installation.
</para>
54 <para>Several instances of the same version of a package may be available when
55 the &sources-list; file contains references to more than one source.
56 In this case
<command>apt-get
</command> downloads the instance listed
57 earliest in the &sources-list; file.
58 The APT preferences do not affect the choice of instance, only
59 the choice of version.
</para>
61 <para>Preferences are a strong power in the hands of a system administrator
62 but they can become also their biggest nightmare if used without care!
63 APT will not question the preferences, so wrong settings can
64 lead to uninstallable packages or wrong decisions while upgrading packages.
65 Even more problems will arise if multiple distribution releases are mixed
66 without a good understanding of the following paragraphs.
67 Packages included in a specific release aren't tested in (and
68 therefore don't always work as expected in) older or newer releases, or
69 together with other packages from different releases.
70 You have been warned.
</para>
72 <para>Note that the files in the
<filename>/etc/apt/preferences.d
</filename>
73 directory are parsed in alphanumeric ascending order and need to obey the
74 following naming convention: The files have either no or "
<literal>pref
</literal>"
75 as filename extension and only contain alphanumeric, hyphen (-),
76 underscore (_) and period (.) characters.
77 Otherwise APT will print a notice that it has ignored a file, unless that
78 file matches a pattern in the <literal>Dir::Ignore-Files-Silently</literal>
79 configuration list - in which case it will be silently ignored.</para>
81 <refsect2><title>APT's Default Priority Assignments</title>
83 <para>If there is no preferences file or if there is no entry in the file
84 that applies to a particular version then the priority assigned to that
85 version is the priority of the distribution to which that version
86 belongs. It is possible to single out a distribution, "the target release",
87 which receives a higher priority than other distributions do by default.
88 The target release can be set on the
<command>apt-get
</command> command
89 line or in the APT configuration file
<filename>/etc/apt/apt.conf
</filename>.
90 Note that this has precedence over any general priority you set in the
91 <filename>/etc/apt/preferences
</filename> file described later, but not
92 over specifically pinned packages.
96 <command>apt-get install -t testing
<replaceable>some-package
</replaceable></command>
99 APT::Default-Release "stable";
103 <para>If the target release has been specified then APT uses the following
104 algorithm to set the priorities of the versions of a package. Assign:
108 <term>priority
1</term>
109 <listitem><simpara>to the versions coming from archives which in their
<filename>Release
</filename>
110 files are marked as "NotAutomatic: yes" but
<emphasis>not
</emphasis> as "ButAutomaticUpgrades: yes"
111 like the Debian
<literal>experimental
</literal> archive.
</simpara></listitem>
115 <term>priority
100</term>
116 <listitem><simpara>to the version that is already installed (if any) and to the versions coming
117 from archives which in their
<filename>Release
</filename> files are marked as "NotAutomatic: yes" and
118 "ButAutomaticUpgrades: yes" like the Debian backports archive since
<literal>squeeze-backports
</literal>.
119 </simpara></listitem>
123 <term>priority
500</term>
124 <listitem><simpara>to the versions that are not installed and do not belong to the target release.
</simpara></listitem>
128 <term>priority
990</term>
129 <listitem><simpara>to the versions that are not installed and belong to the target release.
</simpara></listitem>
134 <para>If the target release has not been specified then APT simply assigns
135 priority
100 to all installed package versions and priority
500 to all
136 uninstalled package versions, except versions coming from archives which
137 in their
<filename>Release
</filename> files are marked as "NotAutomatic: yes" -
138 these versions get the priority
1 or priority
100 if it is additionally marked
139 as "ButAutomaticUpgrades: yes".
</para>
141 <para>APT then applies the following rules, listed in order of precedence,
142 to determine which version of a package to install.
144 <listitem><simpara>Never downgrade unless the priority of an available
145 version exceeds
1000. ("Downgrading" is installing a less recent version
146 of a package in place of a more recent version. Note that none of APT's
147 default priorities exceeds
1000; such high priorities can only be set in
148 the preferences file. Note also that downgrading a package
149 can be risky.)
</simpara></listitem>
150 <listitem><simpara>Install the highest priority version.
</simpara></listitem>
151 <listitem><simpara>If two or more versions have the same priority,
152 install the most recent one (that is, the one with the higher version
153 number).
</simpara></listitem>
154 <listitem><simpara>If two or more versions have the same priority and
155 version number but either the packages differ in some of their metadata or the
156 <literal>--reinstall
</literal> option is given, install the uninstalled one.
</simpara></listitem>
160 <para>In a typical situation, the installed version of a package (priority
100)
161 is not as recent as one of the versions available from the sources listed in
162 the &sources-list; file (priority
500 or
990). Then the package will be upgraded
163 when
<command>apt-get install
<replaceable>some-package
</replaceable></command>
164 or
<command>apt-get upgrade
</command> is executed.
167 <para>More rarely, the installed version of a package is
<emphasis>more
</emphasis> recent
168 than any of the other available versions. The package will not be downgraded
169 when
<command>apt-get install
<replaceable>some-package
</replaceable></command>
170 or
<command>apt-get upgrade
</command> is executed.
</para>
172 <para>Sometimes the installed version of a package is more recent than the
173 version belonging to the target release, but not as recent as a version
174 belonging to some other distribution. Such a package will indeed be upgraded
175 when
<command>apt-get install
<replaceable>some-package
</replaceable></command>
176 or
<command>apt-get upgrade
</command> is executed,
177 because at least
<emphasis>one
</emphasis> of the available versions has a higher
178 priority than the installed version.
</para>
181 <refsect2><title>The Effect of APT Preferences
</title>
183 <para>The APT preferences file allows the system administrator to control the
184 assignment of priorities. The file consists of one or more multi-line records
185 separated by blank lines. Records can have one of two forms, a specific form
189 <simpara>The specific form assigns a priority (a "Pin-Priority") to one or more
190 specified packages with a specified version or version range. For example,
191 the following record assigns a high priority to all versions of
192 the
<filename>perl
</filename> package whose version number begins with "
<literal>&good-perl;
</literal>".
193 Multiple packages can be separated by spaces.</simpara>
197 Pin: version &good-perl;*
202 <listitem><simpara>The general form assigns a priority to all of the package versions in a
203 given distribution (that is, to all the versions of packages that are
204 listed in a certain <filename>Release</filename> file) or to all of the package
205 versions coming from a particular Internet site, as identified by the
206 site's fully qualified domain name.</simpara>
208 <simpara>This general-form entry in the APT preferences file applies only
209 to groups of packages. For example, the following record assigns a high
210 priority to all package versions available from the local site.</simpara>
218 <simpara>A note of caution: the keyword used here is "
<literal>origin
</literal>"
219 which can be used to match a hostname. The following record will assign a high priority
220 to all versions available from the server identified by the hostname "ftp.de.debian.org
"</simpara>
223 Pin: origin "ftp.de.debian.org"
226 <simpara>This should
<emphasis>not
</emphasis> be confused with the Origin of a distribution as
227 specified in a
<filename>Release
</filename> file. What follows the "Origin:" tag
228 in a
<filename>Release
</filename> file is not an Internet address
229 but an author or vendor name, such as "Debian" or "Ximian".
</simpara>
231 <simpara>The following record assigns a low priority to all package versions
232 belonging to any distribution whose Archive name is "
<literal>unstable
</literal>".</simpara>
236 Pin: release a=unstable
240 <simpara>The following record assigns a high priority to all package versions
241 belonging to any distribution whose Codename is "<literal>&testing-codename;
</literal>".</simpara>
245 Pin: release n=&testing-codename;
249 <simpara>The following record assigns a high priority to all package versions
250 belonging to any release whose Archive name is "<literal>stable
</literal>"
251 and whose release Version number is "<literal>&stable-version;
</literal>".</simpara>
255 Pin: release a=stable, v=&stable-version;
264 <refsect2><title>Regular expressions and &glob; syntax</title>
266 APT also supports pinning by &glob; expressions, and regular
267 expressions surrounded by slashes. For example, the following
268 example assigns the priority 500 to all packages from
269 experimental where the name starts with gnome (as a &glob;-like
270 expression) or contains the word kde (as a POSIX extended regular
271 expression surrounded by slashes).
275 Package: gnome* /kde/
276 Pin: release n=experimental
281 The rule for those expressions is that they can occur anywhere
282 where a string can occur. Thus, the following pin assigns the
283 priority 990 to all packages from a release starting with &ubuntu-codename;.
288 Pin: release n=&ubuntu-codename;*
293 If a regular expression occurs in a <literal>Package</literal> field,
294 the behavior is the same as if this regular expression were replaced
295 with a list of all package names it matches. It is undecided whether
296 this will change in the future; thus you should always list wild-card
297 pins first, so later specific pins override it.
299 The pattern "<literal>*
</literal>" in a Package field is not considered
300 a &glob; expression in itself.
309 <title>How APT Interprets Priorities</title>
312 Priorities (P) assigned in the APT preferences file must be positive
313 or negative integers. They are interpreted as follows (roughly speaking):
317 <term>P >= 1000</term>
318 <listitem><simpara>causes a version to be installed even if this
319 constitutes a downgrade of the package</simpara></listitem>
322 <term>990 <= P < 1000</term>
323 <listitem><simpara>causes a version to be installed
324 even if it does not come from the target release,
325 unless the installed version is more recent</simpara></listitem>
328 <term>500 <= P < 990</term>
329 <listitem><simpara>causes a version to be installed
330 unless there is a version available belonging to the target release
331 or the installed version is more recent</simpara></listitem>
334 <term>100 <= P < 500</term>
335 <listitem><simpara>causes a version to be installed
336 unless there is a version available belonging to some other
337 distribution or the installed version is more recent</simpara></listitem>
340 <term>0 < P < 100</term>
341 <listitem><simpara>causes a version to be installed
342 only if there is no installed version of the package</simpara></listitem>
345 <term>P < 0</term>
346 <listitem><simpara>prevents the version from being installed</simpara></listitem>
351 <para>If any specific-form records match an available package version then the
352 first such record determines the priority of the package version.
354 if any general-form records match an available package version then the
355 first such record determines the priority of the package version.</para>
357 <para>For example, suppose the APT preferences file contains the three
358 records presented earlier:</para>
362 Pin: version &good-perl;*
370 Pin: release unstable
376 <listitem><simpara>The most recent available version of the
<literal>perl
</literal>
377 package will be installed, so long as that version's version number begins
378 with "
<literal>&good-perl;
</literal>". If <emphasis>any</emphasis> &good-perl;* version of <literal>perl</literal> is
379 available and the installed version is &bad-perl;*, then <literal>perl</literal> will be
380 downgraded.</simpara></listitem>
381 <listitem><simpara>A version of any package other than <literal>perl</literal>
382 that is available from the local system has priority over other versions,
383 even versions belonging to the target release.
384 </simpara></listitem>
385 <listitem><simpara>A version of a package whose origin is not the local
386 system but some other site listed in &sources-list; and which belongs to
387 an <literal>unstable</literal> distribution is only installed if it is selected
388 for installation and no version of the package is already installed.
389 </simpara></listitem>
395 <title>Determination of Package Version and Distribution Properties</title>
397 <para>The locations listed in the &sources-list; file should provide
398 <filename>Packages</filename> and <filename>Release</filename> files
399 to describe the packages available at that location. </para>
401 <para>The <filename>Packages</filename> file is normally found in the directory
402 <filename>.../dists/<replaceable>dist-name</replaceable>/<replaceable>component</replaceable>/<replaceable>arch</replaceable></filename>:
403 for example, <filename>.../dists/stable/main/binary-i386/Packages</filename>.
404 It consists of a series of multi-line records, one for each package available
405 in that directory. Only two lines in each record are relevant for setting
409 <term>the <literal>Package:</literal> line</term>
410 <listitem><simpara>gives the package name</simpara></listitem>
413 <term>the <literal>Version:</literal> line</term>
414 <listitem><simpara>gives the version number for the named package</simpara></listitem>
419 <para>The <filename>Release</filename> file is normally found in the directory
420 <filename>.../dists/<replaceable>dist-name</replaceable></filename>:
421 for example, <filename>.../dists/stable/Release</filename>,
422 or <filename>.../dists/&stable-codename;/Release</filename>.
423 It consists of a single multi-line record which applies to <emphasis>all</emphasis> of
424 the packages in the directory tree below its parent. Unlike the
425 <filename>Packages</filename> file, nearly all of the lines in a <filename>Release</filename>
426 file are relevant for setting APT priorities:
430 <term>the <literal>Archive:</literal> or <literal>Suite:</literal> line</term>
431 <listitem><simpara>names the archive to which all the packages
432 in the directory tree belong. For example, the line
435 specifies that all of the packages in the directory
436 tree below the parent of the
<filename>Release
</filename> file are in a
437 <literal>stable
</literal> archive. Specifying this value in the APT preferences file
438 would require the line:
441 Pin: release a=stable
447 <term>the
<literal>Codename:
</literal> line
</term>
448 <listitem><simpara>names the codename to which all the packages
449 in the directory tree belong. For example, the line
450 "Codename: &testing-codename;"
451 specifies that all of the packages in the directory
452 tree below the parent of the
<filename>Release
</filename> file belong to a version named
453 <literal>&testing-codename;
</literal>. Specifying this value in the APT preferences file
454 would require the line:
457 Pin: release n=&testing-codename;
463 <term>the
<literal>Version:
</literal> line
</term>
464 <listitem><simpara>names the release version. For example, the
465 packages in the tree might belong to Debian release
466 version &stable-version;. Note that there is normally no version number for the
467 <literal>testing
</literal> and
<literal>unstable
</literal> distributions because they
468 have not been released yet. Specifying this in the APT preferences
469 file would require one of the following lines.
473 Pin: release v=&stable-version;
474 Pin: release a=stable, v=&stable-version;
475 Pin: release &stable-version;
482 <term>the
<literal>Component:
</literal> line
</term>
483 <listitem><simpara>names the licensing component associated with the
484 packages in the directory tree of the
<filename>Release
</filename> file.
485 For example, the line "Component: main" specifies that
486 all the packages in the directory tree are from the
<literal>main
</literal>
487 component, which entails that they are licensed under terms listed
488 in the Debian Free Software Guidelines. Specifying this component
489 in the APT preferences file would require the line:
498 <term>the
<literal>Origin:
</literal> line
</term>
499 <listitem><simpara>names the originator of the packages in the
500 directory tree of the
<filename>Release
</filename> file. Most commonly, this is
501 <literal>Debian
</literal>. Specifying this origin in the APT preferences file
502 would require the line:
505 Pin: release o=Debian
511 <term>the
<literal>Label:
</literal> line
</term>
512 <listitem><simpara>names the label of the packages in the directory tree
513 of the
<filename>Release
</filename> file. Most commonly, this is
514 <literal>Debian
</literal>. Specifying this label in the APT preferences file
515 would require the line:
518 Pin: release l=Debian
525 <para>All of the
<filename>Packages
</filename> and
<filename>Release
</filename>
526 files retrieved from locations listed in the &sources-list; file are stored
527 in the directory
<filename>/var/lib/apt/lists
</filename>, or in the file named
528 by the variable
<literal>Dir::State::Lists
</literal> in the
<filename>apt.conf
</filename> file.
529 For example, the file
530 <filename>debian.lcs.mit.edu_debian_dists_unstable_contrib_binary-i386_Release
</filename>
531 contains the
<filename>Release
</filename> file retrieved from the site
532 <literal>debian.lcs.mit.edu
</literal> for
<literal>binary-i386
</literal> architecture
533 files from the
<literal>contrib
</literal> component of the
<literal>unstable
</literal>
538 <title>Optional Lines in an APT Preferences Record
</title>
540 <para>Each record in the APT preferences file can optionally begin with
541 one or more lines beginning with the word
<literal>Explanation:
</literal>.
542 This provides a place for comments.
</para>
547 <title>Examples
</title>
549 <title>Tracking Stable
</title>
551 <para>The following APT preferences file will cause APT to assign a
552 priority higher than the default (
500) to all package versions belonging
553 to a
<literal>stable
</literal> distribution and a prohibitively low priority to
554 package versions belonging to other
<literal>Debian
</literal> distributions.
557 Explanation: Uninstall or do not install any Debian-originated
558 Explanation: package versions other than those in the stable distro
560 Pin: release a=stable
564 Pin: release o=Debian
569 <para>With a suitable &sources-list; file and the above preferences file,
570 any of the following commands will cause APT to upgrade to the
571 latest
<literal>stable
</literal> version(s).
574 apt-get install
<replaceable>package-name
</replaceable>
580 <para>The following command will cause APT to upgrade the specified
581 package to the latest version from the
<literal>testing
</literal> distribution;
582 the package will not be upgraded again unless this command is given
586 apt-get install
<replaceable>package
</replaceable>/testing
592 <title>Tracking Testing or Unstable
</title>
594 <para>The following APT preferences file will cause APT to assign
595 a high priority to package versions from the
<literal>testing
</literal>
596 distribution, a lower priority to package versions from the
597 <literal>unstable
</literal> distribution, and a prohibitively low priority
598 to package versions from other
<literal>Debian
</literal> distributions.
602 Pin: release a=testing
606 Pin: release a=unstable
610 Pin: release o=Debian
615 <para>With a suitable &sources-list; file and the above preferences file,
616 any of the following commands will cause APT to upgrade to the latest
617 <literal>testing
</literal> version(s).
620 apt-get install
<replaceable>package-name
</replaceable>
626 <para>The following command will cause APT to upgrade the specified
627 package to the latest version from the
<literal>unstable
</literal> distribution.
628 Thereafter,
<command>apt-get upgrade
</command> will upgrade
629 the package to the most recent
<literal>testing
</literal> version if that is
630 more recent than the installed version, otherwise, to the most recent
631 <literal>unstable
</literal> version if that is more recent than the installed
635 apt-get install
<replaceable>package
</replaceable>/unstable
642 <title>Tracking the evolution of a codename release
</title>
644 <para>The following APT preferences file will cause APT to assign a
645 priority higher than the default (
500) to all package versions belonging
646 to a specified codename of a distribution and a prohibitively low priority to
647 package versions belonging to other
<literal>Debian
</literal> distributions,
648 codenames and archives.
649 Note that with this APT preference APT will follow the migration of a release
650 from the archive
<literal>testing
</literal> to
<literal>stable
</literal> and
651 later
<literal>oldstable
</literal>. If you want to follow for example the progress
652 in
<literal>testing
</literal> notwithstanding the codename changes you should use
653 the example configurations above.
656 Explanation: Uninstall or do not install any Debian-originated package versions
657 Explanation: other than those in the distribution codenamed with &testing-codename; or sid
659 Pin: release n=&testing-codename;
662 Explanation: Debian unstable is always codenamed with sid
668 Pin: release o=Debian
673 <para>With a suitable &sources-list; file and the above preferences file,
674 any of the following commands will cause APT to upgrade to the
675 latest version(s) in the release codenamed with
<literal>&testing-codename;
</literal>.
678 apt-get install
<replaceable>package-name
</replaceable>
684 <para>The following command will cause APT to upgrade the specified
685 package to the latest version from the
<literal>sid
</literal> distribution.
686 Thereafter,
<command>apt-get upgrade
</command> will upgrade
687 the package to the most recent
<literal>&testing-codename;
</literal> version if that is
688 more recent than the installed version, otherwise, to the most recent
689 <literal>sid
</literal> version if that is more recent than the installed
693 apt-get install
<replaceable>package
</replaceable>/sid
707 <title>See Also
</title>
708 <para>&apt-get; &apt-cache; &apt-conf; &sources-list;