postinst-qa-check.d: fix false positive and expensive eqatag on first run

When caches were missing, calls to eqatag could be prohibitively
expensive when a large number of files where found. Those files
did not necessaryily belong to the current package, so it was
also a false positive.

Bug: https://bugs.gentoo.org/631454
diff --git a/bin/postinst-qa-check.d/50gnome2-utils b/bin/postinst-qa-check.d/50gnome2-utils
index 077a049..eb045ea 100644
--- a/bin/postinst-qa-check.d/50gnome2-utils
+++ b/bin/postinst-qa-check.d/50gnome2-utils
@@ -1,7 +1,7 @@
 # check for missing calls to gnome2-utils regen functions
 
 gnome2_icon_cache_check() {
-	local d f all_files=() find_args
+	local d f all_files=() find_args missing
 	for d in usr/share/icons/*/; do
 		# gnome2_icon_cache_update updates only themes with an index
 		[[ -f ${d}/index.theme ]] || continue
@@ -15,7 +15,7 @@
 		# 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 )
+			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
@@ -33,7 +33,9 @@
 		fi
 	done
 
-	if [[ ${all_files[@]} ]]; then
+	# 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[@]/#//}"
diff --git a/bin/postinst-qa-check.d/50xdg-utils b/bin/postinst-qa-check.d/50xdg-utils
index 410aceb..ca4b49f 100644
--- a/bin/postinst-qa-check.d/50xdg-utils
+++ b/bin/postinst-qa-check.d/50xdg-utils
@@ -1,7 +1,7 @@
 # check for missing calls to xdg-utils regen functions
 
 xdg_desktop_database_check() {
-	local d f files=()
+	local d f files=() missing
 	for d in usr/share/applications; do
 		[[ -d ${d} ]] || continue
 
@@ -9,7 +9,7 @@
 		# if the cache does not exist at all, we complain for any file
 		# otherwise, we look for files newer than the cache
 		[[ -f ${d}/mimeinfo.cache ]] &&
-			find_args+=( -newercm "${d}"/mimeinfo.cache )
+			find_args+=( -newercm "${d}"/mimeinfo.cache ) || missing=1
 
 		# look for any .desktop files that are newer than the cache
 		# and that have any mime types defined
@@ -29,7 +29,9 @@
 		fi
 	done
 
-	if [[ ${all_files[@]} ]]; then
+	# 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: .desktop files with MimeType= were found installed"
 		eqawarn "but desktop mimeinfo cache has not been updated:"
 		eqatag -v xdg-utils.desktop "${all_files[@]/#//}"
@@ -39,7 +41,7 @@
 }
 
 xdg_mimeinfo_database_check() {
-	local d f files=()
+	local d f files=() missing
 	for d in usr/share/mime; do
 		[[ -d ${d} ]] || continue
 
@@ -47,7 +49,7 @@
 		# if the cache does not exist at all, we complain for any file
 		# otherwise, we look for files newer than the cache
 		[[ -f ${d}/mime.cache ]] &&
-			find_args+=( -newercm "${d}"/mime.cache )
+			find_args+=( -newercm "${d}"/mime.cache ) || missing=1
 
 		while read -r -d $'\0' f; do
 			files+=( "${f}" )
@@ -64,7 +66,9 @@
 		fi
 	done
 
-	if [[ ${all_files[@]} ]]; then
+	# 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: mime-info files were found installed but mime-info"
 		eqawarn "cache has not been updated:"
 		eqatag -v xdg-utils.mime-info "${all_files[@]/#//}"