1APT_PREFERENCES(5)                    APT                   APT_PREFERENCES(5)
2
3
4

NAME

6       apt_preferences - Preference control file for APT
7

DESCRIPTION

9       The APT preferences file /etc/apt/preferences and the fragment files in
10       the /etc/apt/preferences.d/ folder can be used to control which
11       versions of packages will be selected for installation.
12
13       Several versions of a package may be available for installation when
14       the sources.list(5) file contains references to more than one
15       distribution (for example, stable and testing). APT assigns a priority
16       to each version that is available. Subject to dependency constraints,
17       apt-get selects the version with the highest priority for installation.
18       The APT preferences override the priorities that APT assigns to package
19       versions by default, thus giving the user control over which one is
20       selected for installation.
21
22       Several instances of the same version of a package may be available
23       when the sources.list(5) file contains references to more than one
24       source. In this case apt-get downloads the instance listed earliest in
25       the sources.list(5) file. The APT preferences do not affect the choice
26       of instance, only the choice of version.
27
28       Preferences are a strong power in the hands of a system administrator
29       but they can become also their biggest nightmare if used without care!
30       APT will not question the preferences, so wrong settings can lead to
31       uninstallable packages or wrong decisions while upgrading packages.
32       Even more problems will arise if multiple distribution releases are
33       mixed without a good understanding of the following paragraphs.
34       Packages included in a specific release aren't tested in (and therefore
35       don't always work as expected in) older or newer releases, or together
36       with other packages from different releases. You have been warned.
37
38       Note that the files in the /etc/apt/preferences.d directory are parsed
39       in alphanumeric ascending order and need to obey the following naming
40       convention: The files have either no or "pref" as filename extension
41       and only contain alphanumeric, hyphen (-), underscore (_) and period
42       (.) characters. Otherwise APT will print a notice that it has ignored a
43       file, unless that file matches a pattern in the
44       Dir::Ignore-Files-Silently configuration list - in which case it will
45       be silently ignored.
46
47   APT's Default Priority Assignments
48       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
52       release", which receives a higher priority than other distributions do
53       by default. The target release can be set on the apt-get command line
54       or in the APT configuration file /etc/apt/apt.conf. Note that this has
55       precedence over any general priority you set in the
56       /etc/apt/preferences file described later, but not over specifically
57       pinned packages. For example,
58
59           apt-get install -t testing some-package
60
61
62
63           APT::Default-Release "stable";
64
65       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       priority 1
69           to the versions coming from archives which in their Release files
70           are marked as "NotAutomatic: yes" but not as "ButAutomaticUpgrades:
71           yes" like the Debian experimental archive, as well as versions that
72           are not phased on this systems.
73
74       priority 100
75           to the version that is already installed (if any) and to the
76           versions coming from archives which in their Release files are
77           marked as "NotAutomatic: yes" and "ButAutomaticUpgrades: yes" like
78           the Debian backports archive since squeeze-backports.
79
80       priority 500
81           to the versions that do not belong to the target release.
82
83       priority 990
84           to the versions that belong to the target release.
85       The highest of those priorities whose description matches the version
86       is assigned to the version.
87
88       If the target release has not been specified then APT simply assigns
89       priority 100 to all installed package versions and priority 500 to all
90       uninstalled package versions, except versions coming from archives
91       which in their Release files are marked as "NotAutomatic: yes" - these
92       versions get the priority 1 or priority 100 if it is additionally
93       marked as "ButAutomaticUpgrades: yes".
94
95       APT then applies the following rules, listed in order of precedence, to
96       determine which version of a package to install.
97
98       •   Never downgrade unless the priority of an available version exceeds
99           1000. ("Downgrading" is installing a less recent version of a
100           package in place of a more recent version. Note that none of APT's
101           default priorities exceeds 1000; such high priorities can only be
102           set in the preferences file. Note also that downgrading a package
103           can be risky.)
104
105       •   Install the highest priority version.
106
107       •   If two or more versions have the same priority, install the most
108           recent one (that is, the one with the higher version number).
109
110       •   If two or more versions have the same priority and version number
111           but either the packages differ in some of their metadata or the
112           --reinstall option is given, install the uninstalled one.
113
114       In a typical situation, the installed version of a package (priority
115       100) is not as recent as one of the versions available from the sources
116       listed in the sources.list(5) file (priority 500 or 990). Then the
117       package will be upgraded when apt-get install some-package or apt-get
118       upgrade is executed.
119
120       More rarely, the installed version of a package is more recent than any
121       of the other available versions. The package will not be downgraded
122       when apt-get install some-package or apt-get upgrade is executed.
123
124       Sometimes the installed version of a package is more recent than the
125       version belonging to the target release, but not as recent as a version
126       belonging to some other distribution. Such a package will indeed be
127       upgraded when apt-get install some-package or apt-get upgrade is
128       executed, because at least one of the available versions has a higher
129       priority than the installed version.
130
131   Phased Updates
132       APT understands a field called Phased-Update-Percentage which can be
133       used to control the rollout of a new version. It is an integer between
134       0 and 100.
135
136       A system's eligibility to a phased update is determined by seeding
137       random number generator with the package source name, the version
138       number, and /etc/machine-id, and then calculating an integer in the
139       range [0, 100]. If this integer is larger than the
140       Phased-Update-Percentage, the version is pinned to 1, and thus held
141       back. Otherwise, normal policy rules apply.
142
143       In case you have multiple systems that you want to receive the same set
144       of updates, you can set APT::Machine-ID to a UUID such that they all
145       phase the same, or set APT::Get::Never-Include-Phased-Updates or
146       APT::Get::Always-Include-Phased-Updates to true such that APT will
147       never/always consider phased updates.
148
149   The Effect of APT Preferences
150       The APT preferences file allows the system administrator to control the
151       assignment of priorities. The file consists of one or more multi-line
152       records separated by blank lines. Records can have one of two forms, a
153       specific form and a general form.
154
155       •   The specific form assigns a priority (a "Pin-Priority") to one or
156           more specified packages with a specified version or version range.
157           For example, the following record assigns a high priority to all
158           versions of the perl package whose version number begins with
159           "5.20". Multiple packages can be separated by spaces.
160
161               Package: perl
162               Pin: version 5.20*
163               Pin-Priority: 1001
164
165       •   The general form assigns a priority to all of the package versions
166           in a given distribution (that is, to all the versions of packages
167           that are listed in a certain Release file) or to all of the package
168           versions coming from a particular Internet site, as identified by
169           the site's fully qualified domain name.
170
171           This general-form entry in the APT preferences file applies only to
172           groups of packages. For example, the following record assigns a
173           high priority to all package versions available from the local
174           site.
175
176               Package: *
177               Pin: origin ""
178               Pin-Priority: 999
179
180           A note of caution: the keyword used here is "origin" which can be
181           used to match a hostname. The following record will assign a high
182           priority to all versions available from the server identified by
183           the hostname "ftp.de.debian.org"
184
185               Package: *
186               Pin: origin "ftp.de.debian.org"
187               Pin-Priority: 999
188
189           This should not be confused with the Origin of a distribution as
190           specified in a Release file. What follows the "Origin:" tag in a
191           Release file is not an Internet address but an author or vendor
192           name, such as "Debian" or "Ximian".
193
194           The following record assigns a low priority to all package versions
195           belonging to any distribution whose Archive name is "unstable".
196
197               Package: *
198               Pin: release a=unstable
199               Pin-Priority: 50
200
201           The following record assigns a high priority to all package
202           versions belonging to any distribution whose Codename is
203           "bookworm".
204
205               Package: *
206               Pin: release n=bookworm
207               Pin-Priority: 900
208
209           The following record assigns a high priority to all package
210           versions belonging to any release whose Archive name is "stable"
211           and whose release Version number is "11".
212
213               Package: *
214               Pin: release a=stable, v=11
215               Pin-Priority: 500
216
217       The effect of the comma operator is similar to an "and" in logic: All
218       conditions must be satisfied for the pin to match. There is one
219       exception: For any type of condition (such as two "a" conditions), only
220       the last such condition is checked.
221
222   Matching packages in the Package field
223       The Package field specifies the package that a pinning priority is
224       applied to. The field can either contain a binary package name, a
225       source package name (prefixed with "src:"), a glob(7) expression or a
226       regular expression (surrounded by slashes). Multiple package names,
227       glob(7) expressions and regular expressions can be listed separated by
228       whitespace in which case the record will match any of the matched
229       packages.
230
231       By default, only packages of the native architecture are matched. To
232       match binary packages of any architecture, add the :any suffix to the
233       package name. You can also limit matching to a specific architecture by
234       appending the architecture name to the package name, separated by a
235       colon character.
236
237       For example, the following example uses a glob expression and a regular
238       expression to assign the priority 500 to all packages from experimental
239       where the name starts with gnome (as a glob(7)-like expression) or
240       contains the word kde (as a POSIX extended regular expression
241       surrounded by slashes).
242
243           Package: gnome* /kde/
244           Pin: release a=experimental
245           Pin-Priority: 500
246
247       The rule for those expressions is that they can occur anywhere where a
248       string can occur. Thus, the following pin assigns the priority 990 to
249       all packages from a release starting with hirsute.
250
251           Package: *
252           Pin: release n=hirsute*
253           Pin-Priority: 990
254
255       If a regular expression occurs in a Package field, the behavior is the
256       same as if this regular expression were replaced with a list of all
257       package names it matches. It is undecided whether this will change in
258       the future; thus you should always list wild-card pins first, so later
259       specific pins override it. The pattern "*" in a Package field is not
260       considered a glob(7) expression in itself.
261
262       To pin all binaries produced by the apt source package of this APT's
263       version to 990, you can do:
264
265           Package: src:apt
266           Pin: version 2.4.5
267           Pin-Priority: 990
268
269       Source package pinning can be combined with regular expressions and
270       glob patterns, and can also take a binary architecture.
271
272       For example, let's pin all binaries for all architectures produced by
273       any source package containing apt in its name to 990:
274
275           Package: src:*apt*:any
276           Pin: version *
277           Pin-Priority: 990
278
279       The :any suffix makes sure to select binary packages from any
280       architecture. Without that suffix, apt implicitly assumes the :native
281       suffix which would only select packages from the native architecture.
282
283   How APT Interprets Priorities
284       Priorities (P) assigned in the APT preferences file must be positive or
285       negative integers. They are interpreted as follows (roughly speaking):
286
287       P >= 1000
288           causes a version to be installed even if this constitutes a
289           downgrade of the package
290
291       990 <= P < 1000
292           causes a version to be installed even if it does not come from the
293           target release, unless the installed version is more recent
294
295       500 <= P < 990
296           causes a version to be installed unless there is a version
297           available belonging to the target release or the installed version
298           is more recent
299
300       100 <= P < 500
301           causes a version to be installed unless there is a version
302           available belonging to some other distribution or the installed
303           version is more recent
304
305       0 < P < 100
306           causes a version to be installed only if there is no installed
307           version of the package
308
309       P < 0
310           prevents the version from being installed
311
312       P = 0
313           has undefined behaviour, do not use it.
314
315       The first specific-form record matching an available package version
316       determines the priority of the package version. Failing that, the
317       priority of the package is defined as the maximum of all priorities
318       defined by generic-form records matching the version. Records defined
319       using patterns in the Pin field other than "*" are treated like
320       specific-form records.
321
322       For example, suppose the APT preferences file contains the three
323       records presented earlier:
324
325           Package: perl
326           Pin: version 5.20*
327           Pin-Priority: 1001
328
329           Package: *
330           Pin: origin ""
331           Pin-Priority: 999
332
333           Package: *
334           Pin: release unstable
335           Pin-Priority: 50
336
337       Then:
338
339       •   The most recent available version of the perl package will be
340           installed, so long as that version's version number begins with
341           "5.20". If any 5.20* version of perl is available and the installed
342           version is 5.24*, then perl will be downgraded.
343
344       •   A version of any package other than perl that is available from the
345           local system has priority over other versions, even versions
346           belonging to the target release.
347
348       •   A version of a package whose origin is not the local system but
349           some other site listed in sources.list(5) and which belongs to an
350           unstable distribution is only installed if it is selected for
351           installation and no version of the package is already installed.
352
353
354   Determination of Package Version and Distribution Properties
355       The locations listed in the sources.list(5) file should provide
356       Packages and Release files to describe the packages available at that
357       location.
358
359       The Packages file is normally found in the directory
360       .../dists/dist-name/component/arch: for example,
361       .../dists/stable/main/binary-i386/Packages. It consists of a series of
362       multi-line records, one for each package available in that directory.
363       Only two lines in each record are relevant for setting APT priorities:
364
365       the Package: line
366           gives the package name
367
368       the Version: line
369           gives the version number for the named package
370
371       The Release file is normally found in the directory
372       .../dists/dist-name: for example, .../dists/stable/Release, or
373       .../dists/bullseye/Release. It consists of a single multi-line record
374       which applies to all of the packages in the directory tree below its
375       parent. Unlike the Packages file, nearly all of the lines in a Release
376       file are relevant for setting APT priorities:
377
378       the Archive: or Suite: line
379           names the archive to which all the packages in the directory tree
380           belong. For example, the line "Archive: stable" or "Suite: stable"
381           specifies that all of the packages in the directory tree below the
382           parent of the Release file are in a stable archive. Specifying this
383           value in the APT preferences file would require the line:
384
385               Pin: release a=stable
386
387       the Codename: line
388           names the codename to which all the packages in the directory tree
389           belong. For example, the line "Codename: bookworm" specifies that
390           all of the packages in the directory tree below the parent of the
391           Release file belong to a version named bookworm. Specifying this
392           value in the APT preferences file would require the line:
393
394               Pin: release n=bookworm
395
396       the Version: line
397           names the release version. For example, the packages in the tree
398           might belong to Debian release version 11. Note that there is
399           normally no version number for the testing and unstable
400           distributions because they have not been released yet. Specifying
401           this in the APT preferences file would require one of the following
402           lines.
403
404               Pin: release v=11
405               Pin: release a=stable, v=11
406               Pin: release 11
407
408       the Component: line
409           names the licensing component associated with the packages in the
410           directory tree of the Release file. For example, the line
411           "Component: main" specifies that all the packages in the directory
412           tree are from the main component, which entails that they are
413           licensed under terms listed in the Debian Free Software Guidelines.
414           Specifying this component in the APT preferences file would require
415           the line:
416
417               Pin: release c=main
418
419       the Origin: line
420           names the originator of the packages in the directory tree of the
421           Release file. Most commonly, this is Debian. Specifying this origin
422           in the APT preferences file would require the line:
423
424               Pin: release o=Debian
425
426       the Label: line
427           names the label of the packages in the directory tree of the
428           Release file. Most commonly, this is Debian. Specifying this label
429           in the APT preferences file would require the line:
430
431               Pin: release l=Debian
432
433       All of the Packages and Release files retrieved from locations listed
434       in the sources.list(5) file are stored in the directory
435       /var/lib/apt/lists, or in the file named by the variable
436       Dir::State::Lists in the apt.conf file. For example, the file
437       debian.lcs.mit.edu_debian_dists_unstable_contrib_binary-i386_Release
438       contains the Release file retrieved from the site debian.lcs.mit.edu
439       for binary-i386 architecture files from the contrib component of the
440       unstable distribution.
441
442   Optional Lines in an APT Preferences Record
443       Each record in the APT preferences file can optionally begin with one
444       or more lines beginning with the word Explanation:. This provides a
445       place for comments.
446

EXAMPLES

448   Tracking Stable
449       The following APT preferences file will cause APT to assign a priority
450       higher than the default (500) to all package versions belonging to a
451       stable distribution and a prohibitively low priority to package
452       versions belonging to other Debian distributions.
453
454           Explanation: Uninstall or do not install any Debian-originated
455           Explanation: package versions other than those in the stable distro
456           Package: *
457           Pin: release a=stable
458           Pin-Priority: 900
459
460           Package: *
461           Pin: release o=Debian
462           Pin-Priority: -10
463
464       With a suitable sources.list(5) file and the above preferences file,
465       any of the following commands will cause APT to upgrade to the latest
466       stable version(s).
467
468           apt-get install package-name
469           apt-get upgrade
470           apt-get dist-upgrade
471
472       The following command will cause APT to upgrade the specified package
473       to the latest version from the testing distribution; the package will
474       not be upgraded again unless this command is given again.
475
476           apt-get install package/testing
477
478
479   Tracking Testing or Unstable
480       The following APT preferences file will cause APT to assign a high
481       priority to package versions from the testing distribution, a lower
482       priority to package versions from the unstable distribution, and a
483       prohibitively low priority to package versions from other Debian
484       distributions.
485
486           Package: *
487           Pin: release a=testing
488           Pin-Priority: 900
489
490           Package: *
491           Pin: release a=unstable
492           Pin-Priority: 800
493
494           Package: *
495           Pin: release o=Debian
496           Pin-Priority: -10
497
498       With a suitable sources.list(5) file and the above preferences file,
499       any of the following commands will cause APT to upgrade to the latest
500       testing version(s).
501
502           apt-get install package-name
503           apt-get upgrade
504           apt-get dist-upgrade
505
506       The following command will cause APT to upgrade the specified package
507       to the latest version from the unstable distribution. Thereafter,
508       apt-get upgrade will upgrade the package to the most recent testing
509       version if that is more recent than the installed version, otherwise,
510       to the most recent unstable version if that is more recent than the
511       installed version.
512
513           apt-get install package/unstable
514
515
516   Tracking the evolution of a codename release
517       The following APT preferences file will cause APT to assign a priority
518       higher than the default (500) to all package versions belonging to a
519       specified codename of a distribution and a prohibitively low priority
520       to package versions belonging to other Debian distributions, codenames
521       and archives. Note that with this APT preference APT will follow the
522       migration of a release from the archive testing to stable and later
523       oldstable. If you want to follow for example the progress in testing
524       notwithstanding the codename changes you should use the example
525       configurations above.
526
527           Explanation: Uninstall or do not install any Debian-originated package versions
528           Explanation: other than those in the distribution codenamed with bookworm or sid
529           Package: *
530           Pin: release n=bookworm
531           Pin-Priority: 900
532
533           Explanation: Debian unstable is always codenamed with sid
534           Package: *
535           Pin: release n=sid
536           Pin-Priority: 800
537
538           Package: *
539           Pin: release o=Debian
540           Pin-Priority: -10
541
542       With a suitable sources.list(5) file and the above preferences file,
543       any of the following commands will cause APT to upgrade to the latest
544       version(s) in the release codenamed with bookworm.
545
546           apt-get install package-name
547           apt-get upgrade
548           apt-get dist-upgrade
549
550       The following command will cause APT to upgrade the specified package
551       to the latest version from the sid distribution. Thereafter, apt-get
552       upgrade will upgrade the package to the most recent bookworm version if
553       that is more recent than the installed version, otherwise, to the most
554       recent sid version if that is more recent than the installed version.
555
556           apt-get install package/sid
557
558

FILES

560       /etc/apt/preferences
561           Version preferences file. This is where you would specify
562           "pinning", i.e. a preference to get certain packages from a
563           separate source or from a different version of a distribution.
564           Configuration Item: Dir::Etc::Preferences.
565
566       /etc/apt/preferences.d/
567           File fragments for the version preferences. Configuration Item:
568           Dir::Etc::PreferencesParts.
569

SEE ALSO

571       apt-get(8) apt-cache(8) apt.conf(5) sources.list(5)
572

BUGS

574       APT bug page[1]. If you wish to report a bug in APT, please see
575       /usr/share/doc/debian/bug-reporting.txt or the reportbug(1) command.
576

AUTHOR

578       APT team
579

NOTES

581        1. APT bug page
582           http://bugs.debian.org/src:apt
583
584
585
586APT 2.4.5                       03 January 2022             APT_PREFERENCES(5)
Impressum