]> git.saurik.com Git - apt.git/blob - doc/apt_preferences.5.xml
* apt-pkg/depcache.cc, apt-pkg/indexcopy.cc:
[apt.git] / doc / apt_preferences.5.xml
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>04 May 2009</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>
34 can be used to control which versions of packages will be selected
35 for installation.</para>
36
37 <para>Several versions of a package may be available for installation when
38 the &sources-list; file contains references to more than one distribution
39 (for example, <literal>stable</literal> and <literal>testing</literal>).
40 APT assigns a priority to each version that is available.
41 Subject to dependency constraints, <command>apt-get</command> selects the
42 version with the highest priority for installation.
43 The APT preferences file overrides the priorities that APT assigns to
44 package versions by default, thus giving the user control over which
45 one is selected for installation.</para>
46
47 <para>Several instances of the same version of a package may be available when
48 the &sources-list; file contains references to more than one source.
49 In this case <command>apt-get</command> downloads the instance listed
50 earliest in the &sources-list; file.
51 The APT preferences file does not affect the choice of instance, only
52 the 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
57 that applies to a particular version then the priority assigned to that
58 version is the priority of the distribution to which that version
59 belongs. It is possible to single out a distribution, "the target release",
60 which receives a higher priority than other distributions do by default.
61 The target release can be set on the <command>apt-get</command> command
62 line or in the APT configuration file <filename>/etc/apt/apt.conf</filename>.
63 Note that this has precedence over any general priority you set in the
64 <filename>/etc/apt/preferences</filename> file described later, but not
65 over specifically pinned packages.
66 For example,
67
68 <programlisting>
69 <command>apt-get install -t testing <replaceable>some-package</replaceable></command>
70 </programlisting>
71 <programlisting>
72 APT::Default-Release "stable";
73 </programlisting>
74 </para>
75
76 <para>If the target release has been specified then APT uses the following
77 algorithm 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
98 priority 100 to all installed package versions and priority 500 to all
99 uninstalled package versions.</para>
100
101 <para>APT then applies the following rules, listed in order of precedence,
102 to determine which version of a package to install.
103 <itemizedlist>
104 <listitem><simpara>Never downgrade unless the priority of an available
105 version exceeds 1000. ("Downgrading" is installing a less recent version
106 of a package in place of a more recent version. Note that none of APT's
107 default priorities exceeds 1000; such high priorities can only be set in
108 the preferences file. Note also that downgrading a package
109 can 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,
112 install the most recent one (that is, the one with the higher version
113 number).</simpara></listitem>
114 <listitem><simpara>If two or more versions have the same priority and
115 version 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)
121 is not as recent as one of the versions available from the sources listed in
122 the &sources-list; file (priority 500 or 990). Then the package will be upgraded
123 when <command>apt-get install <replaceable>some-package</replaceable></command>
124 or <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
128 than any of the other available versions. The package will not be downgraded
129 when <command>apt-get install <replaceable>some-package</replaceable></command>
130 or <command>apt-get upgrade</command> is executed.</para>
131
132 <para>Sometimes the installed version of a package is more recent than the
133 version belonging to the target release, but not as recent as a version
134 belonging to some other distribution. Such a package will indeed be upgraded
135 when <command>apt-get install <replaceable>some-package</replaceable></command>
136 or <command>apt-get upgrade</command> is executed,
137 because at least <emphasis>one</emphasis> of the available versions has a higher
138 priority 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
144 assignment of priorities. The file consists of one or more multi-line records
145 separated by blank lines. Records can have one of two forms, a specific form
146 and a general form.
147 <itemizedlist>
148 <listitem>
149 <simpara>The specific form assigns a priority (a "Pin-Priority") to one or more
150 specified packages and specified version or version range. For example,
151 the following record assigns a high priority to all versions of
152 the <filename>perl</filename> package whose version number begins with "<literal>5.8</literal>".
153 Multiple packages can be separated by spaces.</simpara>
154
155 <programlisting>
156 Package: perl
157 Pin: version 5.8*
158 Pin-Priority: 1001
159 </programlisting>
160 </listitem>
161
162 <listitem><simpara>The general form assigns a priority to all of the package versions in a
163 given distribution (that is, to all the versions of packages that are
164 listed in a certain <filename>Release</filename> file) or to all of the package
165 versions coming from a particular Internet site, as identified by the
166 site's fully qualified domain name.</simpara>
167
168 <simpara>This general-form entry in the APT preferences file applies only
169 to groups of packages. For example, the following record assigns a high
170 priority to all package versions available from the local site.</simpara>
171
172 <programlisting>
173 Package: *
174 Pin: origin ""
175 Pin-Priority: 999
176 </programlisting>
177
178 <simpara>A note of caution: the keyword used here is "<literal>origin</literal>".
179 This should not be confused with the Origin of a distribution as
180 specified in a <filename>Release</filename> file. What follows the "Origin:" tag
181 in a <filename>Release</filename> file is not an Internet address
182 but 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
185 belonging to any distribution whose Archive name is "<literal>unstable</literal>".</simpara>
186
187 <programlisting>
188 Package: *
189 Pin: release a=unstable
190 Pin-Priority: 50
191 </programlisting>
192
193 <simpara>The following record assigns a high priority to all package versions
194 belonging to any distribution whose Codename is "<literal>squeeze</literal>".</simpara>
195
196 <programlisting>
197 Package: *
198 Pin: release n=squeeze
199 Pin-Priority: 900
200 </programlisting>
201
202 <simpara>The following record assigns a high priority to all package versions
203 belonging to any release whose Archive name is "<literal>stable</literal>"
204 and whose release Version number is "<literal>3.0</literal>".</simpara>
205
206 <programlisting>
207 Package: *
208 Pin: release a=stable, v=3.0
209 Pin-Priority: 500
210 </programlisting>
211 </listitem>
212 </itemizedlist>
213 </para>
214
215 </refsect2>
216
217 <refsect2>
218 <title>How APT Interprets Priorities</title>
219
220 <para>
221 Priorities (P) assigned in the APT preferences file must be positive
222 or negative integers. They are interpreted as follows (roughly speaking):
223
224 <variablelist>
225 <varlistentry>
226 <term>P &gt; 1000</term>
227 <listitem><simpara>causes a version to be installed even if this
228 constitutes a downgrade of the package</simpara></listitem>
229 </varlistentry>
230 <varlistentry>
231 <term>990 &lt; P &lt;=1000</term>
232 <listitem><simpara>causes a version to be installed
233 even if it does not come from the target release,
234 unless the installed version is more recent</simpara></listitem>
235 </varlistentry>
236 <varlistentry>
237 <term>500 &lt; P &lt;=990</term>
238 <listitem><simpara>causes a version to be installed
239 unless there is a version available belonging to the target release
240 or the installed version is more recent</simpara></listitem>
241 </varlistentry>
242 <varlistentry>
243 <term>100 &lt; P &lt;=500</term>
244 <listitem><simpara>causes a version to be installed
245 unless there is a version available belonging to some other
246 distribution or the installed version is more recent</simpara></listitem>
247 </varlistentry>
248 <varlistentry>
249 <term>0 &lt; P &lt;=100</term>
250 <listitem><simpara>causes a version to be installed
251 only if there is no installed version of the package</simpara></listitem>
252 </varlistentry>
253 <varlistentry>
254 <term>P &lt; 0</term>
255 <listitem><simpara>prevents the version from being installed</simpara></listitem>
256 </varlistentry>
257 </variablelist>
258 </para>
259
260 <para>If any specific-form records match an available package version then the
261 first such record determines the priority of the package version.
262 Failing that,
263 if any general-form records match an available package version then the
264 first such record determines the priority of the package version.</para>
265
266 <para>For example, suppose the APT preferences file contains the three
267 records presented earlier:</para>
268
269 <programlisting>
270 Package: perl
271 Pin: version 5.8*
272 Pin-Priority: 1001
273
274 Package: *
275 Pin: origin ""
276 Pin-Priority: 999
277
278 Package: *
279 Pin: release unstable
280 Pin-Priority: 50
281 </programlisting>
282
283 <para>Then:
284 <itemizedlist>
285 <listitem><simpara>The most recent available version of the <literal>perl</literal>
286 package will be installed, so long as that version's version number begins
287 with "<literal>5.8</literal>". If <emphasis>any</emphasis> 5.8* version of <literal>perl</literal> is
288 available and the installed version is 5.9*, then <literal>perl</literal> will be
289 downgraded.</simpara></listitem>
290 <listitem><simpara>A version of any package other than <literal>perl</literal>
291 that is available from the local system has priority over other versions,
292 even versions belonging to the target release.
293 </simpara></listitem>
294 <listitem><simpara>A version of a package whose origin is not the local
295 system but some other site listed in &sources-list; and which belongs to
296 an <literal>unstable</literal> distribution is only installed if it is selected
297 for installation and no version of the package is already installed.
298 </simpara></listitem>
299 </itemizedlist>
300 </para>
301 </refsect2>
302
303 <refsect2>
304 <title>Determination of Package Version and Distribution Properties</title>
305
306 <para>The locations listed in the &sources-list; file should provide
307 <filename>Packages</filename> and <filename>Release</filename> files
308 to describe the packages available at that location. </para>
309
310 <para>The <filename>Packages</filename> file is normally found in the directory
311 <filename>.../dists/<replaceable>dist-name</replaceable>/<replaceable>component</replaceable>/<replaceable>arch</replaceable></filename>:
312 for example, <filename>.../dists/stable/main/binary-i386/Packages</filename>.
313 It consists of a series of multi-line records, one for each package available
314 in that directory. Only two lines in each record are relevant for setting
315 APT priorities:
316 <variablelist>
317 <varlistentry>
318 <term>the <literal>Package:</literal> line</term>
319 <listitem><simpara>gives the package name</simpara></listitem>
320 </varlistentry>
321 <varlistentry>
322 <term>the <literal>Version:</literal> line</term>
323 <listitem><simpara>gives the version number for the named package</simpara></listitem>
324 </varlistentry>
325 </variablelist>
326 </para>
327
328 <para>The <filename>Release</filename> file is normally found in the directory
329 <filename>.../dists/<replaceable>dist-name</replaceable></filename>:
330 for example, <filename>.../dists/stable/Release</filename>,
331 or <filename>.../dists/woody/Release</filename>.
332 It consists of a single multi-line record which applies to <emphasis>all</emphasis> of
333 the packages in the directory tree below its parent. Unlike the
334 <filename>Packages</filename> file, nearly all of the lines in a <filename>Release</filename>
335 file are relevant for setting APT priorities:
336
337 <variablelist>
338 <varlistentry>
339 <term>the <literal>Archive:</literal> or <literal>Suite:</literal> line</term>
340 <listitem><simpara>names the archive to which all the packages
341 in the directory tree belong. For example, the line
342 "Archive: stable" or
343 "Suite: stable"
344 specifies that all of the packages in the directory
345 tree below the parent of the <filename>Release</filename> file are in a
346 <literal>stable</literal> archive. Specifying this value in the APT preferences file
347 would require the line:
348 </simpara>
349 <programlisting>
350 Pin: release a=stable
351 </programlisting>
352 </listitem>
353 </varlistentry>
354
355 <varlistentry>
356 <term>the <literal>Codename:</literal> line</term>
357 <listitem><simpara>names the codename to which all the packages
358 in the directory tree belong. For example, the line
359 "Codename: squeeze"
360 specifies that all of the packages in the directory
361 tree below the parent of the <filename>Release</filename> file belong to a version named
362 <literal>squeeze</literal>. Specifying this value in the APT preferences file
363 would require the line:
364 </simpara>
365 <programlisting>
366 Pin: release n=squeeze
367 </programlisting>
368 </listitem>
369 </varlistentry>
370
371 <varlistentry>
372 <term>the <literal>Version:</literal> line</term>
373 <listitem><simpara>names the release version. For example, the
374 packages in the tree might belong to Debian GNU/Linux release
375 version 3.0. Note that there is normally no version number for the
376 <literal>testing</literal> and <literal>unstable</literal> distributions because they
377 have not been released yet. Specifying this in the APT preferences
378 file would require one of the following lines.
379 </simpara>
380
381 <programlisting>
382 Pin: release v=3.0
383 Pin: release a=stable, v=3.0
384 Pin: release 3.0
385 </programlisting>
386
387 </listitem>
388 </varlistentry>
389
390 <varlistentry>
391 <term>the <literal>Component:</literal> line</term>
392 <listitem><simpara>names the licensing component associated with the
393 packages in the directory tree of the <filename>Release</filename> file.
394 For example, the line "Component: main" specifies that
395 all the packages in the directory tree are from the <literal>main</literal>
396 component, which entails that they are licensed under terms listed
397 in the Debian Free Software Guidelines. Specifying this component
398 in the APT preferences file would require the line:
399 </simpara>
400 <programlisting>
401 Pin: release c=main
402 </programlisting>
403 </listitem>
404 </varlistentry>
405
406 <varlistentry>
407 <term>the <literal>Origin:</literal> line</term>
408 <listitem><simpara>names the originator of the packages in the
409 directory tree of the <filename>Release</filename> file. Most commonly, this is
410 <literal>Debian</literal>. Specifying this origin in the APT preferences file
411 would require the line:
412 </simpara>
413 <programlisting>
414 Pin: release o=Debian
415 </programlisting>
416 </listitem>
417 </varlistentry>
418
419 <varlistentry>
420 <term>the <literal>Label:</literal> line</term>
421 <listitem><simpara>names the label of the packages in the directory tree
422 of the <filename>Release</filename> file. Most commonly, this is
423 <literal>Debian</literal>. Specifying this label in the APT preferences file
424 would require the line:
425 </simpara>
426 <programlisting>
427 Pin: release l=Debian
428 </programlisting>
429 </listitem>
430 </varlistentry>
431 </variablelist>
432 </para>
433
434 <para>All of the <filename>Packages</filename> and <filename>Release</filename>
435 files retrieved from locations listed in the &sources-list; file are stored
436 in the directory <filename>/var/lib/apt/lists</filename>, or in the file named
437 by the variable <literal>Dir::State::Lists</literal> in the <filename>apt.conf</filename> file.
438 For example, the file
439 <filename>debian.lcs.mit.edu_debian_dists_unstable_contrib_binary-i386_Release</filename>
440 contains the <filename>Release</filename> file retrieved from the site
441 <literal>debian.lcs.mit.edu</literal> for <literal>binary-i386</literal> architecture
442 files from the <literal>contrib</literal> component of the <literal>unstable</literal>
443 distribution.</para>
444 </refsect2>
445
446 <refsect2>
447 <title>Optional Lines in an APT Preferences Record</title>
448
449 <para>Each record in the APT preferences file can optionally begin with
450 one or more lines beginning with the word <literal>Explanation:</literal>.
451 This provides a place for comments.</para>
452
453 <para>The <literal>Pin-Priority:</literal> line in each APT preferences record is
454 optional. If omitted, APT assigns a priority of 1 less than the last value
455 specified on a line beginning with <literal>Pin-Priority: release ...</literal>.</para>
456 </refsect2>
457 </refsect1>
458
459 <refsect1>
460 <title>Examples</title>
461 <refsect2>
462 <title>Tracking Stable</title>
463
464 <para>The following APT preferences file will cause APT to assign a
465 priority higher than the default (500) to all package versions belonging
466 to a <literal>stable</literal> distribution and a prohibitively low priority to
467 package versions belonging to other <literal>Debian</literal> distributions.
468
469 <programlisting>
470 Explanation: Uninstall or do not install any Debian-originated
471 Explanation: package versions other than those in the stable distro
472 Package: *
473 Pin: release a=stable
474 Pin-Priority: 900
475
476 Package: *
477 Pin: release o=Debian
478 Pin-Priority: -10
479 </programlisting>
480 </para>
481
482 <para>With a suitable &sources-list; file and the above preferences file,
483 any of the following commands will cause APT to upgrade to the
484 latest <literal>stable</literal> version(s).
485
486 <programlisting>
487 apt-get install <replaceable>package-name</replaceable>
488 apt-get upgrade
489 apt-get dist-upgrade
490 </programlisting>
491 </para>
492
493 <para>The following command will cause APT to upgrade the specified
494 package to the latest version from the <literal>testing</literal> distribution;
495 the package will not be upgraded again unless this command is given
496 again.
497
498 <programlisting>
499 apt-get install <replaceable>package</replaceable>/testing
500 </programlisting>
501 </para>
502 </refsect2>
503
504 <refsect2>
505 <title>Tracking Testing or Unstable</title>
506
507 <para>The following APT preferences file will cause APT to assign
508 a high priority to package versions from the <literal>testing</literal>
509 distribution, a lower priority to package versions from the
510 <literal>unstable</literal> distribution, and a prohibitively low priority
511 to package versions from other <literal>Debian</literal> distributions.
512
513 <programlisting>
514 Package: *
515 Pin: release a=testing
516 Pin-Priority: 900
517
518 Package: *
519 Pin: release a=unstable
520 Pin-Priority: 800
521
522 Package: *
523 Pin: release o=Debian
524 Pin-Priority: -10
525 </programlisting>
526 </para>
527
528 <para>With a suitable &sources-list; file and the above preferences file,
529 any of the following commands will cause APT to upgrade to the latest
530 <literal>testing</literal> version(s).
531
532 <programlisting>
533 apt-get install <replaceable>package-name</replaceable>
534 apt-get upgrade
535 apt-get dist-upgrade
536 </programlisting>
537 </para>
538
539 <para>The following command will cause APT to upgrade the specified
540 package to the latest version from the <literal>unstable</literal> distribution.
541 Thereafter, <command>apt-get upgrade</command> will upgrade
542 the package to the most recent <literal>testing</literal> version if that is
543 more recent than the installed version, otherwise, to the most recent
544 <literal>unstable</literal> version if that is more recent than the installed
545 version.
546
547 <programlisting>
548 apt-get install <replaceable>package</replaceable>/unstable
549 </programlisting>
550 </para>
551 </refsect2>
552
553
554 <refsect2>
555 <title>Tracking the evolution of a codename release</title>
556
557 <para>The following APT preferences file will cause APT to assign a
558 priority higher than the default (500) to all package versions belonging
559 to a specified codename of a distribution and a prohibitively low priority to
560 package versions belonging to other <literal>Debian</literal> distributions,
561 codenames and archives.
562 Note that with this APT preference APT will follow the migration of a release
563 from the archive <literal>testing</literal> to <literal>stable</literal> and
564 later <literal>oldstable</literal>. If you want to follow for example the progress
565 in <literal>testing</literal> notwithstanding the codename changes you should use
566 the example configurations above.
567
568 <programlisting>
569 Explanation: Uninstall or do not install any Debian-originated package versions
570 Explanation: other than those in the distribution codenamed with squeeze or sid
571 Package: *
572 Pin: release n=squeeze
573 Pin-Priority: 900
574
575 Explanation: Debian unstable is always codenamed with sid
576 Package: *
577 Pin: release a=sid
578 Pin-Priority: 800
579
580 Package: *
581 Pin: release o=Debian
582 Pin-Priority: -10
583 </programlisting>
584 </para>
585
586 <para>With a suitable &sources-list; file and the above preferences file,
587 any of the following commands will cause APT to upgrade to the
588 latest version(s) in the release codenamed with <literal>squeeze</literal>.
589
590 <programlisting>
591 apt-get install <replaceable>package-name</replaceable>
592 apt-get upgrade
593 apt-get dist-upgrade
594 </programlisting>
595 </para>
596
597 <para>The following command will cause APT to upgrade the specified
598 package to the latest version from the <literal>sid</literal> distribution.
599 Thereafter, <command>apt-get upgrade</command> will upgrade
600 the package to the most recent <literal>squeeze</literal> version if that is
601 more recent than the installed version, otherwise, to the most recent
602 <literal>sid</literal> version if that is more recent than the installed
603 version.
604
605 <programlisting>
606 apt-get install <replaceable>package</replaceable>/sid
607 </programlisting>
608 </para>
609 </refsect2>
610 </refsect1>
611
612 <refsect1>
613 <title>See Also</title>
614 <para>&apt-get; &apt-cache; &apt-conf; &sources-list;
615 </para>
616 </refsect1>
617
618 &manbugs;
619
620 </refentry>