summaryrefslogtreecommitdiff
blob: 569633fe3e4e1a1e70bf734b6a4c8574767e0c36 (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
# check for missing calls to gnome2-utils regen functions

gnome2_icon_cache_check() {
	local d f all_files=() missing
	for d in usr/share/icons/*/; do
		# gnome2_icon_cache_update updates only themes with an index
		[[ -f ${d}/index.theme ]] || continue

		local files=() find_args=(
			# gtk-update-icon-cache supports only specific file
			# suffixes; match that to avoid false positives
			'(' -name '*.png' -o -name '*.svg'
				-o -name '*.xpm' -o -name '*.icon' ')'
		)
		# if the cache does not exist at all, we complain for any file
		# otherwise, we look for files newer than the cache
		[[ -f ${d}/icon-theme.cache ]] &&
			find_args+=( -newercm "${d}"/icon-theme.cache ) || missing=1

		# (use -mindepth 2 to easily skip the cache files)
		while read -r -d $'\0' f; do
			files+=( "${f}" )
		done < <(find "${d}" -mindepth 2 -type f "${find_args[@]}" -print0)

		# if any files were found, update the db to avoid repeating
		# the warning for subsequent packages
		if [[ ${files[@]} ]]; then
			all_files+=("${files[@]}")
			addwrite "${d}"
			gtk-update-icon-cache -qf "${d}"
		fi
	done

	# The eqatag call is prohibitively expensive if the cache is
	# missing and there are a large number of files.
	if [[ -z ${missing} && ${all_files[@]} ]]; then
		eqawarn "QA Notice: new icons were found installed but GTK+ icon cache"
		eqawarn "has not been updated:"
		eqatag -v gnome2-utils.icon-cache "${all_files[@]/#//}"
		eqawarn "Please make sure to call gnome2_icon_cache_update()"
		eqawarn "in pkg_postinst() and pkg_postrm() phases of appropriate pkgs."
	fi
}

gnome2_utils_postinst_check() {
	cd "${EROOT}" || die
	gnome2_icon_cache_check
}

gnome2_utils_postinst_check
: # guarantee successful exit

# vim:ft=sh