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