blob: e28f5d197555f8e282cb3270ae9eccb7d206bfb0 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/bin/sh
set -eu
while getopts 'p:x:l:f:u' flag; do
case "$flag" in
p)
PREFIX="$OPTARG"
;;
x)
EXECUTABLES_EXPECTED="$OPTARG"
;;
l)
SYMLINKS_EXPECTED="$OPTARG"
;;
f)
FILES_EXPECTED="$OPTARG"
;;
u)
UNINSTALL=1
;;
*)
exit 2
;;
esac
done
shift $((OPTIND - 1))
if [ -n "${UNINSTALL:-}" ]; then
if [ "$(find "$PREFIX" -type f | wc -l)" != 0 ]; then
printf 'When uninstalling, left over files in the PREFIX directory:\n'
find "$PREFIX" -type f
exit 1
fi
exit
fi
EXECUTABLES_ACTUAL="$(find "$PREFIX" -type f -perm -a=x | wc -l)"
if [ "${EXECUTABLES_EXPECTED:-0}" != "$EXECUTABLES_ACTUAL" ]; then
printf 'Expected %s executables, found %s:\n' \
"$EXECUTABLES_EXPECTED" "$EXECUTABLES_ACTUAL" >&2
find "$PREFIX" -type f -perm -a=x
exit 1
fi
SYMLINKS_ACTUAL="$(find "$PREFIX" -type l | wc -l)"
if [ "${SYMLINKS_EXPECTED:-0}" != "$SYMLINKS_ACTUAL" ]; then
printf 'Expected %s symlinks, found %s:\n' \
"$SYMLINKS_EXPECTED" "$SYMLINKS_ACTUAL" >&2
find "$PREFIX" -type l
exit 1
fi
FILES_ACTUAL="$(find "$PREFIX" -type f | wc -l)"
if [ "${FILES_EXPECTED:-0}" != "$FILES_ACTUAL" ]; then
printf 'Expected %s files, found %s:\n' \
"$FILES_EXPECTED" "$FILES_ACTUAL" >&2
find "$PREFIX" -type f
exit 1
fi
|