commit:     361f820b88deda2840396d11c8c8a462dfb435a7
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 19 23:10:04 2017 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Sep 19 23:26:32 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=361f820b

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

 bin/postinst-qa-check.d/50gnome2-utils |  8 +++++---
 bin/postinst-qa-check.d/50xdg-utils    | 16 ++++++++++------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/bin/postinst-qa-check.d/50gnome2-utils 
b/bin/postinst-qa-check.d/50gnome2-utils
index 077a04918..eb045ea78 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 @@ gnome2_icon_cache_check() {
                # 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 @@ gnome2_icon_cache_check() {
                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 410aceb88..ca4b49fe4 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 @@ xdg_desktop_database_check() {
                # 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 @@ xdg_desktop_database_check() {
                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_desktop_database_check() {
 }
 
 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 @@ xdg_mimeinfo_database_check() {
                # 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 @@ xdg_mimeinfo_database_check() {
                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[@]/#//}"

Reply via email to