eclass/xdg-utils: Sync with gentoo

It's from gentoo commit 99c24c9cd97877fe0a052f028061c177e066360c.
This commit is contained in:
Krzesimir Nowak 2021-12-21 10:59:55 +01:00
parent f99ffcd275
commit d69116590f

View File

@ -1,12 +1,13 @@
# Copyright 1999-2019 Gentoo Authors
# Copyright 2004-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: xdg-utils.eclass
# @MAINTAINER:
# gnome@gentoo.org
# freedesktop-bugs@gentoo.org
# @AUTHOR:
# Original author: Gilles Dartiguelongue <eva@gentoo.org>
# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
# @SUPPORTED_EAPIS: 5 6 7 8
# @BLURB: Auxiliary functions commonly used by XDG compliant packages.
# @DESCRIPTION:
# This eclass provides a set of auxiliary functions needed by most XDG
@ -16,9 +17,9 @@
# * XDG .desktop files cache management
# * XDG mime information database management
case "${EAPI:-0}" in
0|1|2|3|4|5|6|7) ;;
*) die "EAPI=${EAPI} is not supported" ;;
case ${EAPI} in
5|6|7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
# @ECLASS-VARIABLE: DESKTOP_DATABASE_DIR
@ -56,7 +57,7 @@ xdg_environment_reset() {
# Updates the .desktop files database.
# Generates a list of mimetypes linked to applications that can handle them
xdg_desktop_database_update() {
if [[ ${EBUILD_PHASE} != post* ]] ; then
if [[ ${EBUILD_PHASE} != post* ]]; then
die "xdg_desktop_database_update must be used in pkg_post* phases."
fi
@ -75,7 +76,7 @@ xdg_desktop_database_update() {
# Updates icon theme cache files under /usr/share/icons.
# This function should be called from pkg_postinst and pkg_postrm.
xdg_icon_cache_update() {
if [[ ${EBUILD_PHASE} != post* ]] ; then
if [[ ${EBUILD_PHASE} != post* ]]; then
die "xdg_icon_cache_update must be used in pkg_post* phases."
fi
@ -85,21 +86,17 @@ xdg_icon_cache_update() {
fi
ebegin "Updating icons cache"
local retval=0
local fails=( )
for dir in "${EROOT%/}"/usr/share/icons/*
do
if [[ -f "${dir}/index.theme" ]] ; then
local rv=0
gtk-update-icon-cache -qf "${dir}"
rv=$?
if [[ ! $rv -eq 0 ]] ; then
local dir retval=0
local fails=()
for dir in "${EROOT%/}"/usr/share/icons/*; do
if [[ -f ${dir}/index.theme ]]; then
if ! gtk-update-icon-cache -qf "${dir}"; then
debug-print "Updating cache failed on ${dir}"
# Add to the list of failures
fails+=( "${dir}" )
fails+=("${dir}")
retval=2
fi
elif [[ $(ls "${dir}") = "icon-theme.cache" ]]; then
elif [[ $(ls "${dir}") = icon-theme.cache ]]; then
# Clear stale cache files after theme uninstallation
rm "${dir}/icon-theme.cache"
fi
@ -109,8 +106,8 @@ xdg_icon_cache_update() {
fi
done
eend ${retval}
for f in "${fails[@]}" ; do
eerror "Failed to update cache with icon $f"
for dir in "${fails[@]}"; do
eerror "Failed to update cache with icon ${dir}"
done
}
@ -119,7 +116,7 @@ xdg_icon_cache_update() {
# Update the mime database.
# Creates a general list of mime types from several sources
xdg_mimeinfo_database_update() {
if [[ ${EBUILD_PHASE} != post* ]] ; then
if [[ ${EBUILD_PHASE} != post* ]]; then
die "xdg_mimeinfo_database_update must be used in pkg_post* phases."
fi
@ -128,6 +125,9 @@ xdg_mimeinfo_database_update() {
return
fi
# https://bugs.gentoo.org/819783
local -x PKGSYSTEM_ENABLE_FSYNC=0
ebegin "Updating shared mime info database"
update-mime-database "${EROOT%/}${MIMEINFO_DATABASE_DIR}"
eend $?