apt_preferences.5.xml 19 KB

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