apt_preferences.5.sgml 18 KB

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