apt_preferences.5.sgml 18 KB

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