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