Manipulating_Packages_with_dpkg.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title xmlns:d="http://docbook.org/ns/docbook">5.4. Manipulating Packages with dpkg</title><link rel="stylesheet" type="text/css" href="Common_Content/css/default.css" /><link rel="stylesheet" media="print" href="Common_Content/css/print.css" type="text/css" /><meta xmlns:d="http://docbook.org/ns/docbook" name="generator" content="publican v4.3.2" /><meta xmlns:d="http://docbook.org/ns/docbook" name="package" content="Debian-debian-handbook-10-en-US-1.0-1" /><meta name="keywords" content="Binary package, Source package, dpkg, deb, dependencies, conflict" /><link rel="home" href="index.html" title="The Debian Administrator's Handbook" /><link rel="up" href="packaging-system.html" title="Chapter 5. Packaging System: Tools and Fundamental Principles" /><link rel="prev" href="sect.source-package-structure.html" title="5.3. Structure of a Source Package" /><link rel="next" href="sect.coexistence-with-other-packaging-systems.html" title="5.5. Coexistence with Other Packaging Systems" /><meta xmlns="" name="flattr:id" content="4pz9jq" /><link xmlns="" rel="canonical" href="https://debian-handbook.info/browse/stable/sect.manipulating-packages-with-dpkg.html" /></head><body><div id="banner"><a href="http://debian-handbook.info/get/"><span class="text">Download the ebook</span></a></div><p id="title"><a class="left" href="http://www.debian.org"><img alt="Product Site" src="Common_Content/images//image_left.png" /></a><a class="right" href="index.html"><img alt="Documentation Site" src="Common_Content/images//image_right.png" /></a></p><ul class="docnav top"><li class="previous"><a accesskey="p" href="sect.source-package-structure.html"><strong>Prev</strong></a></li><li class="home">The Debian Administrator's Handbook</li><li class="next"><a accesskey="n" href="sect.coexistence-with-other-packaging-systems.html"><strong>Next</strong></a></li></ul><div class="section"><div class="titlepage"><div><div><h2 class="title"><a xmlns="" id="sect.manipulating-packages-with-dpkg"></a>5.4. Manipulating Packages with <code class="command">dpkg</code></h2></div></div></div><a id="id-1.8.8.2" class="indexterm"></a><div class="para">
  3. <code class="command">dpkg</code> is the base command for handling Debian packages on the system. If you have <code class="filename">.deb</code> packages, it is <code class="command">dpkg</code> that allows installation or analysis of their contents. But this program only has a partial view of the Debian universe: it knows what is installed on the system, and whatever it is given on the command line, but knows nothing of the other available packages. As such, it will fail if a dependency is not met. Tools such as <code class="command">apt</code> and <code class="command">aptitude</code>, on the contrary, will create a list of dependencies to install everything as automatically as possible.
  4. </div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong><span class="emphasis"><em>NOTE</em></span> <code class="command">dpkg</code> or <code class="command">apt</code>?</strong></p></div></div></div><div class="para">
  5. <code class="command">dpkg</code> should be seen as a system tool (backend), and <code class="command">apt</code> as a tool closer to the user, which overcomes the limitations of the former. These tools work together, each one with its particularities, suited to specific tasks.
  6. </div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a xmlns="" id="id-1.8.8.5"></a>5.4.1. Installing Packages</h3></div></div></div><a id="id-1.8.8.5.2" class="indexterm"></a><a id="id-1.8.8.5.3" class="indexterm"></a><div class="para">
  7. <code class="command">dpkg</code> is, above all, the tool for installing an already available Debian package (because it does not download anything). To do this, we use its <code class="literal">-i</code> or <code class="literal">--install</code> option.
  8. </div><div class="example"><a xmlns="" id="id-1.8.8.5.5"></a><p class="title"><strong>Example 5.2. Installation of a package with <code class="command">dpkg</code></strong></p><div class="example-contents"><pre class="screen scale">
  9. <code class="computeroutput"># </code><strong class="userinput"><code>dpkg -i man-db_2.8.5-2_amd64.deb</code></strong>
  10. <code class="computeroutput">(Reading database ... 14913 files and directories currently installed.)
  11. Preparing to unpack .../man-db_2.8.5-2_amd64.deb ...
  12. Unpacking man-db (2.8.5-2) over (2.8.5-2) ...
  13. Setting up man-db (2.8.5-2) ...
  14. Updating database of manual pages ...
  15. Processing triggers for mime-support (3.62) ...</code></pre></div></div><div class="para">
  16. We can see the different steps performed by <code class="command">dpkg</code>; we know, thus, at what point any error may have occurred. The installation can also be effected in two stages: first unpacking, then configuration. <code class="command">apt</code> takes advantage of this, limiting the number of calls to <code class="command">dpkg</code> (since each call is costly, due to loading of the database in memory, especially the list of already installed files).
  17. </div><div class="example"><a xmlns="" id="id-1.8.8.5.7"></a><p class="title"><strong>Example 5.3. Separate unpacking and configuration</strong></p><div class="example-contents"><pre class="screen scale">
  18. <code class="computeroutput"># </code><strong class="userinput"><code>dpkg --unpack man-db_2.8.5-2_amd64.deb</code></strong>
  19. <code class="computeroutput">(Reading database ... 14937 files and directories currently installed.)
  20. Preparing to unpack man-db_2.8.5-2_amd64.deb ...
  21. Unpacking man-db (2.8.5-2) over (2.8.5-2) ...
  22. Processing triggers for mime-support (3.62) ...
  23. # </code><strong class="userinput"><code>dpkg --configure man-db</code></strong>
  24. <code class="computeroutput">Setting up man-db (2.8.5-2) ...
  25. Updating database of manual pages ...
  26. </code></pre></div></div><a id="id-1.8.8.5.8" class="indexterm"></a><a id="id-1.8.8.5.9" class="indexterm"></a><div class="para">
  27. Sometimes <code class="command">dpkg</code> will fail to install a package and return an error; if the user orders it to ignore this, it will only issue a warning; it is for this reason that we have the different <code class="literal">--force-*</code> options. The <code class="command">dpkg --force-help</code> command, or documentation of this command, will give a complete list of these options. The most frequent error, which you are bound to encounter sooner or later, is a file collision. When a package contains a file that is already installed by another package, <code class="command">dpkg</code> will refuse to install it. The following messages will then appear:
  28. </div><pre class="screen">
  29. <code class="computeroutput">Unpacking libgdm (from .../libgdm_3.8.3-2_amd64.deb) ...
  30. dpkg: error processing /var/cache/apt/archives/libgdm_3.8.3-2_amd64.deb (--unpack):
  31. trying to overwrite '/usr/bin/gdmflexiserver', which is also in package gdm3 3.4.1-9</code></pre><div class="para">
  32. In this case, if you think that replacing this file is not a significant risk to the stability of your system (which is usually the case), you can use the option <code class="literal">--force-overwrite</code>, which tells <code class="command">dpkg</code> to ignore this error and overwrite the file.
  33. </div><div class="para">
  34. While there are many available <code class="literal">--force-*</code> options, only <code class="literal">--force-overwrite</code> is likely to be used regularly. These options only exist for exceptional situations, and it is better to leave them alone as much as possible in order to respect the rules imposed by the packaging mechanism. Do not forget, these rules ensure the consistency and stability of your system.
  35. </div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong><span class="emphasis"><em>CAUTION</em></span> Effective use of <code class="literal">--force-*</code></strong></p></div></div></div><a id="id-1.8.8.5.14.2" class="indexterm"></a><div class="para">
  36. If you are not careful, the use of an option <code class="literal">--force-*</code> can lead to a system where the APT family of commands will refuse to function. In effect, some of these options allow installation of a package when a dependency is not met, or when there is a conflict. The result is an inconsistent system from the point of view of dependencies, and the APT commands will refuse to execute any action except those that will bring the system back to a consistent state (this often consists of installing the missing dependency or removing a problematic package). This often results in a message like this one, obtained after installing a new version of <span class="pkg pkg">rdesktop</span> while ignoring its dependency on a newer version of the <span class="pkg pkg">libc6</span>:
  37. </div><pre class="screen"><code class="computeroutput"># </code><strong class="userinput"><code>apt full-upgrade
  38. </code></strong><code class="computeroutput">[...]
  39. You might want to run 'apt-get -f install' to correct these.
  40. The following packages have unmet dependencies:
  41. rdesktop: Depends: libc6 (&gt;= 2.5) but 2.3.6.ds1-13etch7 is installed
  42. E: Unmet dependencies. Try using -f.</code></pre><div class="para">
  43. A courageous administrator who is certain of the correctness of their analysis may choose to ignore a dependency or conflict and use the corresponding <code class="literal">--force-*</code> option. In this case, if they want to be able to continue to use <code class="command">apt</code> or <code class="command">aptitude</code>, they must edit <code class="filename">/var/lib/dpkg/status</code> to delete/modify the dependency, or conflict, that they chose to override.
  44. </div><div class="para">
  45. This manipulation is an ugly hack, and should never be used, except in the most extreme case of necessity. Quite frequently, a more fitting solution is to recompile the package that is causing the problem (see <a class="xref" href="debian-packaging.html#sect.rebuilding-package">Section 15.1, “Rebuilding a Package from its Sources”</a>) or use a new version (potentially corrected) from a repository such as the <code class="literal">stable-backports</code> one (see <a class="xref" href="apt.html#sect.apt-sources.list.stable.backports">Section 6.1.2.4, “Stable Backports”</a>).
  46. </div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a xmlns="" id="id-1.8.8.6"></a>5.4.2. Package Removal</h3></div></div></div><a id="id-1.8.8.6.2" class="indexterm"></a><a id="id-1.8.8.6.3" class="indexterm"></a><a id="id-1.8.8.6.4" class="indexterm"></a><a id="id-1.8.8.6.5" class="indexterm"></a><div class="para">
  47. Invoking <code class="command">dpkg</code> with the <code class="literal">-r</code> or <code class="literal">--remove</code> option, followed by the name of a package, removes that package. This removal is, however, not complete: all of the configuration files, maintainer scripts, log files (system logs) and other user data handled by the package remain. That way disabling the program is easily done by uninstalling it, and it is still possible to quickly reinstall it with the same configuration. To completely remove everything associated with a package, use the <code class="literal">-P</code> or <code class="literal">--purge</code> option, followed by the package name.
  48. </div><div class="example"><a xmlns="" id="id-1.8.8.6.7"></a><p class="title"><strong>Example 5.4. Removal and purge of the <span class="pkg pkg">debian-cd</span> package</strong></p><div class="example-contents"><pre class="screen"><code class="computeroutput"># </code><strong class="userinput"><code>dpkg -r debian-cd</code></strong>
  49. <code class="computeroutput">(Reading database ... 15915 files and directories currently installed.)
  50. Removing debian-cd (3.1.25) ...
  51. # </code><strong class="userinput"><code>dpkg -P debian-cd</code></strong>
  52. <code class="computeroutput">(Reading database ... 15394 files and directories currently installed.)
  53. Purging configuration files for debian-cd (3.1.25) ...
  54. </code></pre></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a xmlns="" id="sect.dpkg-list"></a>5.4.3. Querying <code class="command">dpkg</code>'s Database and Inspecting <code class="filename">.deb</code> Files</h3></div></div></div><a id="id-1.8.8.7.2" class="indexterm"></a><a id="id-1.8.8.7.3" class="indexterm"></a><a id="id-1.8.8.7.4" class="indexterm"></a><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong><span class="emphasis"><em>BACK TO BASICS</em></span> Option syntax</strong></p></div></div></div><div class="para">
  55. Most options are available in a “long” version (one or more relevant words, preceded by a double dash) and a “short” version (a single letter, often the initial of one word from the long version, and preceded by a single dash). This convention is so common that it is a POSIX standard.
  56. </div></div><div class="para">
  57. Before concluding this section, we will study <code class="command">dpkg</code> options that query the internal database in order to obtain information. Giving first the long options and then corresponding short options (that will evidently take the same possible arguments) we cite <code class="literal">--listfiles <em class="replaceable">package</em></code> (or <code class="literal">-L</code>), which lists the files installed by this package; <code class="literal">--search <em class="replaceable">file</em></code> (or <code class="literal">-S</code>), which finds the package(s) containing the file; <code class="literal">--status <em class="replaceable">package</em></code> (or <code class="literal">-s</code>), which displays the headers of an installed package; <code class="literal">--list</code> (or <code class="literal">-l</code>), which displays the list of packages known to the system and their installation status; <code class="literal">--contents <em class="replaceable">file.deb</em></code> (or <code class="literal">-c</code>), which lists the files in the Debian package specified; <code class="literal">--info<em class="replaceable"> file.deb </em></code> (or <code class="literal">-I</code>), which displays the headers of this Debian package.
  58. </div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong><span class="emphasis"><em>CAUTION</em></span> <code class="command">dpkg --search</code> and merged <code class="filename">/usr</code></strong></p></div></div></div><a id="id-1.8.8.7.7.2" class="indexterm"></a><a id="id-1.8.8.7.7.3" class="indexterm"></a><div class="para">
  59. For <a href="https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/">various reasons</a>, Debian now installs by default a few top-level directories as symlinks to their counterparts below <code class="filename">/usr</code>. For instance, <code class="filename">/bin</code>, <code class="filename">/sbin</code> and <code class="filename">/lib</code> are now symlinks to, respectively, <code class="filename">/usr/bin</code>, <code class="filename">/usr/sbin</code> and <code class="filename">/usr/lib</code>.
  60. </div><div class="para">
  61. While this does provide desirable benefits, it can also be a source of confusion. For example, when you query <code class="command">dpkg</code> which package is owning a given file, it will only be able to answer when you ask for its original path:
  62. </div><pre class="screen">
  63. $ <strong class="userinput"><code>dpkg --search /bin/mount</code></strong>
  64. mount: /bin/mount
  65. $ <strong class="userinput"><code>dpkg --search /usr/bin/mount</code></strong>
  66. dpkg-query: no path found matching pattern /usr/bin/mount
  67. $ <strong class="userinput"><code>dpkg --search /bin/apt</code></strong>
  68. dpkg-query: no path found matching pattern /bin/apt
  69. $ <strong class="userinput"><code>dpkg --search /usr/bin/apt</code></strong>
  70. apt: /usr/bin/apt
  71. </pre></div><div class="example"><a xmlns="" id="id-1.8.8.7.8"></a><p class="title"><strong>Example 5.5. Various queries with <code class="command">dpkg</code></strong></p><div class="example-contents"><pre class="screen scale" width="80">
  72. <code class="computeroutput">$ </code><strong class="userinput"><code>dpkg -L base-passwd</code></strong>
  73. <code class="computeroutput">/.
  74. /usr
  75. /usr/sbin
  76. /usr/sbin/update-passwd
  77. /usr/share
  78. /usr/share/base-passwd
  79. /usr/share/base-passwd/group.master
  80. /usr/share/base-passwd/passwd.master
  81. /usr/share/doc
  82. /usr/share/doc/base-passwd
  83. /usr/share/doc/base-passwd/README
  84. /usr/share/doc/base-passwd/changelog.gz
  85. /usr/share/doc/base-passwd/copyright
  86. /usr/share/doc/base-passwd/users-and-groups.html
  87. /usr/share/doc/base-passwd/users-and-groups.txt.gz
  88. /usr/share/doc-base
  89. /usr/share/doc-base/users-and-groups
  90. /usr/share/lintian
  91. /usr/share/lintian/overrides
  92. /usr/share/lintian/overrides/base-passwd
  93. /usr/share/man
  94. /usr/share/man/de
  95. /usr/share/man/de/man8
  96. /usr/share/man/de/man8/update-passwd.8.gz
  97. /usr/share/man/es
  98. /usr/share/man/es/man8
  99. /usr/share/man/es/man8/update-passwd.8.gz
  100. /usr/share/man/fr
  101. /usr/share/man/fr/man8
  102. /usr/share/man/fr/man8/update-passwd.8.gz
  103. /usr/share/man/ja
  104. /usr/share/man/ja/man8
  105. /usr/share/man/ja/man8/update-passwd.8.gz
  106. /usr/share/man/man8
  107. /usr/share/man/man8/update-passwd.8.gz
  108. /usr/share/man/pl
  109. /usr/share/man/pl/man8
  110. /usr/share/man/pl/man8/update-passwd.8.gz
  111. /usr/share/man/ru
  112. /usr/share/man/ru/man8
  113. /usr/share/man/ru/man8/update-passwd.8.gz
  114. $ </code><strong class="userinput"><code>dpkg -S /bin/date</code></strong>
  115. <code class="computeroutput">coreutils: /bin/date
  116. $ </code><strong class="userinput"><code>dpkg -s coreutils</code></strong>
  117. <code class="computeroutput">Package: coreutils
  118. Essential: yes
  119. Status: install ok installed
  120. Priority: required
  121. Section: utils
  122. Installed-Size: 15719
  123. Maintainer: Michael Stone &lt;mstone@debian.org&gt;
  124. Architecture: amd64
  125. Multi-Arch: foreign
  126. Version: 8.30-3
  127. Pre-Depends: libacl1 (&gt;= 2.2.23), libattr1 (&gt;= 1:2.4.44), libc6 (&gt;= 2.28), libselinux1 (&gt;= 2.1.13)
  128. Description: GNU core utilities
  129. This package contains the basic file, shell and text manipulation
  130. utilities which are expected to exist on every operating system.
  131. .
  132. Specifically, this package includes:
  133. arch base64 basename cat chcon chgrp chmod chown chroot cksum comm cp
  134. csplit cut date dd df dir dircolors dirname du echo env expand expr
  135. factor false flock fmt fold groups head hostid id install join link ln
  136. logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup nproc numfmt
  137. od paste pathchk pinky pr printenv printf ptx pwd readlink realpath rm
  138. rmdir runcon sha*sum seq shred sleep sort split stat stty sum sync tac
  139. tail tee test timeout touch tr true truncate tsort tty uname unexpand
  140. uniq unlink users vdir wc who whoami yes
  141. Homepage: http://gnu.org/software/coreutils
  142. $ </code><strong class="userinput"><code>dpkg -l 'b*'</code></strong>
  143. <code class="computeroutput">Desired=Unknown/Install/Remove/Purge/Hold
  144. | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
  145. |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
  146. ||/ Name Version Architecture Description
  147. +++-====================-===============-===============-==================================================
  148. un backupninja &lt;none&gt; &lt;none&gt; (no description available)
  149. un backuppc &lt;none&gt; &lt;none&gt; (no description available)
  150. un baobab &lt;none&gt; &lt;node&gt; (no description available)
  151. un base &lt;none&gt; &lt;none&gt; (no description available)
  152. un base-config &lt;none&gt; &lt;none&gt; (no description available)
  153. ii base-files 11 amd64 Debian base system miscellaneous files
  154. ii base-passwd 3.5.46 amd64 Debian base system master password and group files
  155. ii bash 5.0-4 amd64 GNU Bourne Again SHell
  156. [..]
  157. $ </code><strong class="userinput"><code>dpkg -c /var/cache/apt/archives/gnupg-utils_2.2.12-1_amd64.deb</code></strong>
  158. <code class="computeroutput">drwxr-xr-x root/root 0 2018-12-15 02:17 ./
  159. drwxr-xr-x root/root 0 2018-12-15 02:17 ./usr/
  160. drwxr-xr-x root/root 0 2018-12-15 02:17 ./usr/bin/
  161. -rwxr-xr-x root/root 3516 2018-12-15 02:17 ./usr/bin/gpg-zip
  162. -rwxr-xr-x root/root 866256 2018-12-15 02:17 ./usr/bin/gpgcompose
  163. -rwxr-xr-x root/root 30792 2018-12-15 02:17 ./usr/bin/gpgparsemail
  164. -rwxr-xr-x root/root 84432 2018-12-15 02:17 ./usr/bin/gpgsplit
  165. -rwxr-xr-x root/root 154952 2018-12-15 02:17 ./usr/bin/gpgtar
  166. -rwxr-xr-x root/root 166568 2018-12-15 02:17 ./usr/bin/kbxutil
  167. -rwxr-xr-x root/root 1081 2017-08-28 12:22 ./usr/bin/lspgpot
  168. -rwxr-xr-x root/root 2194 2018-11-18 23:37 ./usr/bin/migrate-pubring-from-classic-gpg
  169. -rwxr-xr-x root/root 121576 2018-12-15 02:17 ./usr/bin/symcryptrun
  170. -rwxr-xr-x root/root 18424 2018-12-15 02:17 ./usr/bin/watchgnupg
  171. drwxr-xr-x root/root 0 2018-12-15 02:17 ./usr/sbin/
  172. -rwxr-xr-x root/root 3075 2018-12-15 02:17 ./usr/sbin/addgnupghome
  173. -rwxr-xr-x root/root 2217 2018-12-15 02:17 ./usr/sbin/applygnupgdefaults
  174. drwxr-xr-x root/root 0 2018-12-15 02:17 ./usr/share/
  175. drwxr-xr-x root/root 0 2018-12-15 02:17 ./usr/share/doc/
  176. [...]
  177. $ </code><strong class="userinput"><code>dpkg -I /var/cache/apt/archives/gnupg-utils_2.2.12-1_amd64.deb</code></strong>
  178. <code class="computeroutput"> new Debian package, version 2.0.
  179. size 857408 bytes: control archive=1844 bytes.
  180. 1564 bytes, 32 lines control
  181. 1804 bytes, 28 lines md5sums
  182. Package: gnupg-utils
  183. Source: gnupg2
  184. Version: 2.2.12-1
  185. Architecture: amd64
  186. Maintainer: Debian GnuPG Maintainers &lt;pkg-gnupg-maint@lists.alioth.debian.org&gt;
  187. Installed-Size: 1845
  188. Depends: libassuan0 (&gt;= 2.0.1), libbz2-1.0, libc6 (&gt;= 2.25), libgcrypt20 (&gt;= 1.8.0), libgpg-error0 (&gt;= 1.26-2~), libksba8 (&gt;= 1.3.4), libreadline7 (&gt;= 6.0), zlib1g (&gt;= 1:1.1.4)
  189. Recommends: gpg, gpg-agent, gpgconf, gpgsm
  190. Breaks: gnupg (&lt;&lt; 2.1.21-4), gnupg-agent (&lt;&lt; 2.1.21-4)
  191. Replaces: gnupg (&lt;&lt; 2.1.21-4), gnupg-agent (&lt;&lt; 2.1.21-4)
  192. Section: utils
  193. Priority: optional
  194. Multi-Arch: foreign
  195. Homepage: https://www.gnupg.org/
  196. Description: GNU privacy guard - utility programs
  197. GnuPG is GNU's tool for secure communication and data storage.
  198. .
  199. This package contains several useful utilities for manipulating
  200. OpenPGP data and other related cryptographic elements. It includes:
  201. .
  202. * addgnupghome -- create .gnupg home directories
  203. * applygnupgdefaults -- run gpgconf --apply-defaults for all users
  204. * gpgcompose -- an experimental tool for constructing arbitrary
  205. sequences of OpenPGP packets (e.g. for testing)
  206. * gpgparsemail -- parse an e-mail message into annotated format
  207. * gpgsplit -- split a sequence of OpenPGP packets into files
  208. * gpgtar -- encrypt or sign files in an archive
  209. * kbxutil -- list, export, import Keybox data
  210. * lspgpot -- convert PGP ownertrust values to GnuPG
  211. * migrate-pubring-from-classic-gpg -- use only "modern" formats
  212. * symcryptrun -- use simple symmetric encryption tool in GnuPG framework
  213. * watchgnupg -- watch socket-based logs
  214. [..]</code></pre></div></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong><span class="emphasis"><em>GOING FURTHER</em></span> Comparison of versions</strong></p></div></div></div><a id="id-1.8.8.7.9.2" class="indexterm"></a><a id="id-1.8.8.7.9.3" class="indexterm"></a><a id="id-1.8.8.7.9.4" class="indexterm"></a><div class="para">
  215. Since <code class="command">dpkg</code> is the program for handling Debian packages, it also provides the reference implementation of the logic of comparing version numbers. This is why it has a <code class="literal">--compare-versions</code> option, usable by external programs (especially configuration scripts executed by <code class="command">dpkg</code> itself). This option requires three parameters: a version number, a comparison operator, and a second version number. The different possible operators are <code class="literal">lt</code> (strictly less than), <code class="literal">le</code> (less than or equal to), <code class="literal">eq</code> (equal), <code class="literal">ne</code> (not equal), <code class="literal">ge</code> (greater than or equal to), and <code class="literal">gt</code> (strictly greater than). If the comparison is correct, <code class="command">dpkg</code> returns 0 (success); if not, it gives a non-zero return value (indicating failure).
  216. </div><pre class="screen">
  217. <code class="computeroutput">$ </code><strong class="userinput"><code>dpkg --compare-versions 1.2-3 gt 1.1-4</code></strong>
  218. <code class="computeroutput">$ </code><strong class="userinput"><code>echo $?</code></strong>
  219. <code class="computeroutput">0
  220. $ </code><strong class="userinput"><code>dpkg --compare-versions 1.2-3 lt 1.1-4</code></strong>
  221. <code class="computeroutput">$ </code><strong class="userinput"><code>echo $?</code></strong>
  222. <code class="computeroutput">1
  223. $ </code><strong class="userinput"><code>dpkg --compare-versions 2.6.0pre3-1 lt 2.6.0-1</code></strong>
  224. <code class="computeroutput">$ </code><strong class="userinput"><code>echo $?</code></strong>
  225. <code class="computeroutput">1</code></pre><div class="para">
  226. Note the unexpected failure of the last comparison: for <code class="command">dpkg</code>, <code class="literal">pre</code>, usually denoting a pre-release, has no particular meaning, and this program compares the alphabetic characters in the same way as the numbers (a &lt; b &lt; c ...), in alphabetical order. This is why it considers “<code class="literal">0pre3</code>” to be greater than “<code class="literal">0</code>”. When we want a package's version number to indicate that it is a pre-release, we use the tilde character, “<code class="literal">~</code>”:
  227. </div><pre class="screen">
  228. <code class="computeroutput">$ </code><strong class="userinput"><code>dpkg --compare-versions 2.6.0~pre3-1 lt 2.6.0-1</code></strong>
  229. <code class="computeroutput">$ </code><strong class="userinput"><code>echo $?</code></strong>
  230. <code class="computeroutput">0</code></pre></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a xmlns="" id="sect.dpkg-log"></a>5.4.4. <code class="command">dpkg</code>'s Log File</h3></div></div></div><a id="id-1.8.8.8.2" class="indexterm"></a><div class="para">
  231. <code class="command">dpkg</code> keeps a log of all of its actions in <code class="filename">/var/log/dpkg.log</code>. This log is extremely verbose, since it details every one of the stages through which packages handled by <code class="command">dpkg</code> go. In addition to offering a way to track dpkg's behavior, it helps, above all, to keep a history of the development of the system: one can find the exact moment when each package has been installed or updated, and this information can be extremely useful in understanding a recent change in behavior. Additionally, all versions being recorded, it is easy to cross-check the information with the <code class="filename">changelog.Debian.gz</code> for packages in question, or even with online bug reports.
  232. </div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a xmlns="" id="sect.multi-arch"></a>5.4.5. Multi-Arch Support</h3></div></div></div><a id="id-1.8.8.9.2" class="indexterm"></a><a id="id-1.8.8.9.3" class="indexterm"></a><div class="para">
  233. All Debian packages have an <code class="literal">Architecture</code> field in their control information. This field can contain either “<code class="literal">all</code>” (for packages that are architecture independent) or the name of the architecture that it targets (like “amd64”, “armhf”, …). In the latter case, by default, <code class="command">dpkg</code> will only accept to install the package if its architecture matches the host's architecture as returned by <code class="command">dpkg --print-architecture</code>.
  234. </div><div class="para">
  235. This restriction ensures that users do not end up with binaries compiled for an incorrect architecture. Everything would be perfect except that (some) computers can run binaries for multiple architectures, either natively (an “amd64“ system can run “i386” binaries) or through emulators.
  236. </div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a xmlns="" id="id-1.8.8.9.6"></a>5.4.5.1. Enabling Multi-Arch</h4></div></div></div><div class="para">
  237. <code class="command">dpkg</code>'s multi-arch support allows users to define “foreign architectures” that can be installed on the current system. This is simply done with <code class="command">dpkg --add-architecture</code> like in the example below. There is a corresponding <code class="command">dpkg --remove-architecture</code> to drop support of a foreign architecture, but it can only be used when no packages of this architecture remain.
  238. </div><pre class="screen">
  239. <code class="computeroutput"># </code><strong class="userinput"><code>dpkg --print-architecture</code></strong>
  240. <code class="computeroutput">amd64
  241. # </code><strong class="userinput"><code>dpkg --print-foreign-architectures</code></strong>
  242. <code class="computeroutput"># </code><strong class="userinput"><code>dpkg -i gcc-8-base_8.3.0-6_armhf.deb</code></strong>
  243. <code class="computeroutput">dpkg: error processing archive gcc-8-base_8.3.0-6_armhf.deb (--install):
  244. package architecture (armhf) does not match system (amd64)
  245. Errors were encountered while processing:
  246. gcc-8-base_8.3.0-6_armhf.deb
  247. # </code><strong class="userinput"><code>dpkg --add-architecture armhf</code></strong>
  248. <code class="computeroutput"># </code><strong class="userinput"><code>dpkg --add-architecture armel</code></strong>
  249. <code class="computeroutput"># </code><strong class="userinput"><code>dpkg --print-foreign-architectures</code></strong>
  250. <code class="computeroutput">armhf
  251. armel
  252. # </code><strong class="userinput"><code>dpkg -i gcc-8-base_8.3.0-6_armhf.deb</code></strong>
  253. <code class="computeroutput">(Reading database ... 14319 files and directories currently installed.)
  254. Preparing to unpack gcc-8-base_8.3.0-6_armhf.deb ...
  255. Unpacking gcc-8-base:armhf (8.3.0-6) ...
  256. Setting up gcc-8-base:armhf (8.3.0-6) ...
  257. # </code><strong class="userinput"><code>dpkg --remove-architecture armhf</code></strong>
  258. <code class="computeroutput">dpkg: error: cannot remove architecture 'armhf' currently in use by the database
  259. # </code><strong class="userinput"><code>dpkg --remove-architecture armel</code></strong>
  260. <code class="computeroutput"># </code><strong class="userinput"><code>dpkg --print-foreign-architectures</code></strong>
  261. <code class="computeroutput">armhf</code></pre><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong><span class="emphasis"><em>NOTE</em></span> APT's multi-arch support</strong></p></div></div></div><div class="para">
  262. APT will automatically detect when dpkg has been configured to support foreign architectures and will start downloading the corresponding <code class="filename">Packages</code> files during its update process.
  263. </div><div class="para">
  264. Foreign packages can then be installed with <code class="command">apt install <em class="replaceable">package</em>:<em class="replaceable">architecture</em></code>.
  265. </div></div><div class="sidebar"><div class="titlepage"><div><div><p class="title"><strong><span class="emphasis"><em>IN PRACTICE</em></span> Using proprietary i386 binaries on amd64</strong></p></div></div></div><div class="para">
  266. There are multiple use cases for multi-arch, but the most popular ones are the possibility to execute (sometimes proprietary) 32 bit binaries (i386) on 64 bit systems (amd64), and the possibility to cross-compile software for a platform or an architecture different from the host one.
  267. </div></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a xmlns="" id="id-1.8.8.9.7"></a>5.4.5.2. Multi-Arch Related Changes</h4></div></div></div><div class="para">
  268. To make multi-arch actually useful and usable, libraries had to be repackaged and moved to an architecture-specific directory so that multiple copies (targeting different architectures) can be installed alongside. Such updated packages contain the “<code class="literal">Multi-Arch: same</code>” header field to tell the packaging system that the various architectures of the package can be safely co-installed (and that those packages can only satisfy dependencies of packages of the same architecture). The most important libraries have been converted since the introduction of multi-arch in Debian 7 <span class="distribution distribution">Wheezy</span>, but there are many libraries that will likely never be converted unless someone specifically requests it (through a bug report for example).
  269. </div><pre class="screen"><code class="computeroutput">$ </code><strong class="userinput"><code>dpkg -s gcc-8-base
  270. </code></strong><code class="computeroutput">dpkg-query: error: --status needs a valid package name but 'gcc-8-base' is not: ambiguous package name 'gcc-8-base' with more than one installed instance
  271. Use --help for help about querying packages.
  272. $ </code><strong class="userinput"><code>dpkg -s gcc-8-base:amd64 gcc-8-base:armhf | grep ^Multi
  273. </code></strong><code class="computeroutput">Multi-Arch: same
  274. Multi-Arch: same
  275. $ </code><strong class="userinput"><code>dpkg -L libgcc1:amd64 |grep .so
  276. </code></strong><code class="computeroutput">/lib/x86_64-linux-gnu/libgcc_s.so.1
  277. $ </code><strong class="userinput"><code>dpkg -S /usr/share/doc/gcc-8-base/copyright
  278. </code></strong><code class="computeroutput">gcc-8-base:amd64, gcc-8-base:armhf: /usr/share/doc/gcc-8-base/copyright
  279. </code></pre><div class="para">
  280. It is worth noting that <code class="literal">Multi-Arch: same</code> packages must have their names qualified with their architecture to be unambiguously identifiable. They also have the possibility to share files with other instances of the same package; <code class="command">dpkg</code> ensures that all packages have bit-for-bit identical files when they are shared. Last but not least, all instances of a package must have the same version. They must thus be upgraded together.
  281. </div><div class="para">
  282. Multi-Arch support also brings some interesting challenges in the way dependencies are handled. Satisfying a dependency requires either a package marked “<code class="literal">Multi-Arch: foreign</code>” or a package whose architecture matches the one of the package declaring the dependency (in this dependency resolution process, architecture-independent packages are assumed to be of the same architecture than the host). A dependency can also be weakened to allow any architecture to fulfill it, with the <code class="literal"><em class="replaceable">package</em>:any</code> syntax, but foreign packages can only satisfy such a dependency if they are marked “<code class="literal">Multi-Arch: allowed</code>”.
  283. </div></div></div></div><ul class="docnav"><li class="previous"><a accesskey="p" href="sect.source-package-structure.html"><strong>Prev</strong>5.3. Structure of a Source Package</a></li><li class="up"><a accesskey="u" href="#"><strong>Up</strong></a></li><li class="home"><a accesskey="h" href="index.html"><strong>Home</strong></a></li><li class="next"><a accesskey="n" href="sect.coexistence-with-other-packaging-systems.html"><strong>Next</strong>5.5. Coexistence with Other Packaging Systems</a></li></ul></body></html>