On Fri, 2 Oct 1998, Rainer Dorsch wrote:

> $ dpkg -l /usr/bin/printmail
> No packages found matching /usr/bin/printmail.

this is normal.  you used "-l" (list packages) when you meant "-S" (search)

$ dpkg -S /usr/bin/printmail
elm-me+: /usr/bin/printmail



btw, you may want to install jim pick's dlocate hack. it runs a lot
faster than 'dpkg -S' and does the same job (and a lot more) - it is a
very clever use of the GNU locate tool.


$ dlocate /usr/bin/printmail
elm-me+: /usr/bin/printmail

Jim maybe you should package this??? or submit it to the maintainer
of the findutils package.  BTW, you probably haven't seen my modified
version before. hope you like my changes.


anyway, here's how to install dlocate.

make the following directory:

        mkdir -p /var/lib/dlocate

then install the following files:

---cut here---/usr/sbin/dupdatedb---cut here---
#! /usr/bin/make -f
#
# original shell script by Jim Pick <[EMAIL PROTECTED]>, GPL'd of course
#
# hacked by cas to be a Makefile so it updates the dlocatedb only when
# needed (i.e. when the package *.list files have changed)

/var/lib/dlocate/dlocatedb: /var/lib/dpkg/info/*.list
        grep '' /var/lib/dpkg/info/*.list|sed 's,^.*/\(.*\)\.list:,\1: ,' | \
                /usr/lib/locate/frcode > /var/lib/dlocate/dlocatedb.new
        mv -f /var/lib/dlocate/dlocatedb /var/lib/dlocate/dlocatedb.old
        mv /var/lib/dlocate/dlocatedb.new /var/lib/dlocate/dlocatedb
---cut here---/usr/sbin/dupdatedb---cut here---

note: this is a Makefile, so lines are indented by a TAB, not spaces!

this makefile needs to be run (as root) by cron once every day (or week,
or whatever) like so:

0 3 * * *   make -f /usr/sbin/dupdatedb &>/dev/null


and the dlocate script itself:

---cut here---/usr/bin/dlocate---cut here---
#!/bin/sh
#
# original script by Jim Pick <[EMAIL PROTECTED]>, GPL'd of course
#
# hacked by cas to use case instead of if/elif/fi
# hacked by cas to add '-ls' option.  also added error checking for
# -L and -ls options.
# hacked by cas to add '-conf' and '-lsconf' options.
# hacked by cas to add '-md5sum' and '-md5check' options.

DLOCATEDB=/var/lib/dlocate/
DPKG_INFO="/var/lib/dpkg/info"

case "$1" in
        ""|"-h"|"-H"|"--help")
                echo "Usage: dlocate [-L] [-S] [-ls] [-conf] [-lsconf] [md5sum] 
[md5check] string"
                echo 
                echo "    (no option) string  list all records that match"
                echo "    -S        string      list records where files match"
                echo "    -L        string      list all files in package"
                echo "    -ls       string      'ls -ldF' of all files in 
package"
                echo "    -conf     string      list conffiles in package"
                echo "    -lsconf   string      'ls -ldF' of conffiles in 
package"
                echo "    -md5sum   string      list package's md5sums (if any)"
                echo "    -md5check string      check package's md5sums (if 
any)"
                echo 
                echo "  The -L and -S commands are roughly analagous to the"
                echo "  equivalent dpkg commands."
                ;;
        "-L")
                if [ -e $DPKG_INFO/$2.list ] ; then 
                        cat $DPKG_INFO/$2.list
                else
                        echo Package \"$2\" not installed.
                fi
                ;;
        "-S")
                locate -d $DLOCATEDB $2 | grep ":.*$2.*"
                ;;
        "-ls")
                if [ -e $DPKG_INFO/$2.list ] ; then 
                        ls -ldF $(cat $DPKG_INFO/$2.list)
                else
                        echo Package \"$2\" not installed.
                fi
                ;;
        "-conf")
                if [ -e $DPKG_INFO/$2.conffiles ] ; then 
                        cat $DPKG_INFO/$2.conffiles
                else
                        echo Package \"$2\" not installed or has no conffiles.
                fi
                ;;
        "-lsconf")
                if [ -e $DPKG_INFO/$2.conffiles ] ; then 
                        ls -ldF $(cat $DPKG_INFO/$2.conffiles)
                else
                        echo Package \"$2\" not installed or has no conffiles.
                fi
                ;;
        "-md5sum")
                if [ -e $DPKG_INFO/$2.md5sums ] ; then 
                        cat $DPKG_INFO/$2.md5sums
                else
                        echo Package \"$2\" not installed or has no md5sums.
                fi
                ;;
        "-md5check")
                if [ -e $DPKG_INFO/$2.md5sums ] ; then 
                        cat $DPKG_INFO/$2.md5sums | \
                                awk '{print $1 "  /" $2}' | \
                                md5sum -v -c /dev/stdin
                else
                        echo Package \"$2\" not installed or has no md5sums.
                fi
                ;;
        *)
                locate -d /var/lib/dlocate/dlocatedb $*
                ;;
esac
---cut here---/usr/bin/dlocate---cut here---


craig

--
craig sanders

Reply via email to