man-pages/man1/grep-dctrl.1.html
2021-03-31 01:06:50 +01:00

867 lines
21 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GREP-DCTRL</TITLE>
</HEAD><BODY>
<H1>GREP-DCTRL</H1>
Section: Debian user's manual (1)<BR>Updated: 2013-11-26<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
grep-dctrl, grep-status, grep-available, grep-aptavail, grep-debtags - grep Debian control files
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<I>command</I>
<B>--copying</B>|<B>-C</B> | <B>--help</B>|<B>-h</B> | <B>--version</B>|<B>-V</B>
<P>
<I>command</I> [<I>options</I>] <I>filter</I> [ <I>file</I>... ]
<P>
where
<I>command</I>
is one of
<B>grep-dctrl</B>,
<B>grep-status</B>,
<B>grep-available</B>,
<B>grep-aptavail </B>
and
<B>grep-debtags</B>.
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The
<B>grep-dctrl</B>
program can answer such questions as
<I>What is the Debian package foo?</I>,
<I>Which version of the Debian package bar is now current?</I>,
<I>Which Debian packages does John Doe maintain?</I>,
<I>Which Debian packages are somehow related to the Scheme</I>
<I>programming language?</I>,
and with some help,
<I>Who maintain the essential packages of a Debian system?</I>,
given a useful input file.
<P>
The programs
<B>grep-available</B>,
<B>grep-status</B>,
<B>grep-aptavail</B>
and
<B>grep-debtags</B>
are aliases of (actually, symbolic links to)
<B>grep-dctrl</B>.
These aliases use as their default input
the
<B><A HREF="/cgi-bin/man/man2html?1+dpkg">dpkg</A></B>(1)
<I>available</I>
and
<I>status</I>
files, the
<B>apt-cache dumpavail</B>
output and the
<B>debtags dumpavail</B>
output, respectively.
<P>
<B>grep-dctrl</B>
is a specialised
<B>grep</B>
program that is meant for processing any file
which has the general format of a Debian package
<I>control</I>
file, as
described in the Debian Policy. These include the
<B>dpkg</B>
<I>available</I>
file, the
<B>dpkg</B>
<I>status</I>
file, and the
<I>Packages</I>
files on a
distribution medium (such as a Debian CD-ROM or an FTP site carrying
Debian).
<P>
You must give a
<I>filter</I>
expression on the command line. The
<I>filter</I>
defines which kind of paragraphs (aka package records) are output. A
simple
<I>filter</I>
is a search pattern along with any options that modify
it. Possible modifiers are
<B>--eregex</B>, <B>--field</B>, <B>--ignore-case</B>, <B>--regex</B>
and
<B>--exact-match</B>,
along with their single-letter equivalents. By
default, the search is a case-sensitive fixed substring match on each
paragraph (in other words, package record) in the input. With
suitable modifiers, this can be changed: the search can be
case-insensitive and the pattern can be seen as an extended POSIX
regular expression.
<P>
<I>Filter</I>s
can be combined to form more complex
<I>filter</I>s
using the connectives
<B>--and</B>, <B>--or</B> and <B>--not</B>.
Parentheses (which usually
need to be escaped for the shell) can be used for grouping.
<P>
By default, the full matching paragraphs are printed on the standard
output; specific fields can be selected for output with the
<B>-s</B>
option.
<P>
After the
<I>filter</I>
expression comes zero or more
<I>file</I>
names. The
<I>file</I>
name
<B>-</B>
is taken to mean the standard input stream. The
<I>file</I>s
are searched in order but separately; they are
<B>not</B>
concatenated together. In other words, the end of a
<I>file</I>
always implies the end of the current paragraph.
<P>
If no
<I>file</I>
names are specified, the program name is used to identify a default
input file. The program names are matched with the base form of the
name of the current program (the 0'th command line argument, if you
will).
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
<A NAME="lbAF">&nbsp;</A>
<H3>Specifying the search pattern</H3>
<DL COMPACT>
<DT id="1"><B>--pattern=</B><I>pattern<DD>
Specify a
pattern</I>
to be searched. This switch is not generally needed, as the
<I>pattern</I>
can be given by itself. However,
<I>pattern</I>s
that start
with a dash
(<B>-</B>)
must be given using this switch, so that they wouldn't
be mistaken for switches.
</DL>
<A NAME="lbAG">&nbsp;</A>
<H3>Modifiers of simple filters</H3>
<DL COMPACT>
<DT id="2"><B>-F </B><I>field</I>,<I>field</I>, ... | <B>--field=</B><I>field</I>,<I>field</I>, ...<DD>
Restrict pattern matching to the
<I>field</I>s
given. Multiple
<I>field</I>
names in one
<B>-F</B>
option and multiple
<B>-F</B>
options in one simple
<I>filter </I>
are
allowed. The search named by the filter will be performed
among all the
<I>field</I>s
named, and as soon as any one of them matches, the
whole simple
<I>filter</I>
is considered matching.
<DT id="3"><DD>
A
<I>field</I>
specification can contain a colon
(<B>:</B>).
In such a case, the part
up to the colon is taken as the name of the field to be searched in,
and the part after the colon is taken as the name of the field whose
content is to be used if the field to search in is empty.
<DT id="4"><B>-P<DD>
Shorthand for
-FPackage</B>.
<DT id="5"><B>-S<DD>
Shorthand for
-FSource:Package</B>.
<DT id="6"><B>-e</B>, <B>--eregex<DD>
Regard the pattern of the current simple filter as an extended
POSIX regular expression
<DT id="7">-r</B>, <B>--regex<DD>
Regard the pattern of the current simple filter as a standard POSIX regular expression.
<DT id="8">-i</B>, <B>--ignore-case<DD>
Ignore case when looking for a match in the current simple filter.
<DT id="9">-X</B>, <B>--exact-match<DD>
Do an exact match (as opposed to a substring match) in the current
simple filter.
<DT id="10">-w</B>, <B>--whole-pkg<DD>
Do an extended regular expression match on whole package names,
assuming the syntax of inter-package relationship fields such as
Depends</B>,<B>Recommends</B>, ...
When this flag is given you should not worry
about sub-package names such as &quot;libpcre3&quot; also matching
&quot;libpcre3-dev&quot;. This flag implies (and is incompatible with)
<B>-e</B>.
<DT id="11"><B>--eq<DD>
Do an equality comparison under the Debian version number system. If
the pattern or the field to be searched in is not a valid Debian
version number, the paragraph is regarded as not matching. As a
special case, this is capable of comparing simple nonnegative integers
for equality.
<DT id="12">--lt<DD>
Do an strictly-less-than comparison under the Debian version number
system. If the pattern or the field to be searched in is not a valid
Debian version number, the paragraph is regarded as not matching. As
a special case, this is capable of comparing simple nonnegative
integers.
<DT id="13">--le<DD>
Do an less-than-or-equal comparison under the Debian version number
system. If the pattern or the field to be searched in is not a valid
Debian version number, the paragraph is regarded as not matching. As
a special case, this is capable of comparing simple nonnegative
integers.
<DT id="14">--gt<DD>
Do an strictly-greater-than comparison under the Debian version number
system. If the pattern or the field to be searched in is not a valid
Debian version number, the paragraph is regarded as not matching. As
a special case, this is capable of comparing simple nonnegative
integers.
<DT id="15">--ge<DD>
Do an greater-than-or-equal comparison under the Debian version number
system. If the pattern or the field to be searched in is not a valid
Debian version number, the paragraph is regarded as not matching. As
a special case, this is capable of comparing simple nonnegative
integers.
</DL>
</B><A NAME="lbAH">&nbsp;</A>
<H3>Combining filters</H3>
<DL COMPACT>
<DT id="16"><B>-!</B>, <B>--not</B>, <B>!<DD>
Match if the following filter does
not</B>
match.
<DT id="17"><B>-o</B>, <B>--or<DD>
Match if either one or both of the preceding and following filters
matches.
<DT id="18">-a</B>, <B>--and<DD>
Match if both the preceding and the following filter match.
<DT id="19">(</B> ... <B>)<DD>
Parentheses can be used for grouping. Note that they need to be
escaped for most shells. Filter modifiers can be given before the
opening parentheses; they will be treated as if they had been repeated
for each simple filter inside the parentheses.
</DL>
</B><A NAME="lbAI">&nbsp;</A>
<H3>Output format modifiers</H3>
<DL COMPACT>
<DT id="20"><B>-l</B>, <B>--files-with-matches<DD>
Output only the file names, each on its own line, of those files that contain
at least one matching paragraph. This is incompatible with the
-v</B> and <B>-L</B>
options, and all other output format modifiers will be ignored.
<DT id="21"><B>-L</B>, <B>--files-without-matches<DD>
Output only the file names, each on its own line, of those files that do not
contain any matching paragraphs. This is incompatible with the
-v</B> and <B>-l</B>
options, and all other output format modifiers will be ignored.
<DT id="22"><B>-s </B><I>field</I>,<I>field</I>, ... | <B>--show-field=</B><I>field</I>,<I>field</I>, ...<DD>
Show only the body of these
<I>field</I>s
from the matching paragraphs. The
<I>field</I>
names must not include any colons or commas. Commas are used to
delimit
<I>field</I>
names in the argument to this option. The
<I>field</I>s
are shown in the order given here. See also the option
<B>-I</B>.
Note that in the absence of the
<B>--ensure--dctrl</B>
option, if only one field is selected, no paragraph separator is output.
<DT id="23"><B>-I</B>, <B>--invert-show<DD>
Invert the meaning of option
-s</B>:
show only the fields that have
<B>not</B>
been named using a
<B>-s</B>
option. As an artefact of the implementation,
the order of the fields in the original paragraph is not preserved.
</DL>
<P>
A
<I>field</I>
specification can contain a colon. In such a case, the part
up to the colon is taken as the name of the field to be shown, and the
part after the colon is taken as the name of the field whose content
is to be used if the field to be shown is empty.
<DL COMPACT>
<DT id="24"><B>-d<DD>
Show only the first line of the
Description</B>
field from the matching
paragraphs. If no
<B>-s</B>
option is specified, this option also effects
<B>-s Description;</B>
if there is a
<B>-s</B>
option but it does not include
the
<B>Description</B>
field name, one is appended to the option. Thus the
<B>Description</B>
field's location in the output is determined by the
<B>-s</B>
option, if any, the last field being the default.
<DT id="25"><B>-n</B>, <B>--no-field-names<DD>
Suppress field names when showing specified fields, only their bodies
are shown. Each field is printed in its original form without the
field name, the colon after it and any whitespace preceding the start
of the body.
<DT id="26">-v</B>, <B>--invert-match<DD>
Instead of showing all the paragraphs that match, show those paragraphs
that do
not</B>
match.
<DT id="27"><B>-c</B>, <B>--count<DD>
Instead of showing the paragraphs that match (or, with
-v</B>,
that don't
match), show the count of those paragraphs.
<DT id="28"><B>-q</B>, <B>--quiet</B>, <B>--silent<DD>
Output nothing to the standard output stream. Instead, exit
immediately after finding the first match.
</DL>
</B><A NAME="lbAJ">&nbsp;</A>
<H3>Miscellaneous</H3>
<DL COMPACT>
<DT id="29"><B>--ensure-dctrl<DD>
Ensure that the output is in dctrl format, specifically that there always
is an empty line separating paragraphs. This option is not honored if
the
-n</B>
option has been selected, as that option deliberately requests a non-dctrl
format for the output. In a future version, this option may be made the
default behaviour.
<DT id="30"><B>--compat<DD>
Override any
--ensure-dctrl</B>
option given earlier on the command line.
<DT id="31"><B>--ignore-parse-errors<DD>
Ignore errors in parsing input. A paragraph which cannot be parsed
is ignored in its entirety, and the next paragraph is assumed to start
after the first newline since the location of the error.
<DT id="32">--debug-optparse<DD>
Show how the current command line has been parsed.
<DT id="33">--errorlevel=</B><I>level<DD>
Set log level to
level</I>.
<I>level</I>
is one of
<B>fatal</B>, <B>important</B>, <B>informational</B> and <B>debug</B>,
but the last may not be available,
depending on the compile-time options. These categories are given
here in order; every message that is emitted when
<B>fatal</B>
is in effect, will be emitted in the
<B>important</B>
error level, and so on. The default is
<B>important</B>.
<DT id="34"><B>-V</B>, <B>--version<DD>
Print out version information.
<DT id="35">-C</B>, <B>--copying<DD>
Print out the copyright license. This produces much output; be sure
to redirect or pipe it somewhere (such as your favourite pager).
<DT id="36">-h</B>, <B>--help<DD>
Print out a help summary.
</DL>
</B><A NAME="lbAK">&nbsp;</A>
<H2>EXAMPLES</H2>
The almost simplest use of this program is to print out the status or
available record of a package. In this respect,
<B>grep-dctrl</B>
is like
<B>dpkg -s</B>
or
<B>dpkg --print-avail.</B>
To print out the status record of the package &quot;mixal&quot;, do
<PRE>
% grep-status -PX mixal
</PRE>
and to get its available record, use
<PRE>
% grep-available -PX mixal
</PRE>
In fact, you can ask for the record of the &quot;mixal&quot; package
from any Debian control file. Say, you have the Debian 6.0
CD-ROM's
<I>Packages</I>
file in the current directory; now you
can do a
<PRE>
% grep-dctrl -PX mixal Packages
</PRE>
<P>
But
<B>grep-dctrl</B>
can do more than just emulate
<B>dpkg</B>.
It can more-or-less emulate
<B>apt-cache</B>!
That program has a search feature that searches package descriptions.
But we can do that too:
<PRE>
% grep-available -F Description foo
</PRE>
searches for the string &quot;foo&quot; case-sensitively in the descriptions of
all available packages. If you want case-insensitivity, use
<PRE>
% grep-available -F Description -i foo
</PRE>
Truth to be told,
<B>apt-cache</B>
searches package names, too. We can separately search in the names;
to do so, do
<PRE>
% grep-available -F Package foo
</PRE>
or
<PRE>
% grep-available -P foo
</PRE>
which is pretty much the same thing. We can also search in both
descriptions and names; if match is found in either, the package
record is printed:
<PRE>
% grep-available -P -F Description foo
</PRE>
or
<PRE>
% grep-available -F Package -F Description foo
</PRE>
This kind of search is the exactly same that
<B>apt-cache</B>
does.
<P>
Here's one thing neither
<B>dpkg</B>
nor
<B>apt-cache</B>
do. Search for a string in the whole
<I>status</I>
or
<I>available</I>
file (or
any Debian control file, for that matter) and print out all package
records where we have a match. Try
<PRE>
% grep-available dpkg
</PRE>
sometime and watch how thoroughly
<B>dpkg</B>
has infiltrated Debian.
<P>
All the above queries were based on simple substring searches.
But
<B>grep-dctrl</B>
can handle regular expressions in the search pattern. For example,
to see the status records of all packages with either &quot;apt&quot; or
&quot;dpkg&quot; in their names, use
<PRE>
% grep-status -P -e 'apt|dpkg'
</PRE>
<P>
Now that we have seen all these fine and dandy queries, you might
begin to wonder whether it is necessary to always see the whole
paragraph. You may be, for example, interest only in the dependency
information of the packages involved. Fine. To show the depends
lines of all packages maintained by me, do a
<PRE>
% grep-available -F Maintainer -s Depends '<A HREF="mailto:ajk@debian.org">ajk@debian.org</A>'
</PRE>
If you want to see the packages' names, too, use
<PRE>
% grep-available -F Maintainer -s Package,Depends \
'<A HREF="mailto:ajk@debian.org">ajk@debian.org</A>'
</PRE>
Note that there must be no spaces in the argument to the
<B>-s</B>
switch.
<P>
More complex queries are also possible. For example, to see the list of packages
maintained by me and depending on libc6, do
<PRE>
% grep-available -F Maintainer '<A HREF="mailto:ajk@debian.org">ajk@debian.org</A>' \
-a -F Depends libc6 -s Package,Depends
</PRE>
Remember that you can use other UNIX filters to help you, too. Ever
wondered, who's the most active Debian developer based on the number
of source packages being maintained? Easy. You just need to have a
copy of the most recent
<I>Sources</I>
file from any Debian mirror.
<PRE>
% grep-dctrl -n -s Maintainer '' Sources | sort | \
uniq -c | sort -nr
</PRE>
This example shows a neat trick: if you want to selectively
show only some field of
<I>all</I>
packages, just supply an empty pattern.
<P>
The term &quot;bogopackage&quot; means the count of the packages that a Debian
developer maintains. To get the bogopackage count for the maintainer
of
<B>dctrl-tools</B>,
say
<PRE>
% grep-available -c -FMaintainer \
&quot;`grep-available -sMaintainer -n -PX dctrl-tools`&quot;
</PRE>
<P>
Sometimes it is useful to output the data of several fields on the
same line. For example, the following command outputs the list of
installed packages, sorted by their
<B>Installed-Size</B>.
<PRE>
% grep-status -FStatus -sInstalled-Size,Package -n \
&quot;install ok installed&quot; -a -FInstalled-Size --gt 0 \
| paste -sd &quot; \n&quot; | sort -n
</PRE>
Note that there should be exactly 2 spaces in the &quot; \n&quot; string.
<P>
Another usual use-case is looking for packages that have another one as
build dependency:
<PRE>
% grep-dctrl -s Package -F Build-Depends,Build-Depends-Indep \
quilt /var/lib/apt/lists/*Sources
</PRE>
<P>
These examples cover a lot of typical uses of this utility, but not
all possible uses. Use your imagination! The building blocks are
there, and if something's missing, let me know.
<A NAME="lbAL">&nbsp;</A>
<H2>DIAGNOSTICS</H2>
In the absence of errors, the exit code
<B>0</B>
is used if at least one
match was found, and the exit code
<B>1</B>
is used if no matches were found.
If there were errors, the exit code is
<B>2</B>,
with one exception. If the
<B>-q</B>, <B>--quiet</B> or <B>--silent</B>
options are used, the exit code
<B>0</B>
is used when
a match is found regardless of whether there have been non-fatal
errors.
<P>
These messages are emitted in log levels
<B>fatal</B> and <B>important</B>.
Additional messages may be provided by the system libraries.
<B>This list is incomplete.</B>
<DL COMPACT>
<DT id="37"><B>A pattern is mandatory<DD>
You must specify a pattern to be searched for.
<DT id="38">malformed filter<DD>
No filter was specified, but one is required.
<DT id="39">cannot find enough memory<DD>
More memory was needed than was available. This error may be
transient, that is, if you try again, all may go well.
<DT id="40">cannot suppress field names when showing whole paragraphs<DD>
When you do not use the
-s</B>
switch,
<B>grep-dctrl</B>
just passes the matching paragraphs through, not touching them any
way. This means, for example, that you can only use
<B>-n</B>
when you use
<B>-s</B>.
<DT id="41"><B>inconsistent modifiers of simple filters<DD>
Conflicting modifiers of simple filters were used; for example, perhaps both
-X</B>
and
<B>-e</B>
were specified for the same simple filter.
<DT id="42"><B>missing ')' in command line<DD>
There were more opening than closing parentheses in the given
filter.
<DT id="43">no such log level<DD>
The argument to
--errorlevel</B>
was invalid.
<DT id="44"><B>too many file names<DD>
The number of file names specified in the command line exceeded a
compile-time limit.
<DT id="45">too many output fields<DD>
The argument to
-s</B>
had too many field names in it. This number is
limited to 256.
<DT id="46"><B>unexpected ')' in command line<DD>
There was no opening parenthesis that would match some closing
parenthesis in the command line.
</DL>
</B><A NAME="lbAM">&nbsp;</A>
<H2>FILES</H2>
<DL COMPACT>
<DT id="47"><I>/var/lib/dpkg/available<DD>
The default input file of
</I><B>grep-available</B>.
<DT id="48"><I>/var/lib/dpkg/status<DD>
The default input file of
</I><B>grep-status</B>.
</DL>
<A NAME="lbAN">&nbsp;</A>
<H2>AUTHOR</H2>
The program and this manual page were written by Antti-Juhani
Kaijanaho
&lt;<I><A HREF="mailto:gaia@iki.fi">gaia@iki.fi</A></I>&gt;.
Bill Allombert
&lt;<I><A HREF="mailto:ballombe@debian.org">ballombe@debian.org</A></I>&gt;
provided one of the examples in the manual page.
<A NAME="lbAO">&nbsp;</A>
<H2>SEE ALSO</H2>
Debian Policy Manual. Published as the Debian
package
<B>debian-policy</B>.
Also available in the Debian website.
<P>
<B><A HREF="/cgi-bin/man/man2html?1+apt-cache">apt-cache</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?1+ara">ara</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?1+dpkg-awk">dpkg-awk</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?1+sgrep">sgrep</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?8+dpkg">dpkg</A></B>(8)
<P>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="49"><A HREF="#lbAB">NAME</A><DD>
<DT id="50"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="51"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="52"><A HREF="#lbAE">OPTIONS</A><DD>
<DL>
<DT id="53"><A HREF="#lbAF">Specifying the search pattern</A><DD>
<DT id="54"><A HREF="#lbAG">Modifiers of simple filters</A><DD>
<DT id="55"><A HREF="#lbAH">Combining filters</A><DD>
<DT id="56"><A HREF="#lbAI">Output format modifiers</A><DD>
<DT id="57"><A HREF="#lbAJ">Miscellaneous</A><DD>
</DL>
<DT id="58"><A HREF="#lbAK">EXAMPLES</A><DD>
<DT id="59"><A HREF="#lbAL">DIAGNOSTICS</A><DD>
<DT id="60"><A HREF="#lbAM">FILES</A><DD>
<DT id="61"><A HREF="#lbAN">AUTHOR</A><DD>
<DT id="62"><A HREF="#lbAO">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:15 GMT, March 31, 2021
</BODY>
</HTML>