]>
Commit | Line | Data |
---|---|---|
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> | |
26 | can be used to control which versions of packages will be selected | |
27 | for installation.</para> | |
28 | ||
29 | <para>Several versions of a package may be available for installation when | |
30 | the &sources-list; file contains references to more than one distribution | |
31 | (for example, <literal>stable</literal> and <literal>testing</literal>). | |
32 | APT assigns a priority to each version that is available. | |
33 | Subject to dependency constraints, <command>apt-get</command> selects the | |
34 | version with the highest priority for installation. | |
35 | The APT preferences file overrides the priorities that APT assigns to | |
36 | package versions by default, thus giving the user control over which | |
37 | one is selected for installation.</para> | |
38 | ||
39 | <para>Several instances of the same version of a package may be available when | |
40 | the &sources-list; file contains references to more than one source. | |
41 | In this case <command>apt-get</command> downloads the instance listed | |
42 | earliest in the &sources-list; file. | |
43 | The APT preferences file does not affect the choice of instance, only | |
44 | the 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 | |
49 | that applies to a particular version then the priority assigned to that | |
50 | version is the priority of the distribution to which that version | |
51 | belongs. It is possible to single out a distribution, "the target release", | |
52 | which receives a higher priority than other distributions do by default. | |
53 | The target release can be set on the <command>apt-get</command> command | |
54 | line or in the APT configuration file <filename>/etc/apt/apt.conf</filename>. | |
55 | For example, | |
56 | ||
57 | <programlisting> | |
58 | <command>apt-get install -t testing <replaceable>some-package</replaceable></command> | |
59 | </programlisting> | |
60 | <programlisting> | |
61 | APT::Default-Release "stable"; | |
62 | </programlisting> | |
63 | </para> | |
64 | ||
65 | <para>If the target release has been specified then APT uses the following | |
66 | algorithm 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 | |
87 | priority 100 to all installed package versions and priority 500 to all | |
88 | uninstalled package versions.</para> | |
89 | ||
90 | <para>APT then applies the following rules, listed in order of precedence, | |
91 | to determine which version of a package to install. | |
92 | <itemizedlist> | |
93 | <listitem><simpara>Never downgrade unless the priority of an available | |
94 | version exceeds 1000. ("Downgrading" is installing a less recent version | |
95 | of a package in place of a more recent version. Note that none of APT's | |
96 | default priorities exceeds 1000; such high priorities can only be set in | |
97 | the preferences file. Note also that downgrading a package | |
98 | can 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, | |
101 | install the most recent one (that is, the one with the higher version | |
102 | number).</simpara></listitem> | |
103 | <listitem><simpara>If two or more versions have the same priority and | |
104 | version 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) | |
110 | is not as recent as one of the versions available from the sources listed in | |
111 | the &sources-list; file (priority 500 or 990). Then the package will be upgraded | |
112 | when <command>apt-get install <replaceable>some-package</replaceable></command> | |
113 | or <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 | |
117 | than any of the other available versions. The package will not be downgraded | |
118 | when <command>apt-get install <replaceable>some-package</replaceable></command> | |
119 | or <command>apt-get upgrade</command> is executed.</para> | |
120 | ||
121 | <para>Sometimes the installed version of a package is more recent than the | |
122 | version belonging to the target release, but not as recent as a version | |
123 | belonging to some other distribution. Such a package will indeed be upgraded | |
124 | when <command>apt-get install <replaceable>some-package</replaceable></command> | |
125 | or <command>apt-get upgrade</command> is executed, | |
126 | because at least <emphasis>one</emphasis> of the available versions has a higher | |
127 | priority 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 | |
133 | assignment of priorities. The file consists of one or more multi-line records | |
134 | separated by blank lines. Records can have one of two forms, a specific form | |
135 | and a general form. | |
136 | <itemizedlist> | |
137 | <listitem> | |
138 | <simpara>The specific form assigns a priority (a "Pin-Priority") to a | |
139 | specified package and specified version or version range. For example, | |
140 | the following record assigns a high priority to all versions of | |
141 | the <filename>perl</filename> package whose version number begins with "<literal>5.8</literal>".</simpara> | |
142 | ||
143 | <programlisting> | |
144 | Package: perl | |
145 | Pin: version 5.8* | |
146 | Pin-Priority: 1001 | |
147 | </programlisting> | |
148 | </listitem> | |
149 | ||
150 | <listitem><simpara>The general form assigns a priority to all of the package versions in a | |
151 | given distribution (that is, to all the versions of packages that are | |
152 | listed in a certain <filename>Release</filename> file) or to all of the package | |
153 | versions coming from a particular Internet site, as identified by the | |
154 | site's fully qualified domain name.</simpara> | |
155 | ||
156 | <simpara>This general-form entry in the APT preferences file applies only | |
157 | to groups of packages. For example, the following record assigns a high | |
158 | priority to all package versions available from the local site.</simpara> | |
159 | ||
160 | <programlisting> | |
161 | Package: * | |
162 | Pin: origin "" | |
163 | Pin-Priority: 999 | |
164 | </programlisting> | |
165 | ||
166 | <simpara>A note of caution: the keyword used here is "<literal>origin</literal>". | |
167 | This should not be confused with the Origin of a distribution as | |
168 | specified in a <filename>Release</filename> file. What follows the "Origin:" tag | |
169 | in a <filename>Release</filename> file is not an Internet address | |
170 | but 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 | |
173 | belonging to any distribution whose Archive name is "<literal>unstable</literal>".</simpara> | |
174 | ||
175 | <programlisting> | |
176 | Package: * | |
177 | Pin: release a=unstable | |
178 | Pin-Priority: 50 | |
179 | </programlisting> | |
180 | ||
181 | <simpara>The following record assigns a high priority to all package versions | |
182 | belonging to any release whose Archive name is "<literal>stable</literal>" | |
183 | and whose release Version number is "<literal>3.0</literal>".</simpara> | |
184 | ||
185 | <programlisting> | |
186 | Package: * | |
187 | Pin: release a=unstable, v=3.0 | |
188 | Pin-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> | |
200 | Priorities (P) assigned in the APT preferences file must be positive | |
201 | or negative integers. They are interpreted as follows (roughly speaking): | |
202 | ||
203 | <variablelist> | |
204 | <varlistentry> | |
205 | <term>P > 1000</term> | |
206 | <listitem><simpara>causes a version to be installed even if this | |
207 | constitutes a downgrade of the package</simpara></listitem> | |
208 | </varlistentry> | |
209 | <varlistentry> | |
210 | <term>990 < P <=1000</term> | |
211 | <listitem><simpara>causes a version to be installed | |
212 | even if it does not come from the target release, | |
213 | unless the installed version is more recent</simpara></listitem> | |
214 | </varlistentry> | |
215 | <varlistentry> | |
216 | <term>500 < P <=990</term> | |
217 | <listitem><simpara>causes a version to be installed | |
218 | unless there is a version available belonging to the target release | |
219 | or the installed version is more recent</simpara></listitem> | |
220 | </varlistentry> | |
221 | <varlistentry> | |
222 | <term>100 < P <=500</term> | |
223 | <listitem><simpara>causes a version to be installed | |
224 | unless there is a version available belonging to some other | |
225 | distribution or the installed version is more recent</simpara></listitem> | |
226 | </varlistentry> | |
227 | <varlistentry> | |
228 | <term>0 < P <=100</term> | |
229 | <listitem><simpara>causes a version to be installed | |
230 | only if there is no installed version of the package</simpara></listitem> | |
231 | </varlistentry> | |
232 | <varlistentry> | |
233 | <term>P < 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 | |
240 | first such record determines the priority of the package version. | |
241 | Failing that, | |
242 | if any general-form records match an available package version then the | |
243 | first such record determines the priority of the package version.</para> | |
244 | ||
245 | <para>For example, suppose the APT preferences file contains the three | |
246 | records presented earlier:</para> | |
247 | ||
248 | <programlisting> | |
249 | Package: perl | |
250 | Pin: version 5.8* | |
251 | Pin-Priority: 1001 | |
252 | ||
253 | Package: * | |
254 | Pin: origin "" | |
255 | Pin-Priority: 999 | |
256 | ||
257 | Package: * | |
258 | Pin: release unstable | |
259 | Pin-Priority: 50 | |
260 | </programlisting> | |
261 | ||
262 | <para>Then: | |
263 | <itemizedlist> | |
264 | <listitem><simpara>The most recent available version of the <literal>perl</literal> | |
265 | package will be installed, so long as that version's version number begins | |
266 | with "<literal>5.8</literal>". If <emphasis>any</emphasis> 5.8* version of <literal>perl</literal> is | |
267 | available and the installed version is 5.9*, then <literal>perl</literal> will be | |
268 | downgraded.</simpara></listitem> | |
269 | <listitem><simpara>A version of any package other than <literal>perl</literal> | |
270 | that is available from the local system has priority over other versions, | |
271 | even versions belonging to the target release. | |
272 | </simpara></listitem> | |
273 | <listitem><simpara>A version of a package whose origin is not the local | |
274 | system but some other site listed in &sources-list; and which belongs to | |
275 | an <literal>unstable</literal> distribution is only installed if it is selected | |
276 | for 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 | |
287 | to 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>: | |
291 | for example, <filename>.../dists/stable/main/binary-i386/Packages</filename>. | |
292 | It consists of a series of multi-line records, one for each package available | |
293 | in that directory. Only two lines in each record are relevant for setting | |
294 | APT 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>: | |
309 | for example, <filename>.../dists/stable/Release</filename>, | |
310 | or <filename>.../dists/woody/Release</filename>. | |
311 | It consists of a single multi-line record which applies to <emphasis>all</emphasis> of | |
312 | the 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> | |
314 | file 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 | |
320 | in the directory tree belong. For example, the line | |
321 | "Archive: stable" | |
322 | specifies that all of the packages in the directory | |
323 | tree 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 | |
325 | would require the line: | |
326 | </simpara> | |
327 | <programlisting> | |
328 | Pin: 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 | |
336 | packages in the tree might belong to Debian GNU/Linux release | |
337 | version 3.0. Note that there is normally no version number for the | |
338 | <literal>testing</literal> and <literal>unstable</literal> distributions because they | |
339 | have not been released yet. Specifying this in the APT preferences | |
340 | file would require one of the following lines. | |
341 | </simpara> | |
342 | ||
343 | <programlisting> | |
344 | Pin: release v=3.0 | |
345 | Pin: release a=stable, v=3.0 | |
346 | Pin: 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 | |
355 | packages in the directory tree of the <filename>Release</filename> file. | |
356 | For example, the line "Component: main" specifies that | |
357 | all the packages in the directory tree are from the <literal>main</literal> | |
358 | component, which entails that they are licensed under terms listed | |
359 | in the Debian Free Software Guidelines. Specifying this component | |
360 | in the APT preferences file would require the line: | |
361 | </simpara> | |
362 | <programlisting> | |
363 | Pin: 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 | |
371 | directory tree of the <filename>Release</filename> file. Most commonly, this is | |
372 | <literal>Debian</literal>. Specifying this origin in the APT preferences file | |
373 | would require the line: | |
374 | </simpara> | |
375 | <programlisting> | |
376 | Pin: 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 | |
384 | of the <filename>Release</filename> file. Most commonly, this is | |
385 | <literal>Debian</literal>. Specifying this label in the APT preferences file | |
386 | would require the line: | |
387 | </simpara> | |
388 | <programlisting> | |
389 | Pin: 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> | |
397 | files retrieved from locations listed in the &sources-list; file are stored | |
398 | in the directory <filename>/var/lib/apt/lists</filename>, or in the file named | |
399 | by the variable <literal>Dir::State::Lists</literal> in the <filename>apt.conf</filename> file. | |
400 | For example, the file | |
401 | <filename>debian.lcs.mit.edu_debian_dists_unstable_contrib_binary-i386_Release</filename> | |
402 | contains the <filename>Release</filename> file retrieved from the site | |
403 | <literal>debian.lcs.mit.edu</literal> for <literal>binary-i386</literal> architecture | |
404 | files from the <literal>contrib</literal> component of the <literal>unstable</literal> | |
405 | distribution.</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 | |
412 | one or more lines beginning with the word <literal>Explanation:</literal>. | |
413 | This provides a place for comments.</para> | |
414 | ||
415 | <para>The <literal>Pin-Priority:</literal> line in each APT preferences record is | |
416 | optional. If omitted, APT assigs a priority of 1 less than the last value | |
417 | specified 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 | |
427 | priority higher than the default (500) to all package versions belonging | |
428 | to a <literal>stable</literal> distribution and a prohibitively low priority to | |
429 | package versions belonging to other <literal>Debian</literal> distributions. | |
430 | ||
431 | <programlisting> | |
432 | Explanation: Uninstall or do not install any Debian-originated | |
433 | Explanation: package versions other than those in the stable distro | |
434 | Package: * | |
435 | Pin: release a=stable | |
436 | Pin-Priority: 900 | |
437 | ||
438 | Package: * | |
439 | Pin: release o=Debian | |
440 | Pin-Priority: -10 | |
441 | </programlisting> | |
442 | </para> | |
443 | ||
444 | <para>With a suitable &sources-list; file and the above preferences file, | |
445 | any of the following commands will cause APT to upgrade to the | |
446 | latest <literal>stable</literal> version(s). | |
447 | ||
448 | <programlisting> | |
449 | apt-get install <replaceable>package-name</replaceable> | |
450 | apt-get upgrade | |
451 | apt-get dist-upgrade | |
452 | </programlisting> | |
453 | </para> | |
454 | ||
455 | <para>The following command will cause APT to upgrade the specified | |
456 | package to the latest version from the <literal>testing</literal> distribution; | |
457 | the package will not be upgraded again unless this command is given | |
458 | again. | |
459 | ||
460 | <programlisting> | |
461 | apt-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 | |
470 | a high priority to package versions from the <literal>testing</literal> | |
471 | distribution, a lower priority to package versions from the | |
472 | <literal>unstable</literal> distribution, and a prohibitively low priority | |
473 | to package versions from other <literal>Debian</literal> distributions. | |
474 | ||
475 | <programlisting> | |
476 | Package: * | |
477 | Pin: release a=testing | |
478 | Pin-Priority: 900 | |
479 | ||
480 | Package: * | |
481 | Pin: release a=unstable | |
482 | Pin-Priority: 800 | |
483 | ||
484 | Package: * | |
485 | Pin: release o=Debian | |
486 | Pin-Priority: -10 | |
487 | </programlisting> | |
488 | </para> | |
489 | ||
490 | <para>With a suitable &sources-list; file and the above preferences file, | |
491 | any of the following commands will cause APT to upgrade to the latest | |
492 | <literal>testing</literal> version(s). | |
493 | ||
494 | <programlisting> | |
495 | apt-get install <replaceable>package-name</replaceable> | |
496 | apt-get upgrade | |
497 | apt-get dist-upgrade | |
498 | </programlisting> | |
499 | </para> | |
500 | ||
501 | <para>The following command will cause APT to upgrade the specified | |
502 | package to the latest version from the <literal>unstable</literal> distribution. | |
503 | Thereafter, <command>apt-get upgrade</command> will upgrade | |
504 | the package to the most recent <literal>testing</literal> version if that is | |
505 | more recent than the installed version, otherwise, to the most recent | |
506 | <literal>unstable</literal> version if that is more recent than the installed | |
507 | version. | |
508 | ||
509 | <programlisting> | |
510 | apt-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 |