You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

221 lines
11 KiB

  1. <?xml version="1.0" encoding="utf-8" standalone="no"?>
  2. <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % aptent SYSTEM "apt.ent"> %aptent;
  5. <!ENTITY % aptverbatiment SYSTEM "apt-verbatim.ent"> %aptverbatiment;
  6. <!ENTITY % aptvendor SYSTEM "apt-vendor.ent"> %aptvendor;
  7. ]>
  8. <refentry>
  9. <refentryinfo>
  10. &apt-author.jgunthorpe;
  11. &apt-author.team;
  12. &apt-email;
  13. &apt-product;
  14. <!-- The last update date -->
  15. <date>2020-02-04T00:00:00Z</date>
  16. </refentryinfo>
  17. <refmeta>
  18. <refentrytitle>apt-patterns</refentrytitle>
  19. <manvolnum>7</manvolnum>
  20. <refmiscinfo class="manual">APT</refmiscinfo>
  21. </refmeta>
  22. <!-- Man page title -->
  23. <refnamediv>
  24. <refname>apt-patterns</refname>
  25. <refpurpose>Syntax and semantics of apt search patterns</refpurpose>
  26. </refnamediv>
  27. <refsect1><title>Description</title>
  28. <para>
  29. Starting with version 2.0, <command>APT</command> provides support for
  30. patterns, which can be used to query the apt cache for packages.
  31. </para>
  32. </refsect1>
  33. <refsect1>
  34. <title>Logic patterns</title>
  35. <para>
  36. These patterns provide the basic means to combine other patterns into
  37. more complex expressions, as well as <code>?true</code> and <code>?false</code>
  38. patterns.
  39. </para>
  40. <variablelist>
  41. <varlistentry><term><code>?and(PATTERN, PATTERN, ...)</code></term><term><code>PATTERN PATTERN ...</code></term>
  42. <listitem><para>Selects objects where all specified patterns match.</para></listitem>
  43. </varlistentry>
  44. <varlistentry><term><code>?false</code></term><term><code>~F</code></term>
  45. <listitem><para>Selects nothing.</para></listitem>
  46. </varlistentry>
  47. <varlistentry><term><code>?not(PATTERN)</code></term><term><code>!PATTERN</code></term>
  48. <listitem><para>Selects objects where PATTERN does not match.</para></listitem>
  49. </varlistentry>
  50. <varlistentry><term><code>?or(PATTERN, PATTERN, ...)</code></term><term><code>PATTERN | PATTERN | ...</code></term>
  51. <listitem><para>Selects objects where at least one of the specified patterns match.</para></listitem>
  52. </varlistentry>
  53. <varlistentry><term><code>?true</code></term><term><code>~T</code></term>
  54. <listitem><para>Selects all objects.</para></listitem>
  55. </varlistentry>
  56. <varlistentry><term><code>(PATTERN)</code></term>
  57. <listitem><para>Selects the same as <code>PATTERN</code>, can be used to work around precedence, for example, <code>(~ramd64|~ri386)~nfoo</code></para></listitem>
  58. </varlistentry>
  59. </variablelist>
  60. </refsect1>
  61. <refsect1>
  62. <title>Narrowing patterns</title>
  63. <para>
  64. </para>
  65. <variablelist>
  66. <varlistentry><term><code>?all-versions(PATTERN)</code></term>
  67. <listitem><para>Selects packages where all versions match PATTERN. When matching versions instead, same as PATTERN.</para></listitem>
  68. </varlistentry>
  69. <varlistentry><term><code>?any-version(PATTERN)</code></term>
  70. <listitem><para>Selects any version where the pattern matches on the version.</para>
  71. <para>For example, while <code>?and(?version(1),?version(2))</code> matches a package which has one version containing 1 and one version containing 2, <code>?any-version(?and(?version(1),?version(2)))</code> restricts the <code>?and</code> to act on the same version.</para></listitem>
  72. </varlistentry>
  73. <varlistentry><term><code>?narrow(PATTERN...)</code></term>
  74. <listitem><para>Selects any version matching all PATTERNs, short for <code>?any-version(?and(PATTERN...))</code>.</para></listitem>
  75. </varlistentry>
  76. </variablelist>
  77. </refsect1>
  78. <refsect1>
  79. <title>Package patterns</title>
  80. <para>
  81. These patterns select specific packages.
  82. </para>
  83. <variablelist>
  84. <varlistentry><term><code>?architecture(WILDCARD)</code></term><term><code>~rWILDCARD</code></term>
  85. <listitem><para>Selects packages matching the specified architecture, which may contain wildcards using any.</para></listitem>
  86. </varlistentry>
  87. <varlistentry><term><code>?automatic</code></term><term><code>~M</code></term>
  88. <listitem><para>Selects packages that were installed automatically.</para></listitem>
  89. </varlistentry>
  90. <varlistentry><term><code>?broken</code></term><term><code>~b</code></term>
  91. <listitem><para>Selects packages that have broken dependencies.</para></listitem>
  92. </varlistentry>
  93. <varlistentry><term><code>?config-files</code></term><term><code>~c</code></term>
  94. <listitem><para>Selects packages that are not fully installed, but have solely residual configuration files left.</para></listitem>
  95. </varlistentry>
  96. <varlistentry><term><code>?essential</code></term><term><code>~E</code></term>
  97. <listitem><para>Selects packages that have Essential: yes set in their control file.</para></listitem>
  98. </varlistentry>
  99. <varlistentry><term><code>?exact-name(NAME)</code></term>
  100. <listitem><para>Selects packages with the exact specified name.</para></listitem>
  101. </varlistentry>
  102. <varlistentry><term><code>?garbage</code></term><term><code>~g</code></term>
  103. <listitem><para>Selects packages that can be removed automatically.</para></listitem>
  104. </varlistentry>
  105. <varlistentry><term><code>?installed</code></term><term><code>~i</code></term>
  106. <listitem><para>Selects packages that are currently installed.</para></listitem>
  107. </varlistentry>
  108. <varlistentry><term><code>?name(REGEX)</code></term><term><code>~nREGEX</code></term>
  109. <listitem><para>Selects packages where the name matches the given regular expression.</para></listitem>
  110. </varlistentry>
  111. <varlistentry><term><code>?obsolete</code></term><term><code>~o</code></term>
  112. <listitem><para>Selects packages that no longer exist in repositories.</para></listitem>
  113. </varlistentry>
  114. <varlistentry><term><code>?upgradable</code></term><term><code>~U</code></term>
  115. <listitem><para>Selects packages that can be upgraded (have a newer candidate).</para></listitem>
  116. </varlistentry>
  117. <varlistentry><term><code>?virtual</code></term><term><code>~v</code></term>
  118. <listitem><para>Selects all virtual packages; that is packages without a version.
  119. These exist when they are referenced somewhere in the archive,
  120. for example because something depends on that name.</para></listitem>
  121. </varlistentry>
  122. </variablelist>
  123. </refsect1>
  124. <refsect1>
  125. <title>Version patterns</title>
  126. <para>
  127. These patterns select specific versions of a package.
  128. </para>
  129. <variablelist>
  130. <varlistentry><term><code>?archive(REGEX)</code></term><term><code>~AREGEX</code></term>
  131. <listitem><para>Selects versions that come from the archive that matches the specified regular expression. Archive, here, means the values after <code>a=</code> in <command>apt-cache policy</command>.</para></listitem>
  132. </varlistentry>
  133. <varlistentry><term><code>?origin(REGEX)</code></term><term><code>~OREGEX</code></term>
  134. <listitem><para>Selects versions that come from the origin that matches the specified regular expression. Origin, here, means the values after <code>o=</code> in <command>apt-cache policy</command>.</para></listitem>
  135. </varlistentry>
  136. <varlistentry><term><code>?section(REGEX)</code></term><term><code>~sREGEX</code></term>
  137. <listitem><para>Selects versions where the section matches the specified regular expression.</para></listitem>
  138. </varlistentry>
  139. <varlistentry><term><code>?source-package(REGEX)</code></term><term><code>~eREGEX</code></term>
  140. <listitem><para>Selects versions where the source package name matches the specified regular expression.</para></listitem>
  141. </varlistentry>
  142. <varlistentry><term><code>?source-version(REGEX)</code></term>
  143. <listitem><para>Selects versions where the source package version matches the specified regular expression.</para></listitem>
  144. </varlistentry>
  145. <varlistentry><term><code>?version(REGEX)</code></term><term><code>~VREGEX</code></term>
  146. <listitem><para>Selects versions where the version string matches the specified regular expression.</para></listitem>
  147. </varlistentry>
  148. </variablelist>
  149. </refsect1>
  150. <refsect1><title>Examples</title>
  151. <variablelist>
  152. <varlistentry><term><code>apt remove ?garbage</code></term>
  153. <listitem><para>Remove all packages that are automatically installed and no longer needed - same as apt autoremove</para></listitem>
  154. </varlistentry>
  155. <varlistentry><term><code>apt purge ?config-files</code></term>
  156. <listitem><para>Purge all packages that only have configuration files left</para></listitem>
  157. </varlistentry>
  158. <varlistentry><term><code>apt list '~i !~M (~slibs|~sperl|~spython)'</code></term>
  159. <listitem><para>List all manually-installed packages in sections matching libs, perl, or python.</para></listitem>
  160. </varlistentry>
  161. </variablelist>
  162. </refsect1>
  163. <refsect1><title>Migrating from aptitude</title>
  164. <para>
  165. Patterns in apt are heavily inspired by patterns in aptitude, but with some tweaks:
  166. </para>
  167. <itemizedlist>
  168. <listitem>
  169. <para>
  170. Syntax is uniform: If there is an opening parenthesis after a term, it is always assumed to be the beginning of an argument list.
  171. </para>
  172. <para>
  173. In aptitude, a syntactic form <code>"?foo(bar)"</code> could mean <code>"?and(?foo,bar)"</code> if foo does not take an argument. In APT, this will cause an error.
  174. </para>
  175. </listitem>
  176. <listitem>
  177. <para>Not all patterns are supported.</para>
  178. </listitem>
  179. <listitem>
  180. <para>Some additional patterns are available, for example, for finding gstreamer codecs.</para>
  181. </listitem>
  182. <listitem>
  183. <para>Escaping terms with <code>~</code> is not supported.</para>
  184. </listitem>
  185. <listitem>
  186. <para>A trailing comma is allowed in argument lists</para>
  187. </listitem>
  188. <listitem>
  189. <para>?narrow accepts infinite arguments</para>
  190. </listitem>
  191. <listitem>
  192. <para><code>foo</code> cannot be used as a shortform for <code>?name(foo)</code>, as this can cause typos to go unnoticed:
  193. Consider <code>?and(...,~poptional)</code>:
  194. this requires the package to have <code>required</code> priority, but
  195. if you do not type the <code>~</code>, it would require the package name to contain <code>poptional</code>.</para>
  196. </listitem>
  197. <listitem>
  198. <para>Grouping patterns with <code>(...)</code> or writing <code>?or(A,B)</code> as <code>A|B</code> are not supported. We
  199. do not believe that the use of <code>|</code> is that common, and the grouping is not necessary without it.</para>
  200. </listitem>
  201. </itemizedlist>
  202. </refsect1>
  203. <refsect1><title>See Also</title>
  204. <para>
  205. &apt-get;, &apt;
  206. </para>
  207. </refsect1>
  208. &manbugs;
  209. &manauthor;
  210. </refentry>