apt_preferences.5.xml 19 KB

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