]> git.saurik.com Git - apt.git/blame - doc/apt_preferences.5.xml
* apt-pkg/algorithms.cc:
[apt.git] / doc / apt_preferences.5.xml
CommitLineData
24f6490f
AL
1<?xml version="1.0" encoding="utf-8" standalone="no"?>
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
b2e465d6
AL
4
5<!ENTITY % aptent SYSTEM "apt.ent">
6%aptent;
7
8]>
9
10<refentry>
ec2853a7 11
5e80de29
AL
12 <refentryinfo>
13 &apt-author.team;
14 &apt-email;
15 &apt-product;
16 <!-- The last update date -->
17 <date>29 February 2004</date>
18 </refentryinfo>
19
b2e465d6 20 <refmeta>
24f6490f
AL
21 <refentrytitle>apt_preferences</refentrytitle>
22 <manvolnum>5</manvolnum>
b2e465d6 23 </refmeta>
ec2853a7 24
b2e465d6
AL
25 <!-- Man page title -->
26 <refnamediv>
24f6490f
AL
27 <refname>apt_preferences</refname>
28 <refpurpose>Preference control file for APT</refpurpose>
b2e465d6 29 </refnamediv>
b2e465d6 30
24f6490f
AL
31<refsect1>
32<title>Description</title>
33<para>The APT preferences file <filename>/etc/apt/preferences</filename>
5b9d504e 34can be used to control which versions of packages will be selected
24f6490f 35for installation.</para>
ec2853a7 36
24f6490f 37<para>Several versions of a package may be available for installation when
ec2853a7 38the &sources-list; file contains references to more than one distribution
5b9d504e
AL
39(for example, <literal>stable</literal> and <literal>testing</literal>).
40APT assigns a priority to each version that is available.
41Subject to dependency constraints, <command>apt-get</command> selects the
408a8e0a 42version with the highest priority for installation.
5b9d504e
AL
43The APT preferences file overrides the priorities that APT assigns to
44package versions by default, thus giving the user control over which
24f6490f
AL
45one is selected for installation.</para>
46
47<para>Several instances of the same version of a package may be available when
408a8e0a
AL
48the &sources-list; file contains references to more than one source.
49In this case <command>apt-get</command> downloads the instance listed
5b9d504e 50earliest in the &sources-list; file.
408a8e0a 51The APT preferences file does not affect the choice of instance, only
24f6490f 52the choice of version.</para>
ec2853a7 53
24f6490f 54<refsect2><title>APT's Default Priority Assignments</title>
ec2853a7 55
24f6490f 56<para>If there is no preferences file or if there is no entry in the file
408a8e0a
AL
57that applies to a particular version then the priority assigned to that
58version is the priority of the distribution to which that version
59belongs. It is possible to single out a distribution, "the target release",
60which receives a higher priority than other distributions do by default.
61The target release can be set on the <command>apt-get</command> command
62line or in the APT configuration file <filename>/etc/apt/apt.conf</filename>.
63For example,
24f6490f 64
408a8e0a
AL
65<programlisting>
66<command>apt-get install -t testing <replaceable>some-package</replaceable></command>
67</programlisting>
68<programlisting>
69APT::Default-Release "stable";
70</programlisting>
ec2853a7
AL
71</para>
72
24f6490f 73<para>If the target release has been specified then APT uses the following
408a8e0a 74algorithm to set the priorities of the versions of a package. Assign:
24f6490f 75
ec2853a7
AL
76<variablelist>
77<varlistentry>
78<term>priority 100</term>
5b9d504e 79<listitem><simpara>to the version that is already installed (if any).</simpara></listitem>
ec2853a7 80</varlistentry>
24f6490f 81
ec2853a7
AL
82<varlistentry>
83<term>priority 500</term>
5b9d504e 84<listitem><simpara>to the versions that are not installed and do not belong to the target release.</simpara></listitem>
ec2853a7 85</varlistentry>
24f6490f 86
ec2853a7
AL
87<varlistentry>
88<term>priority 990</term>
5b9d504e 89<listitem><simpara>to the versions that are not installed and belong to the target release.</simpara></listitem>
ec2853a7
AL
90</varlistentry>
91</variablelist>
92</para>
93
24f6490f 94<para>If the target release has not been specified then APT simply assigns
5b9d504e 95priority 100 to all installed package versions and priority 500 to all
24f6490f 96uninstalled package versions.</para>
ec2853a7 97
24f6490f 98<para>APT then applies the following rules, listed in order of precedence,
5b9d504e 99to determine which version of a package to install.
ec2853a7 100<itemizedlist>
5b9d504e
AL
101<listitem><simpara>Never downgrade unless the priority of an available
102version exceeds 1000. ("Downgrading" is installing a less recent version
103of a package in place of a more recent version. Note that none of APT's
104default priorities exceeds 1000; such high priorities can only be set in
105the preferences file. Note also that downgrading a package
106can be risky.)</simpara></listitem>
107<listitem><simpara>Install the highest priority version.</simpara></listitem>
108<listitem><simpara>If two or more versions have the same priority,
109install the most recent one (that is, the one with the higher version
110number).</simpara></listitem>
111<listitem><simpara>If two or more versions have the same priority and
112version number but either the packages differ in some of their metadata or the
24f6490f 113<literal>--reinstall</literal> option is given, install the uninstalled one.</simpara></listitem>
ec2853a7
AL
114</itemizedlist>
115</para>
116
24f6490f 117<para>In a typical situation, the installed version of a package (priority 100)
5b9d504e
AL
118is not as recent as one of the versions available from the sources listed in
119the &sources-list; file (priority 500 or 990). Then the package will be upgraded
120when <command>apt-get install <replaceable>some-package</replaceable></command>
121or <command>apt-get upgrade</command> is executed.
ec2853a7
AL
122</para>
123
24f6490f 124<para>More rarely, the installed version of a package is <emphasis>more</emphasis> recent
5b9d504e
AL
125than any of the other available versions. The package will not be downgraded
126when <command>apt-get install <replaceable>some-package</replaceable></command>
24f6490f 127or <command>apt-get upgrade</command> is executed.</para>
ec2853a7 128
24f6490f 129<para>Sometimes the installed version of a package is more recent than the
ec2853a7 130version belonging to the target release, but not as recent as a version
5b9d504e
AL
131belonging to some other distribution. Such a package will indeed be upgraded
132when <command>apt-get install <replaceable>some-package</replaceable></command>
133or <command>apt-get upgrade</command> is executed,
24f6490f
AL
134because at least <emphasis>one</emphasis> of the available versions has a higher
135priority than the installed version.</para>
136</refsect2>
ec2853a7 137
24f6490f 138<refsect2><title>The Effect of APT Preferences</title>
ec2853a7 139
24f6490f 140<para>The APT preferences file allows the system administrator to control the
5b9d504e
AL
141assignment of priorities. The file consists of one or more multi-line records
142separated by blank lines. Records can have one of two forms, a specific form
143and a general form.
ec2853a7
AL
144<itemizedlist>
145<listitem>
24f6490f 146<simpara>The specific form assigns a priority (a "Pin-Priority") to a
5b9d504e
AL
147specified package and specified version or version range. For example,
148the following record assigns a high priority to all versions of
24f6490f 149the <filename>perl</filename> package whose version number begins with "<literal>5.8</literal>".</simpara>
ec2853a7
AL
150
151<programlisting>
152Package: perl
153Pin: version 5.8*
154Pin-Priority: 1001
155</programlisting>
156</listitem>
157
24f6490f 158<listitem><simpara>The general form assigns a priority to all of the package versions in a
ec2853a7 159given distribution (that is, to all the versions of packages that are
24f6490f 160listed in a certain <filename>Release</filename> file) or to all of the package
5b9d504e 161versions coming from a particular Internet site, as identified by the
24f6490f 162site's fully qualified domain name.</simpara>
ec2853a7 163
24f6490f 164<simpara>This general-form entry in the APT preferences file applies only
5b9d504e 165to groups of packages. For example, the following record assigns a high
24f6490f 166priority to all package versions available from the local site.</simpara>
ec2853a7
AL
167
168<programlisting>
169Package: *
170Pin: origin ""
171Pin-Priority: 999
172</programlisting>
173
24f6490f 174<simpara>A note of caution: the keyword used here is "<literal>origin</literal>".
5b9d504e 175This should not be confused with the Origin of a distribution as
24f6490f
AL
176specified in a <filename>Release</filename> file. What follows the "Origin:" tag
177in a <filename>Release</filename> file is not an Internet address
178but an author or vendor name, such as "Debian" or "Ximian".</simpara>
ec2853a7 179
24f6490f
AL
180<simpara>The following record assigns a low priority to all package versions
181belonging to any distribution whose Archive name is "<literal>unstable</literal>".</simpara>
ec2853a7
AL
182
183<programlisting>
184Package: *
185Pin: release a=unstable
583958a8 186Pin-Priority: 50
ec2853a7
AL
187</programlisting>
188
24f6490f
AL
189<simpara>The following record assigns a high priority to all package versions
190belonging to any release whose Archive name is "<literal>stable</literal>"
191and whose release Version number is "<literal>3.0</literal>".</simpara>
ec2853a7
AL
192
193<programlisting>
194Package: *
0493db1e
MZ
195Pin: release a=stable, v=3.0
196Pin-Priority: 500
ec2853a7
AL
197</programlisting>
198</listitem>
199</itemizedlist>
200</para>
201
24f6490f 202</refsect2>
ec2853a7 203
24f6490f
AL
204<refsect2>
205<title>How APT Interprets Priorities</title>
ec2853a7 206
5b9d504e
AL
207<para>
208Priorities (P) assigned in the APT preferences file must be positive
ec2853a7
AL
209or negative integers. They are interpreted as follows (roughly speaking):
210
211<variablelist>
5b9d504e
AL
212<varlistentry>
213<term>P &gt; 1000</term>
214<listitem><simpara>causes a version to be installed even if this
215constitutes a downgrade of the package</simpara></listitem>
ec2853a7 216</varlistentry>
5b9d504e
AL
217<varlistentry>
218<term>990 &lt; P &lt;=1000</term>
219<listitem><simpara>causes a version to be installed
ec2853a7 220even if it does not come from the target release,
5b9d504e 221unless the installed version is more recent</simpara></listitem>
ec2853a7 222</varlistentry>
5b9d504e
AL
223<varlistentry>
224<term>500 &lt; P &lt;=990</term>
225<listitem><simpara>causes a version to be installed
226unless there is a version available belonging to the target release
227or the installed version is more recent</simpara></listitem>
ec2853a7 228</varlistentry>
5b9d504e
AL
229<varlistentry>
230<term>100 &lt; P &lt;=500</term>
231<listitem><simpara>causes a version to be installed
232unless there is a version available belonging to some other
233distribution or the installed version is more recent</simpara></listitem>
24f6490f 234</varlistentry>
5b9d504e 235<varlistentry>
56298634 236<term>0 &lt; P &lt;=100</term>
5b9d504e
AL
237<listitem><simpara>causes a version to be installed
238only if there is no installed version of the package</simpara></listitem>
ec2853a7 239</varlistentry>
5b9d504e
AL
240<varlistentry>
241<term>P &lt; 0</term>
242<listitem><simpara>prevents the version from being installed</simpara></listitem>
ec2853a7
AL
243</varlistentry>
244</variablelist>
245</para>
246
24f6490f 247<para>If any specific-form records match an available package version then the
5b9d504e
AL
248first such record determines the priority of the package version.
249Failing that,
250if any general-form records match an available package version then the
24f6490f 251first such record determines the priority of the package version.</para>
ec2853a7 252
24f6490f
AL
253<para>For example, suppose the APT preferences file contains the three
254records presented earlier:</para>
ec2853a7
AL
255
256<programlisting>
257Package: perl
258Pin: version 5.8*
b2e465d6 259Pin-Priority: 1001
ec2853a7 260
b2e465d6 261Package: *
ec2853a7
AL
262Pin: origin ""
263Pin-Priority: 999
264
265Package: *
266Pin: release unstable
267Pin-Priority: 50
268</programlisting>
269
24f6490f 270<para>Then:
ec2853a7 271<itemizedlist>
24f6490f 272<listitem><simpara>The most recent available version of the <literal>perl</literal>
ec2853a7 273package will be installed, so long as that version's version number begins
24f6490f
AL
274with "<literal>5.8</literal>". If <emphasis>any</emphasis> 5.8* version of <literal>perl</literal> is
275available and the installed version is 5.9*, then <literal>perl</literal> will be
ec2853a7 276downgraded.</simpara></listitem>
24f6490f 277<listitem><simpara>A version of any package other than <literal>perl</literal>
5b9d504e
AL
278that is available from the local system has priority over other versions,
279even versions belonging to the target release.
ec2853a7 280</simpara></listitem>
5b9d504e
AL
281<listitem><simpara>A version of a package whose origin is not the local
282system but some other site listed in &sources-list; and which belongs to
24f6490f 283an <literal>unstable</literal> distribution is only installed if it is selected
5b9d504e 284for installation and no version of the package is already installed.
ec2853a7
AL
285</simpara></listitem>
286</itemizedlist>
287</para>
24f6490f 288</refsect2>
ec2853a7 289
24f6490f
AL
290<refsect2>
291<title>Determination of Package Version and Distribution Properties</title>
ec2853a7 292
24f6490f 293<para>The locations listed in the &sources-list; file should provide
ec2853a7 294<filename>Packages</filename> and <filename>Release</filename> files
24f6490f 295to describe the packages available at that location. </para>
ec2853a7 296
24f6490f 297<para>The <filename>Packages</filename> file is normally found in the directory
ec2853a7
AL
298<filename>.../dists/<replaceable>dist-name</replaceable>/<replaceable>component</replaceable>/<replaceable>arch</replaceable></filename>:
299for example, <filename>.../dists/stable/main/binary-i386/Packages</filename>.
300It consists of a series of multi-line records, one for each package available
301in that directory. Only two lines in each record are relevant for setting
302APT priorities:
303<variablelist>
304<varlistentry>
24f6490f 305<term>the <literal>Package:</literal> line</term>
ec2853a7
AL
306<listitem><simpara>gives the package name</simpara></listitem>
307</varlistentry>
308<varlistentry>
24f6490f 309<term>the <literal>Version:</literal> line</term>
ec2853a7
AL
310<listitem><simpara>gives the version number for the named package</simpara></listitem>
311</varlistentry>
312</variablelist>
313</para>
314
24f6490f 315<para>The <filename>Release</filename> file is normally found in the directory
ec2853a7
AL
316<filename>.../dists/<replaceable>dist-name</replaceable></filename>:
317for example, <filename>.../dists/stable/Release</filename>,
318or <filename>.../dists/woody/Release</filename>.
24f6490f 319It consists of a single multi-line record which applies to <emphasis>all</emphasis> of
5b9d504e 320the packages in the directory tree below its parent. Unlike the
24f6490f 321<filename>Packages</filename> file, nearly all of the lines in a <filename>Release</filename>
ec2853a7
AL
322file are relevant for setting APT priorities:
323
324<variablelist>
325<varlistentry>
24f6490f 326<term>the <literal>Archive:</literal> line</term>
5b9d504e 327<listitem><simpara>names the archive to which all the packages
ec2853a7 328in the directory tree belong. For example, the line
5b9d504e
AL
329"Archive: stable"
330specifies that all of the packages in the directory
24f6490f
AL
331tree below the parent of the <filename>Release</filename> file are in a
332<literal>stable</literal> archive. Specifying this value in the APT preferences file
ec2853a7
AL
333would require the line:
334</simpara>
ec2853a7
AL
335<programlisting>
336Pin: release a=stable
337</programlisting>
338</listitem>
339</varlistentry>
340
341<varlistentry>
24f6490f 342<term>the <literal>Version:</literal> line</term>
ec2853a7 343<listitem><simpara>names the release version. For example, the
5b9d504e
AL
344packages in the tree might belong to Debian GNU/Linux release
345version 3.0. Note that there is normally no version number for the
24f6490f 346<literal>testing</literal> and <literal>unstable</literal> distributions because they
5b9d504e
AL
347have not been released yet. Specifying this in the APT preferences
348file would require one of the following lines.
ec2853a7
AL
349</simpara>
350
351<programlisting>
352Pin: release v=3.0
f6271220 353Pin: release a=stable, v=3.0
ec2853a7
AL
354Pin: release 3.0
355</programlisting>
356
357</listitem>
358</varlistentry>
359
360<varlistentry>
24f6490f 361<term>the <literal>Component:</literal> line</term>
ec2853a7 362<listitem><simpara>names the licensing component associated with the
24f6490f 363packages in the directory tree of the <filename>Release</filename> file.
5b9d504e 364For example, the line "Component: main" specifies that
24f6490f 365all the packages in the directory tree are from the <literal>main</literal>
5b9d504e
AL
366component, which entails that they are licensed under terms listed
367in the Debian Free Software Guidelines. Specifying this component
368in the APT preferences file would require the line:
ec2853a7 369</simpara>
ec2853a7
AL
370<programlisting>
371Pin: release c=main
372</programlisting>
373</listitem>
374</varlistentry>
375
376<varlistentry>
24f6490f 377<term>the <literal>Origin:</literal> line</term>
5b9d504e 378<listitem><simpara>names the originator of the packages in the
24f6490f
AL
379directory tree of the <filename>Release</filename> file. Most commonly, this is
380<literal>Debian</literal>. Specifying this origin in the APT preferences file
ec2853a7
AL
381would require the line:
382</simpara>
ec2853a7
AL
383<programlisting>
384Pin: release o=Debian
385</programlisting>
386</listitem>
387</varlistentry>
388
389<varlistentry>
24f6490f 390<term>the <literal>Label:</literal> line</term>
5b9d504e 391<listitem><simpara>names the label of the packages in the directory tree
24f6490f
AL
392of the <filename>Release</filename> file. Most commonly, this is
393<literal>Debian</literal>. Specifying this label in the APT preferences file
ec2853a7
AL
394would require the line:
395</simpara>
ec2853a7
AL
396<programlisting>
397Pin: release l=Debian
398</programlisting>
399</listitem>
400</varlistentry>
401</variablelist>
402</para>
403
24f6490f 404<para>All of the <filename>Packages</filename> and <filename>Release</filename>
5b9d504e 405files retrieved from locations listed in the &sources-list; file are stored
ec2853a7 406in the directory <filename>/var/lib/apt/lists</filename>, or in the file named
24f6490f 407by the variable <literal>Dir::State::Lists</literal> in the <filename>apt.conf</filename> file.
ec2853a7
AL
408For example, the file
409<filename>debian.lcs.mit.edu_debian_dists_unstable_contrib_binary-i386_Release</filename>
410contains the <filename>Release</filename> file retrieved from the site
24f6490f
AL
411<literal>debian.lcs.mit.edu</literal> for <literal>binary-i386</literal> architecture
412files from the <literal>contrib</literal> component of the <literal>unstable</literal>
413distribution.</para>
414</refsect2>
ec2853a7 415
24f6490f
AL
416<refsect2>
417<title>Optional Lines in an APT Preferences Record</title>
ec2853a7 418
24f6490f
AL
419<para>Each record in the APT preferences file can optionally begin with
420one or more lines beginning with the word <literal>Explanation:</literal>.
421This provides a place for comments.</para>
ec2853a7 422
24f6490f 423<para>The <literal>Pin-Priority:</literal> line in each APT preferences record is
ec2853a7 424optional. If omitted, APT assigs a priority of 1 less than the last value
24f6490f
AL
425specified on a line beginning with <literal>Pin-Priority: release ...</literal>.</para>
426</refsect2>
427</refsect1>
ec2853a7 428
24f6490f
AL
429<refsect1>
430<title>Examples</title>
431<refsect2>
432<title>Tracking Stable</title>
ec2853a7 433
24f6490f 434<para>The following APT preferences file will cause APT to assign a
ec2853a7 435priority higher than the default (500) to all package versions belonging
24f6490f
AL
436to a <literal>stable</literal> distribution and a prohibitively low priority to
437package versions belonging to other <literal>Debian</literal> distributions.
ec2853a7
AL
438
439<programlisting>
5b9d504e
AL
440Explanation: Uninstall or do not install any Debian-originated
441Explanation: package versions other than those in the stable distro
ec2853a7
AL
442Package: *
443Pin: release a=stable
444Pin-Priority: 900
445
ec2853a7
AL
446Package: *
447Pin: release o=Debian
448Pin-Priority: -10
449</programlisting>
450</para>
451
24f6490f 452<para>With a suitable &sources-list; file and the above preferences file,
ec2853a7 453any of the following commands will cause APT to upgrade to the
24f6490f 454latest <literal>stable</literal> version(s).
ec2853a7
AL
455
456<programlisting>
457apt-get install <replaceable>package-name</replaceable>
458apt-get upgrade
459apt-get dist-upgrade
460</programlisting>
461</para>
462
24f6490f
AL
463<para>The following command will cause APT to upgrade the specified
464package to the latest version from the <literal>testing</literal> distribution;
5b9d504e
AL
465the package will not be upgraded again unless this command is given
466again.
ec2853a7
AL
467
468<programlisting>
469apt-get install <replaceable>package</replaceable>/testing
470</programlisting>
24f6490f
AL
471</para>
472</refsect2>
ec2853a7 473
24f6490f
AL
474 <refsect2>
475 <title>Tracking Testing or Unstable</title>
ec2853a7 476
24f6490f
AL
477<para>The following APT preferences file will cause APT to assign
478a high priority to package versions from the <literal>testing</literal>
5b9d504e 479distribution, a lower priority to package versions from the
24f6490f
AL
480<literal>unstable</literal> distribution, and a prohibitively low priority
481to package versions from other <literal>Debian</literal> distributions.
ec2853a7
AL
482
483<programlisting>
484Package: *
485Pin: release a=testing
486Pin-Priority: 900
487
488Package: *
489Pin: release a=unstable
490Pin-Priority: 800
491
492Package: *
493Pin: release o=Debian
494Pin-Priority: -10
495</programlisting>
496</para>
497
24f6490f 498<para>With a suitable &sources-list; file and the above preferences file,
5b9d504e 499any of the following commands will cause APT to upgrade to the latest
24f6490f 500<literal>testing</literal> version(s).
ec2853a7
AL
501
502<programlisting>
503apt-get install <replaceable>package-name</replaceable>
504apt-get upgrade
505apt-get dist-upgrade
506</programlisting>
507</para>
508
509<para>The following command will cause APT to upgrade the specified
24f6490f 510package to the latest version from the <literal>unstable</literal> distribution.
5b9d504e 511Thereafter, <command>apt-get upgrade</command> will upgrade
24f6490f 512the package to the most recent <literal>testing</literal> version if that is
5b9d504e 513more recent than the installed version, otherwise, to the most recent
24f6490f 514<literal>unstable</literal> version if that is more recent than the installed
5b9d504e 515version.
ec2853a7
AL
516
517<programlisting>
518apt-get install <replaceable>package</replaceable>/unstable
519</programlisting>
520</para>
521
24f6490f
AL
522</refsect2>
523</refsect1>
ec2853a7 524
24f6490f
AL
525<refsect1>
526<title>See Also</title>
5e80de29 527<para>&apt-get; &apt-cache; &apt-conf; &sources-list;
5b9d504e 528</para>
24f6490f 529</refsect1>
b2e465d6
AL
530
531 &manbugs;
ec2853a7 532
b2e465d6 533</refentry>
24f6490f 534