Debian Codegraph @

man/grep-dctrl.1.cp

raw
1 .TH GREP-DCTRL 1 2013-11-26 "Debian Project" "Debian user's manual"
2 \" Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2011,
3 \" 2012, 2013
4 \" Antti-Juhani Kaijanaho <[email protected]>
5 \" This program is free software; you can redistribute it and/or modify
6 \" it under the terms of the GNU General Public License as published by
7 \" the Free Software Foundation; either version 2 of the License, or
8 \" (at your option) any later version.
9 \"
10 \" This program is distributed in the hope that it will be useful,
11 \" but WITHOUT ANY WARRANTY; without even the implied warranty of
12 \" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 \" GNU General Public License for more details.
14 \"
15 \" You should have received a copy of the GNU General Public License
16 \" along with this program; see the file COPYING. If not, write to
17 \" the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 \" Boston, MA 02111-1307, USA.
19 .SH NAME
20 grep\-dctrl, grep\-status, grep\-available, grep\-aptavail, grep\-debtags \- grep Debian control files
21 .SH SYNOPSIS
22 .I command
23 .BR --copying "|" -C " | " --help "|" -h " | " --version "|" -V
24 .sp
25 .IR command " [" options "] " filter " [ " file "... ]"
26 .sp
27 where
28 .I command
29 is one of
30 .BR grep\-dctrl ,
31 .BR grep\-status ,
32 .BR grep\-available ,
33 .B grep\-aptavail
34 and
35 .BR grep\-debtags .
36 .SH DESCRIPTION
37 The
38 .B grep\-dctrl
39 program can answer such questions as
40 .IR "What is the Debian package foo?" ,
41 .IR "Which version of the Debian package bar is now current?" ,
42 .IR "Which Debian packages does John Doe maintain?" ,
43 .I "Which Debian packages are somehow related to the Scheme"
44 .IR "programming language?" ,
45 and with some help,
46 .IR "Who maintain the essential packages of a Debian system?" ,
47 given a useful input file.
48 .PP
49 The programs
50 .BR grep\-available ,
51 .BR grep\-status ,
52 .B grep\-aptavail
53 and
54 .B grep\-debtags
55 are aliases of (actually, symbolic links to)
56 .BR grep\-dctrl .
57 These aliases use as their default input
58 the
59 .BR dpkg (1)
60 .I available
61 and
62 .I status
63 files, the
64 .B apt\-cache dumpavail
65 output and the
66 .B debtags dumpavail
67 output, respectively.
68 .PP
69 .B grep\-dctrl
70 is a specialised
71 .B grep
72 program that is meant for processing any file
73 which has the general format of a Debian package
74 .I control
75 file, as
76 described in the Debian Policy. These include the
77 .B dpkg
78 .I available
79 file, the
80 .B dpkg
81 .I status
82 file, and the
83 .I Packages
84 files on a
85 distribution medium (such as a Debian CD-ROM or an FTP site carrying
86 Debian).
87 .PP
88 You must give a
89 .I filter
90 expression on the command line. The
91 .I filter
92 defines which kind of paragraphs (aka package records) are output. A
93 simple
94 .I filter
95 is a search pattern along with any options that modify
96 it. Possible modifiers are
97 .BR \-\-eregex ", " \-\-field ", " \-\-ignore\-case ", " \-\-regex
98 and
99 .BR \-\-exact\-match ,
100 along with their single-letter equivalents. By
101 default, the search is a case-sensitive fixed substring match on each
102 paragraph (in other words, package record) in the input. With
103 suitable modifiers, this can be changed: the search can be
104 case-insensitive and the pattern can be seen as an extended POSIX
105 regular expression.
106 .PP
107 .IR Filter s
108 can be combined to form more complex
109 .IR filter s
110 using the connectives
111 .BR \-\-and ", " \-\-or " and " \-\-not .
112 Parentheses (which usually
113 need to be escaped for the shell) can be used for grouping.
114 .PP
115 By default, the full matching paragraphs are printed on the standard
116 output; specific fields can be selected for output with the
117 .B \-s
118 option.
119 .PP
120 After the
121 .I filter
122 expression comes zero or more
123 .I file
124 names. The
125 .I file
126 name
127 .B \-
128 is taken to mean the standard input stream. The
129 .IR file s
130 are searched in order but separately; they are
131 .B not
132 concatenated together. In other words, the end of a
133 .I file
134 always implies the end of the current paragraph.
135 .PP
136 If no
137 .I file
138 names are specified, the program name is used to identify a default
139 input file. The program names are matched with the base form of the
140 name of the current program (the 0'th command line argument, if you
141 will).
142 .SH OPTIONS
143 .SS Specifying the search pattern
144 .IP "\fB\-\-pattern=\fIpattern"
145 Specify a
146 .I pattern
147 to be searched. This switch is not generally needed, as the
148 .I pattern
149 can be given by itself. However,
150 .IR pattern s
151 that start
152 with a dash
153 .RB ( - )
154 must be given using this switch, so that they wouldn't
155 be mistaken for switches.
156 .SS Modifiers of simple filters
157 .IP "\fB\-F \fIfield\fR,\fIfield\fR, ... | \fB\-\-field=\fIfield\fR,\fIfield\fR, ..."
158 Restrict pattern matching to the
159 .IR field s
160 given. Multiple
161 .I field
162 names in one
163 .B -F
164 option and multiple
165 .B -F
166 options in one simple
167 .I filter
168 are
169 allowed. The search named by the filter will be performed
170 among all the
171 .IR field s
172 named, and as soon as any one of them matches, the
173 whole simple
174 .I filter
175 is considered matching.
176 .IP
177 A
178 .I field
179 specification can contain a colon
180 .RB ( : ).
181 In such a case, the part
182 up to the colon is taken as the name of the field to be searched in,
183 and the part after the colon is taken as the name of the field whose
184 content is to be used if the field to search in is empty.
185 .IP \fB\-P
186 Shorthand for
187 .BR \-FPackage .
188 .IP \fB\-S
189 Shorthand for
190 .BR \-FSource:Package .
191 .IP "\fB\-e\fR, \fB\-\-eregex"
192 Regard the pattern of the current simple filter as an extended
193 POSIX regular expression
194 .IP "\fB\-r\fR, \fB\-\-regex"
195 Regard the pattern of the current simple filter as a standard POSIX regular expression.
196 .IP "\fB\-i\fR, \fB\-\-ignore\-case"
197 Ignore case when looking for a match in the current simple filter.
198 .IP "\fB\-X\fR, \fB\-\-exact\-match"
199 Do an exact match (as opposed to a substring match) in the current
200 simple filter.
201 .IP "\fB\-w\fR, \fB\-\-whole\-pkg"
202 Do an extended regular expression match on whole package names,
203 assuming the syntax of inter-package relationship fields such as
204 .BR Depends , Recommends ", ..."
205 When this flag is given you should not worry
206 about sub-package names such as "libpcre3" also matching
207 "libpcre3-dev". This flag implies (and is incompatible with)
208 .BR \-e .
209 .IP "\fB\-\-eq"
210 Do an equality comparison under the Debian version number system. If
211 the pattern or the field to be searched in is not a valid Debian
212 version number, the paragraph is regarded as not matching. As a
213 special case, this is capable of comparing simple nonnegative integers
214 for equality.
215 .IP "\fB\-\-lt"
216 Do an strictly-less-than comparison under the Debian version number
217 system. If the pattern or the field to be searched in is not a valid
218 Debian version number, the paragraph is regarded as not matching. As
219 a special case, this is capable of comparing simple nonnegative
220 integers.
221 .IP "\fB\-\-le"
222 Do an less-than-or-equal comparison under the Debian version number
223 system. If the pattern or the field to be searched in is not a valid
224 Debian version number, the paragraph is regarded as not matching. As
225 a special case, this is capable of comparing simple nonnegative
226 integers.
227 .IP "\fB\-\-gt"
228 Do an strictly-greater-than comparison under the Debian version number
229 system. If the pattern or the field to be searched in is not a valid
230 Debian version number, the paragraph is regarded as not matching. As
231 a special case, this is capable of comparing simple nonnegative
232 integers.
233 .IP "\fB\-\-ge"
234 Do an greater-than-or-equal comparison under the Debian version number
235 system. If the pattern or the field to be searched in is not a valid
236 Debian version number, the paragraph is regarded as not matching. As
237 a special case, this is capable of comparing simple nonnegative
238 integers.
239 .SS Combining filters
240 .IP "\fB\-!\fR, \fB\-\-not\fR, \fB!"
241 Match if the following filter does
242 .B not
243 match.
244 .IP "\fB\-o\fR, \fB\-\-or"
245 Match if either one or both of the preceding and following filters
246 matches.
247 .IP "\fB\-a\fR, \fB\-\-and"
248 Match if both the preceding and the following filter match.
249 .IP "\fB(\fR ... \fB)"
250 Parentheses can be used for grouping. Note that they need to be
251 escaped for most shells. Filter modifiers can be given before the
252 opening parentheses; they will be treated as if they had been repeated
253 for each simple filter inside the parentheses.
254 .SS Output format modifiers
255 .IP "\fB\-l\fR, \fB\-\-files\-with\-matches"
256 Output only the file names, each on its own line, of those files that contain
257 at least one matching paragraph. This is incompatible with the
258 .BR \-v " and " \-L
259 options, and all other output format modifiers will be ignored.
260 .IP "\fB\-L\fR, \fB\-\-files\-without\-matches"
261 Output only the file names, each on its own line, of those files that do not
262 contain any matching paragraphs. This is incompatible with the
263 .BR \-v " and " \-l
264 options, and all other output format modifiers will be ignored.
265 .IP "\fB\-s \fIfield\fR,\fIfield\fR, ... | \fB\-\-show\-field=\fIfield\fR,\fIfield\fR, ..."
266 Show only the body of these
267 .IR field s
268 from the matching paragraphs. The
269 .I field
270 names must not include any colons or commas. Commas are used to
271 delimit
272 .I field
273 names in the argument to this option. The
274 .IR field s
275 are shown in the order given here. See also the option
276 .BR \-I .
277 Note that in the absence of the
278 .B \-\-ensure\--dctrl
279 option, if only one field is selected, no paragraph separator is output.
280 .IP "\fB\-I\fR, \fB\-\-invert\-show"
281 Invert the meaning of option
282 .BR \-s :
283 show only the fields that have
284 .B not
285 been named using a
286 .B \-s
287 option. As an artefact of the implementation,
288 the order of the fields in the original paragraph is not preserved.
289 .PP
290 A
291 .I field
292 specification can contain a colon. In such a case, the part
293 up to the colon is taken as the name of the field to be shown, and the
294 part after the colon is taken as the name of the field whose content
295 is to be used if the field to be shown is empty.
296 .IP "\fB\-d"
297 Show only the first line of the
298 .B Description
299 field from the matching
300 paragraphs. If no
301 .B \-s
302 option is specified, this option also effects
303 .BR "\-s Description";
304 if there is a
305 .B \-s
306 option but it does not include
307 the
308 .B Description
309 field name, one is appended to the option. Thus the
310 .B Description
311 field's location in the output is determined by the
312 .B \-s
313 option, if any, the last field being the default.
314 .IP "\fB\-n\fR, \fB\-\-no\-field\-names"
315 Suppress field names when showing specified fields, only their bodies
316 are shown. Each field is printed in its original form without the
317 field name, the colon after it and any whitespace preceding the start
318 of the body.
319 .IP "\fB\-v\fR, \fB\-\-invert\-match"
320 Instead of showing all the paragraphs that match, show those paragraphs
321 that do
322 .B not
323 match.
324 .IP "\fB\-c\fR, \fB\-\-count"
325 Instead of showing the paragraphs that match (or, with
326 .BR \-v ,
327 that don't
328 match), show the count of those paragraphs.
329 .IP "\fB\-q\fR, \fB\-\-quiet\fR, \fB\-\-silent"
330 Output nothing to the standard output stream. Instead, exit
331 immediately after finding the first match.
332 .SS Miscellaneous
333 .IP "\fB\-\-ensure\-dctrl"
334 Ensure that the output is in dctrl format, specifically that there always
335 is an empty line separating paragraphs. This option is not honored if
336 the
337 .B \-n
338 option has been selected, as that option deliberately requests a non-dctrl
339 format for the output. In a future version, this option may be made the
340 default behaviour.
341 .IP "\fB\-\-compat"
342 Override any
343 .B \-\-ensure\-dctrl
344 option given earlier on the command line.
345 .IP "\fB\-\-ignore\-parse\-errors"
346 Ignore errors in parsing input. A paragraph which cannot be parsed
347 is ignored in its entirety, and the next paragraph is assumed to start
348 after the first newline since the location of the error.
349 .IP "\fB\-\-debug\-optparse"
350 Show how the current command line has been parsed.
351 .IP "\fB\-\-errorlevel=\fIlevel"
352 Set log level to
353 .IR level .
354 .I level
355 is one of
356 .BR fatal ", " important ", " informational " and " debug ,
357 but the last may not be available,
358 depending on the compile-time options. These categories are given
359 here in order; every message that is emitted when
360 .B fatal
361 is in effect, will be emitted in the
362 .B important
363 error level, and so on. The default is
364 .BR important .
365 .IP "\fB\-V\fR, \fB\-\-version"
366 Print out version information.
367 .IP "\fB\-C\fR, \fB\-\-copying"
368 Print out the copyright license. This produces much output; be sure
369 to redirect or pipe it somewhere (such as your favourite pager).
370 .IP "\fB\-h\fR, \fB\-\-help"
371 Print out a help summary.
372 .SH EXAMPLES
373 The almost simplest use of this program is to print out the status or
374 available record of a package. In this respect,
375 .B grep\-dctrl
376 is like
377 .B "dpkg \-s"
378 or
379 .BR "dpkg \-\-print\-avail".
380 To print out the status record of the package "mixal", do
381 .nf
382 % grep\-status \-PX mixal
383 .fi
384 and to get its available record, use
385 .nf
386 % grep\-available \-PX mixal
387 .fi
388 In fact, you can ask for the record of the "mixal" package
389 from any Debian control file. Say, you have the Debian 6.0
390 CD-ROM's
391 .I Packages
392 file in the current directory; now you
393 can do a
394 .nf
395 % grep\-dctrl \-PX mixal Packages
396 .fi
397 .PP
398 But
399 .B grep\-dctrl
400 can do more than just emulate
401 .BR dpkg .
402 It can more-or-less emulate
403 .BR apt\-cache !
404 That program has a search feature that searches package descriptions.
405 But we can do that too:
406 .nf
407 % grep\-available \-F Description foo
408 .fi
409 searches for the string "foo" case-sensitively in the descriptions of
410 all available packages. If you want case-insensitivity, use
411 .nf
412 % grep\-available \-F Description \-i foo
413 .fi
414 Truth to be told,
415 .B apt\-cache
416 searches package names, too. We can separately search in the names;
417 to do so, do
418 .nf
419 % grep\-available \-F Package foo
420 .fi
421 or
422 .nf
423 % grep\-available \-P foo
424 .fi
425 which is pretty much the same thing. We can also search in both
426 descriptions and names; if match is found in either, the package
427 record is printed:
428 .nf
429 % grep\-available \-P \-F Description foo
430 .fi
431 or
432 .nf
433 % grep\-available \-F Package \-F Description foo
434 .fi
435 This kind of search is the exactly same that
436 .B apt\-cache
437 does.
438 .PP
439 Here's one thing neither
440 .B dpkg
441 nor
442 .B apt\-cache
443 do. Search for a string in the whole
444 .I status
445 or
446 .I available
447 file (or
448 any Debian control file, for that matter) and print out all package
449 records where we have a match. Try
450 .nf
451 % grep\-available dpkg
452 .fi
453 sometime and watch how thoroughly
454 .B dpkg
455 has infiltrated Debian.
456 .PP
457 All the above queries were based on simple substring searches.
458 But
459 .B grep\-dctrl
460 can handle regular expressions in the search pattern. For example,
461 to see the status records of all packages with either "apt" or
462 "dpkg" in their names, use
463 .nf
464 % grep\-status \-P \-e 'apt|dpkg'
465 .fi
466 .PP
467 Now that we have seen all these fine and dandy queries, you might
468 begin to wonder whether it is necessary to always see the whole
469 paragraph. You may be, for example, interest only in the dependency
470 information of the packages involved. Fine. To show the depends
471 lines of all packages maintained by me, do a
472 .nf
473 % grep\-available \-F Maintainer \-s Depends '[email protected]'
474 .fi
475 If you want to see the packages' names, too, use
476 .nf
477 % grep\-available \-F Maintainer \-s Package,Depends \\
478 '[email protected]'
479 .fi
480 Note that there must be no spaces in the argument to the
481 .B \-s
482 switch.
483 .PP
484 More complex queries are also possible. For example, to see the list of packages
485 maintained by me and depending on libc6, do
486 .nf
487 % grep\-available \-F Maintainer '[email protected]' \\
488 \-a \-F Depends libc6 \-s Package,Depends
489 .fi
490 Remember that you can use other UNIX filters to help you, too. Ever
491 wondered, who's the most active Debian developer based on the number
492 of source packages being maintained? Easy. You just need to have a
493 copy of the most recent
494 .I Sources
495 file from any Debian mirror.
496 .nf
497 % grep\-dctrl \-n \-s Maintainer '' Sources | sort | \\
498 uniq \-c | sort \-nr
499 .fi
500 This example shows a neat trick: if you want to selectively
501 show only some field of
502 .I all
503 packages, just supply an empty pattern.
504 .PP
505 The term "bogopackage" means the count of the packages that a Debian
506 developer maintains. To get the bogopackage count for the maintainer
507 of
508 .BR dctrl\-tools ,
509 say
510 .nf
511 % grep\-available \-c \-FMaintainer \\
512 "`grep\-available \-sMaintainer \-n \-PX dctrl\-tools`"
513 .fi
514 .PP
515 Sometimes it is useful to output the data of several fields on the
516 same line. For example, the following command outputs the list of
517 installed packages, sorted by their
518 .BR Installed\-Size .
519 .nf
520 % grep\-status \-FStatus \-sInstalled\-Size,Package \-n \\
521 "install ok installed" -a -FInstalled-Size --gt 0 \\
522 | paste \-sd " \\n" | sort \-n
523 .fi
524 Note that there should be exactly 2 spaces in the " \\n" string.
525 .PP
526 Another usual use-case is looking for packages that have another one as
527 build dependency:
528 .nf
529 % grep\-dctrl \-s Package \-F Build\-Depends,Build\-Depends\-Indep \\
530 quilt /var/lib/apt/lists/*Sources
531 .fi
532 .PP
533 These examples cover a lot of typical uses of this utility, but not
534 all possible uses. Use your imagination! The building blocks are
535 there, and if something's missing, let me know.
536 .SH DIAGNOSTICS
537 In the absence of errors, the exit code
538 .B 0
539 is used if at least one
540 match was found, and the exit code
541 .B 1
542 is used if no matches were found.
543 If there were errors, the exit code is
544 .BR 2 ,
545 with one exception. If the
546 .BR \-q ", " \-\-quiet " or " \-\-silent
547 options are used, the exit code
548 .B 0
549 is used when
550 a match is found regardless of whether there have been non-fatal
551 errors.
552 .PP
553 These messages are emitted in log levels
554 .BR fatal " and " important .
555 Additional messages may be provided by the system libraries.
556 .B This list is incomplete.
557 .IP "\fBA pattern is mandatory"
558 You must specify a pattern to be searched for.
559 .IP "\fBmalformed filter"
560 No filter was specified, but one is required.
561 .IP "\fBcannot find enough memory"
562 More memory was needed than was available. This error may be
563 transient, that is, if you try again, all may go well.
564 .IP "\fBcannot suppress field names when showing whole paragraphs"
565 When you do not use the
566 .B \-s
567 switch,
568 .B grep\-dctrl
569 just passes the matching paragraphs through, not touching them any
570 way. This means, for example, that you can only use
571 .B \-n
572 when you use
573 .BR \-s .
574 .IP "\fBinconsistent modifiers of simple filters"
575 Conflicting modifiers of simple filters were used; for example, perhaps both
576 .B \-X
577 and
578 .B \-e
579 were specified for the same simple filter.
580 .IP "\fBmissing ')' in command line"
581 There were more opening than closing parentheses in the given
582 filter.
583 .IP "\fBno such log level"
584 The argument to
585 .B \-\-errorlevel
586 was invalid.
587 .IP "\fBtoo many file names"
588 The number of file names specified in the command line exceeded a
589 compile-time limit.
590 .IP "\fBtoo many output fields"
591 The argument to
592 .B \-s
593 had too many field names in it. This number is
594 limited to 256.
595 .IP "\fBunexpected ')' in command line"
596 There was no opening parenthesis that would match some closing
597 parenthesis in the command line.
598 .SH FILES
599 .IP \fI/var/lib/dpkg/available
600 The default input file of
601 .BR grep\-available .
602 .IP \fI/var/lib/dpkg/status
603 The default input file of
604 .BR grep\-status .
605 .SH AUTHOR
606 The program and this manual page were written by Antti-Juhani
607 Kaijanaho
608 .RI < [email protected] >.
609 Bill Allombert
610 .RI < [email protected] >
611 provided one of the examples in the manual page.
612 .SH "SEE ALSO"
613 Debian Policy Manual. Published as the Debian
614 package
615 .BR debian\-policy .
616 Also available in the Debian website.
617 .PP
618 .BR apt\-cache (1),
619 .BR ara (1),
620 .BR dpkg\-awk (1),
621 .BR sgrep (1),
622 .BR dpkg (8)
623 \" Local variables:
624 \" mode: nroff
625 \" End:
626