17
17
DPKGLIST=/var/lib/dlocate/dpkg-list
18
18
DPKG_INFO=/var/lib/dpkg/info
20
if [ -x /usr/bin/locate.findutils ] ; then
21
# locate package is installed
22
LOCATE='/usr/bin/locate.findutils'
24
# slocate diverts locate
25
LOCATE=$(/usr/sbin/dpkg-divert --truename /usr/bin/locate)
20
COMPRESS_DLOCATEDB='0'
22
[ -e /etc/default/dlocate ] && . /etc/default/dlocate
23
[ "$COMPRESS_DLOCATE" = "1" ] && GREP='zgrep'
28
25
function dlocate_help {
30
Usage: dlocate [option] [string...]
33
(no option) string list all records that match
34
-S string list records where files match
35
-L package list all files in package
36
-l package almost-emulation of 'dpkg -l'
37
-s package print package's status
38
-ls package 'ls -ldF' of all files in package
39
-du package 'du -sck' of all files in package
40
-conf package list conffiles in package
41
-lsconf package 'ls -ldF' of conffiles in package
42
-md5sum package list package's md5sums (if any)
43
-md5check package check package's md5sums (if any)
44
-man package list package's man pages (if any)
45
-lsman package list full path/filenames of man pages
46
-lsbin package list full path/filenames of executable files
48
-- stop processing options. remainder of
49
command-line is filename(s)
51
--ignore-case, -i ignore case when search for filenames or
54
-h display this help message and exit.
55
-V display dlocate's version number and exit.
57
The -L, -s, and -S commands are roughly analagous to the
58
equivalent dpkg commands.
27
Usage: dlocate [option...] [command] [PATTERN...]
30
DEFAULT/none PATTERN list records that match either package or files names
31
-S PATTERN list records that match filenames
33
-L package list all files in package
34
-l package regexp-enhanced emulation of 'dpkg -l'
35
-s package print package's status
36
-ls package 'ls -ldF' of all files in package
37
-du package 'du -sck' of all files in package
38
-conf package list conffiles in package
39
-lsconf package 'ls -ldF' of conffiles in package
40
-md5sum package list package's md5sums (if any)
41
-md5check package check package's md5sums (if any)
42
-man package list package's man pages (if any)
43
-lsman package list full path/filenames of man pages
44
-lsbin package list full path/filenames of executable files
45
-K list installed kernel & related packages
46
-k detailed list of installed kernel & related packages
48
-- stop processing commands and options. remainder of
49
command-line is filename(s)
52
The -l, and -S commands are approximately the same as the equivalent dpkg
53
options except that the search is performed using regular expressions
54
rather than fixed strings.
58
--filename-only only output file names when searching for files
59
--package-only only output package names when searching for files
61
Regular Expression Options (see grep(1) for details):
68
-w, --word-regexp restrict matches to whole words
69
-i, --ignore-case case-insensitive match
71
Miscellaneous Options:
73
-h, -H, --help display this help message and exit.
74
-V, --version display dlocate's version number and exit.
75
-v, --verbose, --debug verbose/debug output
63
80
function dlocate_version {
64
#VERSION_BANNER=$(grep-dctrl -X -P dlocate -n -s Version -d \
65
# /var/lib/dpkg/status | sed -e '2s/.*/(&)/')
66
VERSION_BANNER="0.96.1"
67
echo "dlocate version "$VERSION_BANNER
82
echo "dlocate version $VERSION_BANNER"
71
86
function dlocate_option_error () {
97
# default to extended regexp
102
# default to case-sensitive
104
# default to non- word-based searches
107
# output filters for -S and DEFAULT option
110
function output_filter() {
111
[ "$VERBOSE" = "1" ] && echo "OUTPUT FILTER: $OUTPUT_FILTER"
113
case "$OUTPUT_FILTER" in
116
cut -d\ -f 2 | sort -u
120
cut -d: -f 1 | sort -u
83
131
SEPARATOR='::::::::'
134
if [ "$LAST_OPT" -eq 1 ] ; then
135
PKGS="$PKGS$SEPARATOR$p"
90
if [ $LAST_OPT -eq 0 ] ; then
93
PKGS="$PKGS$SEPARATOR$p"
97
142
(''|'-h'|'-H'|'--help')
99
if [ $LAST_OPT -eq 0 ] ; then
102
PKGS="$PKGS$SEPARATOR$p"
106
('-v'|'-V'|'--version')
108
if [ $LAST_OPT -eq 0 ] ; then
111
PKGS="$PKGS$SEPARATOR$p"
115
('--ignore-case'|'-i')
117
if [ $LAST_OPT -eq 0 ] ; then
150
('-v'|'--verbose'|'--debug')
159
('-S'|'-L'|'-l'|'-s'|'-ls'|'-du'|'-conf'|'-lsconf'|'-md5sum'|'-md5check'|'-man'|'-lsman'|'-lsbin')
163
('-i'|'--ignore-case')
120
PKGS="$PKGS$SEPARATOR$p"
124
('-S'|'-L'|'-l'|'-s'|'-ls'|'-du'|'-conf'|'-lsconf'|'-md5sum'|'-md5check'|'-man'|'-lsman'|'-lsbin')
126
if [ $LAST_OPT -eq 0 ] ; then
129
PKGS="$PKGS$SEPARATOR$p"
167
('-E'|'--extended-regexp')
173
('-F'|'--fixed-strings')
178
('-G'|'--basic-regexp')
184
('-P'|'--perl-regexp')
189
('-w'|'--word-regexp')
194
OUTPUT_FILTER='Filenames only'
198
OUTPUT_FILTER='Packages only'
134
if [ $LAST_OPT -eq 0 ] ; then
135
202
dlocate_option_error $1
137
PKGS="$PKGS$SEPARATOR$p"
142
PKGS="$PKGS$SEPARATOR$p"
206
PKGS="$PKGS$SEPARATOR$p"
147
212
PKGS=$(echo "$PKGS" | sed -e "s/^$SEPARATOR//")
150
PKGS_REGEXP=$(echo "$PKGS" | sed -e "s/$SEPARATOR/|/g")
153
FILES_REGEXP="$PKGS_REGEXP"
213
[ -z "$PKGS" ] && dlocate_help
215
PKGS_REGEXP=$(echo "$PKGS" | sed -e "s/$SEPARATOR/$RE_SEPARATOR/g")
217
FILES_REGEXP="($PKGS_REGEXP)"
218
[ "$WORD_RE" = "-w" ] && FILES_REGEXP="\b$FILES_REGEXP\b"
220
PKGS=$(echo "$PKGS" | sed -e "s/$SEPARATOR/ /")
222
if [ "$VERBOSE" = "1" ] ; then
224
echo "RE_SEPARATOR:" $RE_SEPARATOR
225
echo "PKGS_REGEXP:" $PKGS_REGEXP
158
228
[ -z "$PKGS_REGEXP" ] && PKGS_REGEXP='^$'
198
270
elif [ "$OPTION" = '-S' ] ; then
200
$LOCATE -d $DLOCATEDB $IGNORE_CASE -- $PKGS | egrep $IGNORE_CASE "^[-a-zA-Z0-9_.+]+:.*($FILES_REGEXP)"
272
if [ "$RE_TYPE" = '-F' ] ; then
273
echo "Error: -F Fixed String searches are incompatible with -S"
277
PREFIX="^([-a-zA-Z0-9_.+]+:|diversion by )"
278
[ "$RE_TYPE" = "-G" ] && PREFIX="^([-a-zA-Z0-9_.+]+:\|diversion by )"
280
[ "$VERBOSE" = "1" ] && echo RUNNING: $GREP $RE_TYPE $IGNORE_CASE "$PREFIX.*$FILES_REGEXP" "$DLOCATEDB"
281
$GREP $RE_TYPE $IGNORE_CASE "$PREFIX.*$FILES_REGEXP" "$DLOCATEDB" | output_filter
203
284
elif [ "$OPTION" = 'DEFAULT' ] ; then
205
$LOCATE -d $DLOCATEDB $IGNORE_CASE -- $PKGS
286
[ "$VERBOSE" = "1" ] && echo RUNNING: $GREP $RE_TYPE $IGNORE_CASE $WORD_RE "$PKGS_REGEXP" "$DLOCATEDB"
287
$GREP $RE_TYPE $IGNORE_CASE $WORD_RE "$PKGS_REGEXP" "$DLOCATEDB" | output_filter
290
elif [ "$OPTION" = '-s' ] ; then
291
DCTRL_REGEXP="^($PKGS_REGEXP)$"
293
[ "$VERBOSE" = "1" ] && echo RUNNING: grep-dctrl -X -P $DCTRL_RE_TYPE $DCTRL_REGEXP /var/lib/dpkg/status
294
grep-dctrl -P $DCTRL_RE_TYPE $DCTRL_REGEXP /var/lib/dpkg/status
297
elif [ "$OPTION" = '-k' ] ; then
299
grep-status -P -e "(^linux-(image|source|headers|doc|debug)|nvidia-kernel-|.*-modules-)" | \
300
grep-dctrl -n -s Package -F status " installed" - | \
301
egrep -v -- '^(lib|openser|pam|scim|tryton|wims)|-perl'
305
elif [ "$OPTION" = '-K' ] ; then
306
KERN_RE=$(dlocate -k | xargs | sed -e 's/ /|/g')
308
[ "$VERBOSE" = "1" ] && echo echo RUNNING: dlocate -P -l "\s($KERN_RE)\s"
309
dlocate -P -l "\s($KERN_RE)\s"
210
313
for PKG in $PKGS; do
212
314
case "$OPTION" in