~ubuntu-branches/ubuntu/warty/dlocate/warty

« back to all changes in this revision

Viewing changes to dlocate

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2002-03-10 09:44:16 UTC
  • Revision ID: james.westby@ubuntu.com-20020310094416-ceyi0iyltaaiz9u1
Tags: 0.5-0.1
* Non-Maintainer Upload.
* NMU, Craig Sanders seems to have lost his interest in this package,
  last upload was in 1999.
* Upload sponsored by Thom May <thom@debian.org>.
* cron job conditional on package being installed (Closes: #83196, #54073)
* remove /var/lib/dlocate on purge (Closes: #63902)
* work with long package names. Patch from Peter Samuelson, modified to
  limit length of output to $COLUMNS characters
  (Closes: #84018, #67650, #78621)
* Patch for #84018 adds "Hold" to the list of desired states, too.
 (Closes: #132930)
* dpkg -ls works with packages containing many files (use xargs),
  patch from Peter Samuelson (Closes: #91785)
* Works with slocate, using dpkg-divert --truename, patch from Robert
  Luberda, depend on dpkg 1.8.0, drop superfluous versioned conflicts
  on very old dpkg. Once this is uploaded I'll ask the slocate-maintainer
  to remove the "Conflicts: dlocate".
  (Closes: #100694, #101426, #129251) 
* depend on perl. (Closes: #132931)
* Use nice quotation marks in dlocate(1) (Closes: #129186)
* Add manpage for update-dlocatedb.8 (Closes: #76149)
* dlocate -l already mimics dpkg -l good enough
  (Closes: #43145, #43146, #45057)
* fix lintian warnings:
  findutils and bash are essential, depending on them is wrong
  copyright: fix location of GPL
  update-dlocatedb has no manpage.
  Add versioned Build-Depends-Indep: debhelper >= 3.0.0 (dh_installmanpages)
  Bump standards-version.
* update debian/rules from dh_make-template
* Use dh_installman instead of dh_installmanpages.
* Use DH_COMPAT=3, get rid of debian/conffiles.
* update dlocate(1)
* -l uses egrep and accepts extended re, document it in manpage.
* Old bug was already fixed: Generate initial database asynchronously
  (Closes: #42314)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# original script by Jim Pick <jim@jimpick.com>, GPL'd of course
 
4
# many changes and enhancement by Craig Sander <cas@taz.net.au>
 
5
#
 
6
# hacked by cas to use case instead of if/elif/fi
 
7
# hacked by cas to add '-ls' option.  also added error checking for
 
8
# -L and -ls options.
 
9
# hacked by cas to add '-conf' and '-lsconf' options.
 
10
# hacked by cas to add '-md5sum' and '-md5check' options.
 
11
# hacked by cas to add '-man' option.
 
12
# hacked by cas to add '-s' option (requires grep-dctrl).
 
13
# hacked by cas to support multiple string/package arguments
 
14
# hacked by cas to add simplistic emulation of 'dpkg -l'
 
15
 
 
16
DLOCATEDB=/var/lib/dlocate/dlocatedb
 
17
DPKGLIST=/var/lib/dlocate/dpkg-list
 
18
DPKG_INFO=/var/lib/dpkg/info
 
19
 
 
20
LOCATE="/usr/bin/locate" 
 
21
# slocate diverts locate
 
22
LOCATE=`/usr/sbin/dpkg-divert --truename /usr/bin/locate`
 
23
 
 
24
OPTION="$1" ; shift
 
25
 
 
26
case "$OPTION" in
 
27
        ""|"-h"|"-H"|"--help")
 
28
                echo "Usage: dlocate [option] [string...]"
 
29
                echo 
 
30
                echo "Options:"
 
31
                echo "    (no option) string  list all records that match"
 
32
                echo "    -S        string      list records where files match"
 
33
                echo "    -L        package     list all files in package"
 
34
                echo "    -l        package     almost-emulation of 'dpkg -l'"
 
35
                echo "    -s        package     print package's status"
 
36
                echo "    -ls       package     'ls -ldF' of all files in package"
 
37
                echo "    -du       package     'du -sck' of all files in package"
 
38
                echo "    -conf     package     list conffiles in package"
 
39
                echo "    -lsconf   package     'ls -ldF' of conffiles in package"
 
40
                echo "    -md5sum   package     list package's md5sums (if any)"
 
41
                echo "    -md5check package     check package's md5sums (if any)"
 
42
                echo "    -man      package     list package's man pages (if any)"
 
43
                echo 
 
44
                echo "  The -L, -s, and -S commands are roughly analagous to the"
 
45
                echo "  equivalent dpkg commands."
 
46
                exit
 
47
                ;;
 
48
esac
 
49
 
 
50
PKG=$1
 
51
[ -z "$1" ] && PKG="$OPTION"
 
52
 
 
53
while [ -n "$PKG" ] ; do
 
54
 
 
55
case "$OPTION" in
 
56
        "-l")
 
57
                [ -z "$COLUMNS" ] &&
 
58
                        COLUMNS=$(stty -a 2>&- |
 
59
                                sed -ne '/columns/s/.*columns \([0-9]*\)[^0-9].*/\1/p');
 
60
                [ 0"$COLUMNS" -lt 80 ] && COLUMNS=80;
 
61
                ((fieldw=(COLUMNS-24)/4));
 
62
                # dpkg uses
 
63
                #((fieldd=fieldw*2+16));
 
64
                # limiting the output to COLUMNS-2 characters and losing up to
 
65
                # additional 3 characters due to the rounding error.
 
66
                ((fieldd=COLUMNS-fieldw*2-6));
 
67
                fmt_eq=$(echo ==================================================== |
 
68
                        cut -c-$fieldw)
 
69
                printf \
 
70
"Desired=Unknown/Install/Remove/Purge/Hold
 
71
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
 
72
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
 
73
||/ %-${fieldw}s %-${fieldw}s %s
 
74
+++-${fmt_eq}-${fmt_eq}-${fmt_eq}${fmt_eq}==================\\n" \
 
75
                        Name Version Description
 
76
 
 
77
                egrep "$1" $DPKGLIST | while read stat name ver descr; do
 
78
                        printf "%-2s  %-${fieldw}.${fieldw}s %-${fieldw}.${fieldw}s %-${fieldd}.${fieldd}s\\n" \
 
79
                                "$stat" "$name" "$ver" "$descr";
 
80
                done
 
81
                ;;
 
82
        "-L")
 
83
                if [ -e $DPKG_INFO/$PKG.list ] ; then 
 
84
                        cat $DPKG_INFO/$PKG.list
 
85
                else
 
86
                        echo Package \"$PKG\" not installed.
 
87
                fi
 
88
                ;;
 
89
        "-S")
 
90
                $LOCATE -d $DLOCATEDB $PKG | grep ":.*$PKG.*"
 
91
                ;;
 
92
        "-s")
 
93
                if [ -e $DPKG_INFO/$PKG.list ] ; then 
 
94
                        grep-dctrl -X -P $PKG /var/lib/dpkg/status
 
95
                else
 
96
                        echo Package \"$PKG\" not installed.
 
97
                fi
 
98
                ;;
 
99
        "-ls")
 
100
                if [ -e $DPKG_INFO/$PKG.list ] ; then
 
101
                        xargs ls -ldF < $DPKG_INFO/$PKG.list
 
102
                else
 
103
                        echo Package \"$PKG\" not installed.
 
104
                fi
 
105
                ;;
 
106
        "-du")
 
107
                if [ -e $DPKG_INFO/$PKG.list ] ; then 
 
108
                        du -sck $(cat $DPKG_INFO/$PKG.list | xargs ls -1dF | grep -v "@$\|/$" )
 
109
                else
 
110
                        echo Package \"$PKG\" not installed.
 
111
                fi
 
112
                ;;
 
113
        "-conf")
 
114
                if [ -e $DPKG_INFO/$PKG.conffiles ] ; then 
 
115
                        cat $DPKG_INFO/$PKG.conffiles
 
116
                else
 
117
                        echo Package \"$PKG\" not installed or has no conffiles.
 
118
                fi
 
119
                ;;
 
120
        "-lsconf")
 
121
                if [ -e $DPKG_INFO/$PKG.conffiles ] ; then 
 
122
                        ls -ldF $(cat $DPKG_INFO/$PKG.conffiles)
 
123
                else
 
124
                        echo Package \"$PKG\" not installed or has no conffiles.
 
125
                fi
 
126
                ;;
 
127
        "-md5sum")
 
128
                if [ -e $DPKG_INFO/$PKG.md5sums ] ; then 
 
129
                        cat $DPKG_INFO/$PKG.md5sums
 
130
                else
 
131
                        echo Package \"$PKG\" not installed or has no md5sums.
 
132
                fi
 
133
                ;;
 
134
        "-man")
 
135
                if [ -e $DPKG_INFO/$PKG.list ] ; then 
 
136
                        dlocate -L $PKG | \
 
137
                                sed -n -e 's/\.gz$//' \
 
138
                                          -e '/man.*\/.*[0-9]/s/^.*\/\([^\/]*\)\.\(.*\)/\2 \1/p'
 
139
                else
 
140
                        echo Package \"$PKG\" not installed.
 
141
                fi
 
142
                ;;
 
143
        "-md5check")
 
144
                if [ -e $DPKG_INFO/$PKG.md5sums ] ; then 
 
145
                        cat $DPKG_INFO/$PKG.md5sums | \
 
146
                                awk '{print $1 "  /" $2}' | \
 
147
                                md5sum -v -c /dev/stdin
 
148
                else
 
149
                        echo Package \"$PKG\" not installed or has no md5sums.
 
150
                fi
 
151
                ;;
 
152
        *)
 
153
                $LOCATE -d $DLOCATEDB "$PKG"
 
154
                ;;
 
155
esac
 
156
 
 
157
shift
 
158
PKG=$1
 
159
done
 
160
 
 
161