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