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