aboutsummaryrefslogtreecommitdiff
path: root/sbopkglint.d/45-doinst.t.sh
blob: ae47c727ec5f4d5c9a6e8c96b55ed47bbf93531a (plain)
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
#!/bin/sh

# sbopkglint test, must be sourced by sbopkglint (not run standalone).

# PKG, PRGNAM, VERSION, ARCH are set by sbopkglint. also the current
# directory is the root of the installed package tree. This test
# also uses the filename variable.

#######################################################################
# check the doinst.sh. its job is to generate various files by running
# e.g. update-desktop-database, which creates a cache file. if the
# cache file exists, and doinst.sh either doesn't exist, or doesn't
# contain an update-desktop-database, that's very bad: it means
# the cache file is actually included in the package. which means,
# installing such a package would overwrite the user's local cache,
# breaking his desktop, until he fixes it (either manually or giving
# up and logging out or rebooting).

doinst=var/lib/pkgtools/scripts/"$( echo $filename | sed 's,\.[^.]*$,,' )"

have_doinst() {
	[ -e "$doinst" ]
	return $?
}

grep_doinst() {
	have_doinst && grep -q "$@" $doinst
	return $?
}

doinst_warn() {
	local msg="doinst.sh is missing, package needs one, with"
	have_doinst && msg="doinst.sh exists, but is missing"
	warn "$msg $@"
}

doinst_chk_command() {
	local cmd="$1"
	grep_doinst "$cmd" || doinst_warn "$cmd"
}

[ "$( find -L usr/share/icons -type f 2>/dev/null )" != "" ] && \
	doinst_chk_command "gtk-update-icon-cache"

[ "$( find -L usr/share/applications -type f 2>/dev/null )" != "" ] && \
	doinst_chk_command "update-desktop-database"

[ "$( find -L usr/share/glib-2.0/schemas -type f 2>/dev/null )" != "" ] && \
	doinst_chk_command "glib-compile-schemas"

[ "$( find -L usr/share/fonts -type f 2>/dev/null )" != "" ] && \
	doinst_chk_command "fc-cache"