Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 632688 - postinst-qa-check.d/50gnome2-utils: gnome2_icon_cache_check(): Broken behavior in case of missing icon-theme.cache
Summary: postinst-qa-check.d/50gnome2-utils: gnome2_icon_cache_check(): Broken behavio...
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-02 11:54 UTC by Arfrever Frehtes Taifersar Arahesis
Modified: 2017-10-02 16:13 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch (portage.patch,4.45 KB, patch)
2017-10-02 14:50 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arfrever Frehtes Taifersar Arahesis 2017-10-02 11:54:10 UTC
In postinst-qa-check.d/50gnome2-utils, gnome2_icon_cache_check() checks all /usr/share/icons/* directories.
icon-theme.cache can be missing in some directories and not in others.
In this situation, missing=1 will be set and QA warning will not be printed.


In postinst-qa-check.d/50xdg-utils, xdg_desktop_database_check() and xdg_mimeinfo_database_check() theoretically also have this problem, but currently each of them checks only 1 directory.


For example, kde-plasma/breeze-5.10.5 installs /usr/share/icons/Breeze_Snow and /usr/share/icons/breeze_cursors directories with some files.
/usr/share/icons/Breeze_Snow/index.theme and /usr/share/icons/breeze_cursors/index.theme exist and are owned by kde-plasma/breeze-5.10.5.
However /usr/share/icons/Breeze_Snow/icon-theme.cache and /usr/share/icons/breeze_cursors/icon-theme.cache do not exist.
/usr/share/icons/Breeze_Snow and /usr/share/icons/breeze_cursors contain 0 *.png or *.svg or *.xpm or *.icon files, so kde-plasma/breeze-5.10.5 does not need to be fixed (e.g. by calling gnome2_icon_cache_update() in this package).
Comment 1 Arfrever Frehtes Taifersar Arahesis 2017-10-02 14:49:09 UTC
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #0)
> kde-plasma/breeze-5.10.5 does not need to be fixed (e.g. by calling
> gnome2_icon_cache_update() in this package).

Actually kde5_pkg_postinst() already calls gnome2_icon_cache_update(), but /usr/bin/gtk-update-icon-cache simply does not create icon-theme.cache in directories without files supported by gtk-update-icon-cache.
Comment 2 Arfrever Frehtes Taifersar Arahesis 2017-10-02 14:50:07 UTC
Created attachment 497418 [details, diff]
Patch
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-10-02 15:31:42 UTC

*** This bug has been marked as a duplicate of bug 631820 ***
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-10-02 15:33:10 UTC
Sorry, wrong bug.
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-10-02 15:39:56 UTC
Comment on attachment 497418 [details, diff]
Patch

>diff --git a/bin/postinst-qa-check.d/50gnome2-utils b/bin/postinst-qa-check.d/50gnome2-utils
>index 569633fe3..0d09363c5 100644
>--- a/bin/postinst-qa-check.d/50gnome2-utils
>+++ b/bin/postinst-qa-check.d/50gnome2-utils
>@@ -14,8 +14,12 @@ 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 ) || missing=1
>+		if [[ -f ${d}/icon-theme.cache ]]; then
>+			find_args+=( -newercm "${d}"/icon-theme.cache )
>+			missing=0
>+		else
>+			missing=1
>+		fi
> 
> 		# (use -mindepth 2 to easily skip the cache files)
> 		while read -r -d $'\0' f; do
>@@ -25,15 +29,18 @@ gnome2_icon_cache_check() {
> 		# 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}"
>+
>+			# The eqatag call is prohibitively expensive if the cache is
>+			# missing and there is a large number of files.
>+			if [[ ${missing} == 0 || ${#files[@]} -lt 100 ]]; then

What's that arbitrary limit of 100 files? So if a package installs more than 100 files, then we do not report that it's broken because...?

>+				all_files+=("${files[@]}")
>+			fi
> 		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
>+	if [[ ${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 9164f8dc1..9c156248f 100644
>--- a/bin/postinst-qa-check.d/50xdg-utils
>+++ b/bin/postinst-qa-check.d/50xdg-utils
>@@ -8,8 +8,12 @@ xdg_desktop_database_check() {
> 		local files=() find_args=()
> 		# 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 ) || missing=1
>+		if [[ -f ${d}/mimeinfo.cache ]]; then
>+			find_args+=( -newercm "${d}"/mimeinfo.cache )
>+			missing=0
>+		else
>+			missing=1
>+		fi
> 
> 		# look for any .desktop files that are newer than the cache
> 		# and that have any mime types defined
>@@ -21,15 +25,18 @@ xdg_desktop_database_check() {
> 		# if any files were found, update the db to avoid repeating
> 		# the warning for subsequent packages
> 		if [[ ${files[@]} ]]; then
>-			all_files+=("${files[@]}")
> 			addwrite "${d}"
> 			update-desktop-database "${d}"
>+
>+			# The eqatag call is prohibitively expensive if the cache is
>+			# missing and there is a large number of files.
>+			if [[ ${missing} == 0 || ${#files[@]} -lt 100 ]]; then
>+				all_files+=("${files[@]}")
>+			fi
> 		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
>+	if [[ ${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[@]/#//}"
>@@ -46,8 +53,12 @@ xdg_mimeinfo_database_check() {
> 		local files=() find_args=()
> 		# 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 ) || missing=1
>+		if [[ -f ${d}/mime.cache ]]; then
>+			find_args+=( -newercm "${d}"/mime.cache )
>+			missing=0
>+		else
>+			missing=1
>+		fi
> 
> 		while read -r -d $'\0' f; do
> 			files+=( "${f}" )
>@@ -56,15 +67,18 @@ xdg_mimeinfo_database_check() {
> 		# if any files were found, update the db to avoid repeating
> 		# the warning for subsequent packages
> 		if [[ ${files[@]} ]]; then
>-			all_files+=("${files[@]}")
> 			addwrite "${d}"
> 			update-mime-database "${d}"
>+
>+			# The eqatag call is prohibitively expensive if the cache is
>+			# missing and there is a large number of files.
>+			if [[ ${missing} == 0 || ${#files[@]} -lt 100 ]]; then
>+				all_files+=("${files[@]}")
>+			fi
> 		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
>+	if [[ ${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[@]/#//}"

Also, please include submit a pull request or include more context in your patches. Without context, this patch review workflow is useless.
Comment 6 Arfrever Frehtes Taifersar Arahesis 2017-10-02 15:51:57 UTC
(In reply to Michał Górny from comment #5)
> >@@ -25,15 +29,18 @@ gnome2_icon_cache_check() {
> > 		# 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}"
> >+
> >+			# The eqatag call is prohibitively expensive if the cache is
> >+			# missing and there is a large number of files.
> >+			if [[ ${missing} == 0 || ${#files[@]} -lt 100 ]]; then
> 
> What's that arbitrary limit of 100 files? So if a package installs more than
> 100 files, then we do not report that it's broken because...?

I moved a pre-existing comment talking about "a large number of files".
Maybe 100 is reasonable limit for "a large number of files".
When icon-theme.cache is not missing, then this limit is not used anyway.

> 
> >+				all_files+=("${files[@]}")
> >+			fi
> > 		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
> >+	if [[ ${all_files[@]} ]]; then
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-10-02 15:54:42 UTC
The point is, if the cache is missing, then the result will be incorrect anyway.
Comment 8 Arfrever Frehtes Taifersar Arahesis 2017-10-02 16:13:53 UTC
Maybe it would be better to create intersection of set of files found by that 'find' command and set of files installed by given package. And to report all files from this intersection even when icon-theme.cache is missing.