File: update-dlocatedb

package info (click to toggle)
dlocate 1.18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144 kB
  • sloc: sh: 641; perl: 181; makefile: 37
file content (69 lines) | stat: -rwxr-xr-x 1,157 bytes parent folder | download | duplicates (2)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh

DPKGLIST='/var/lib/dlocate/dpkg-list'

pkgs=1
files=1

usage() {
  cat <<__EOF__
Usage: $0 [<option>...]

Options:
  -p        Update the packages list only.
  -f        Update the files list only.
  -b        Update both (default).
  -h        This help message.
__EOF__
}

usage_error() {
  printf "%s\n" "$*" >/dev/stderr
  exit 1
}

while getopts "pfbh" opt; do
  case "$opt" in
  p)
    pkgs=1
    files=''
    ;;
  f)
    pkgs=''
    files=1
    ;;
  b)
    pkgs=1
    files=1
    ;;
  h)
    usage
    ;;
  *)
    usage_error "unknown option: '$opt'"
    ;;
  esac
done
shift $((OPTIND - 1))

# See ionice(1)
if command -v ionice >/dev/null; then
  # Redirect ionice output to /dev/null because VSERVER & OPENVZ
  # & probably other container environments don't like it.  See
  # Bug#456292
  ionice -c3 -p$$ >/dev/null 2>&1
fi

if [ -n "$files" ]; then
  # update dlocate database
  if [ -x /usr/share/dlocate/updatedb ]; then
    /usr/share/dlocate/updatedb >/dev/null
  fi
fi

if [ -n "$files" ]; then
  # update dpkg-list
  if [ -x /usr/share/dlocate/update-dpkg-list ]; then
    /usr/share/dlocate/update-dpkg-list >/dev/null
  fi
fi