-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcheck_install_uninstall.sh
executable file
·84 lines (69 loc) · 2.34 KB
/
check_install_uninstall.sh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
#
# Ensure that the Makefile targets 'install' and 'uninstall' work.
#
# 2020 (C) by Christian Garbs <mitch@cgarbs.de>
# Licensed under GNU GPL v1 or, at your option, any later version.
set -e
initial_files=/tmp/initial_files
files_after_installation=/tmp/files_after_installation
files_after_removal=/tmp/files_after_removal
list_files()
{
if [ ! -d "$installdir" ]; then
return
fi
# ignore mime database in listing:
# on install, files might get created for the first time,
# but on uninstall only file contents are removed, not the files themselves
#
# also ignore $installdir which might remain because of the remaining mime database files
find "$installdir" \
| sort \
| grep -v -E '/share$' \
| grep -v -E '/share/applications$' \
| grep -v -E '/share/applications/mimeinfo\.cache' \
| grep -v -E '/share/mime$' \
| grep -v -E '/share/mime/(aliases|audio|generic-icons|globs|globs2|icons|magic|mime\.cache|subclasses|treemagic|types|version|XMLnamespaces)$' \
| grep -v -E '/share/mime/application$' \
| grep -v -E '/share/mime/application/x-cmakecache\.xml$' \
| grep -v -E "^$installdir$" || true
}
expect_content_to_be_equal()
{
local file_a="$1" file_b="$2"
printf 'compare <%s> to <%s> .. ' "$file_a" "$file_b"
if ! cmp --quiet "$file_a" "$file_b"; then
echo "ERROR"
echo "expected content of <$file_a> and <$file_b> to be equal, but file contents differ:"
diff "$file_a" "$file_b"
exit 1
fi
echo "ok"
}
expect_content_to_be_different()
{
local file_a="$1" file_b="$2"
printf 'compare <%s> to <%s> .. ' "$file_a" "$file_b"
if cmp --quiet "$file_a" "$file_b"; then
echo "ERROR"
echo "expected content of <$file_a> and <$file_b> to be different, but file contents are equal"
exit 1
fi
echo "ok"
}
## read installation directory from configuration
read -r _ _ installdir < <(grep "^prefix " config.mk)
## run install/uninstall cycle
list_files > "$initial_files"
make install
list_files > "$files_after_installation"
make uninstall
list_files > "$files_after_removal"
## check file changes
echo
expect_content_to_be_different "$initial_files" "$files_after_installation"
expect_content_to_be_different "$files_after_installation" "$files_after_removal"
expect_content_to_be_equal "$initial_files" "$files_after_removal"
## end
echo ok