blob: 472045f6222fc454c74aa65c6ec6f9fdf9750c07 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/bin/sh
# xlocate [-u | PATTERN] - locate files in all XBPS packages
: ${XLOCATE_DB:=~/.cache/xlocate.db}
xupdatedb() {
if command -v pv >/dev/null; then
PROGRESS="pv -l"
else
PROGRESS=cat
fi
echo "xlocate: reindexing database..." 1>&2
xbps-query -Ro '*' |
$PROGRESS |
sed 's/ *([^)]*)$//; s|: ||; s,^,/,' |
/usr/libexec/frcode >"$XLOCATE_DB"
}
if [ "$1" = -u ]; then
xupdatedb
exit $?
fi
if [ -e "$XLOCATE_DB" ]; then
if find /var/db/xbps/ -name '*repodata' -newer "$XLOCATE_DB" | grep -q .; then
echo "xlocate: database outdated, please run xlocate -u." 1>&2
fi
rx=
case "$1" in
# Just . is unlikely to be a regex here...
*[*+\\\[\]^$]*) rx=-r;;
esac
# XXX also matches template in package name.
glocate $rx -d "$XLOCATE_DB" "$1" |
sed 's|^/\([^/]*\)-[^-/]*/|\1\t/|'
else
xbps-query --regex -Ro "$@" |
sed 's/ *([^)]*)$//; s/^\([^ ]*\)-[^-]*: /\1\t/'
fi
|