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