apt_preferences.5.xml 19 KB

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