apt_preferences.5.sgml 18 KB

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