diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2019-02-16 12:59:29 +0000 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2019-02-16 12:59:29 +0000 |
commit | 79599515788b85b18aa655e7b7f8cc05c1bbddd8 (patch) | |
tree | ade7cb031f363fad64c77139dea7aa3d81908537 /eclass/xdg-utils.eclass | |
parent | 6bc2e4d7c5906e46a8f275a876ead6ec41aca5bb (diff) |
gentoo resync : 16.02.1018
Diffstat (limited to 'eclass/xdg-utils.eclass')
-rw-r--r-- | eclass/xdg-utils.eclass | 75 |
1 files changed, 52 insertions, 23 deletions
diff --git a/eclass/xdg-utils.eclass b/eclass/xdg-utils.eclass index fe1eef213ea4..f5121830d888 100644 --- a/eclass/xdg-utils.eclass +++ b/eclass/xdg-utils.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2017 Gentoo Foundation +# Copyright 1999-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: xdg-utils.eclass @@ -12,6 +12,7 @@ # This eclass provides a set of auxiliary functions needed by most XDG # compliant packages. # It provides XDG stack related functions such as: +# * GTK/Qt5 icon theme cache management # * XDG .desktop files cache management # * XDG mime information database management @@ -20,24 +21,12 @@ case "${EAPI:-0}" in *) die "EAPI=${EAPI} is not supported" ;; esac -# @ECLASS-VARIABLE: DESKTOP_DATABASE_UPDATE_BIN -# @INTERNAL -# @DESCRIPTION: -# Path to update-desktop-database -: ${DESKTOP_DATABASE_UPDATE_BIN:="/usr/bin/update-desktop-database"} - # @ECLASS-VARIABLE: DESKTOP_DATABASE_DIR # @INTERNAL # @DESCRIPTION: # Directory where .desktop files database is stored : ${DESKTOP_DATABASE_DIR="/usr/share/applications"} -# @ECLASS-VARIABLE: MIMEINFO_DATABASE_UPDATE_BIN -# @INTERNAL -# @DESCRIPTION: -# Path to update-mime-database -: ${MIMEINFO_DATABASE_UPDATE_BIN:="/usr/bin/update-mime-database"} - # @ECLASS-VARIABLE: MIMEINFO_DATABASE_DIR # @INTERNAL # @DESCRIPTION: @@ -67,39 +56,79 @@ xdg_environment_reset() { # Updates the .desktop files database. # Generates a list of mimetypes linked to applications that can handle them xdg_desktop_database_update() { - local updater="${EROOT%/}${DESKTOP_DATABASE_UPDATE_BIN}" - if [[ ${EBUILD_PHASE} != post* ]] ; then die "xdg_desktop_database_update must be used in pkg_post* phases." fi - if [[ ! -x "${updater}" ]] ; then - debug-print "${updater} is not executable" + if ! type update-desktop-database &>/dev/null; then + debug-print "update-desktop-database is not found" return fi ebegin "Updating .desktop files database" - "${updater}" -q "${EROOT%/}${DESKTOP_DATABASE_DIR}" + update-desktop-database -q "${EROOT%/}${DESKTOP_DATABASE_DIR}" eend $? } +# @FUNCTION: xdg_icon_cache_update +# @DESCRIPTION: +# 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 + die "xdg_icon_cache_update must be used in pkg_post* phases." + fi + + if ! type gtk-update-icon-cache &>/dev/null; then + debug-print "gtk-update-icon-cache is not found" + return + 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 + debug-print "Updating cache failed on ${dir}" + # Add to the list of failures + fails+=( "${dir}" ) + retval=2 + fi + elif [[ $(ls "${dir}") = "icon-theme.cache" ]]; then + # Clear stale cache files after theme uninstallation + rm "${dir}/icon-theme.cache" + fi + if [[ -z $(ls "${dir}") ]]; then + # Clear empty theme directories after theme uninstallation + rmdir "${dir}" + fi + done + eend ${retval} + for f in "${fails[@]}" ; do + eerror "Failed to update cache with icon $f" + done +} + # @FUNCTION: xdg_mimeinfo_database_update # @DESCRIPTION: # Update the mime database. # Creates a general list of mime types from several sources xdg_mimeinfo_database_update() { - local updater="${EROOT%/}${MIMEINFO_DATABASE_UPDATE_BIN}" - if [[ ${EBUILD_PHASE} != post* ]] ; then die "xdg_mimeinfo_database_update must be used in pkg_post* phases." fi - if [[ ! -x "${updater}" ]] ; then - debug-print "${updater} is not executable" + if ! type update-mime-database &>/dev/null; then + debug-print "update-mime-database is not found" return fi ebegin "Updating shared mime info database" - "${updater}" "${EROOT%/}${MIMEINFO_DATABASE_DIR}" + update-mime-database "${EROOT%/}${MIMEINFO_DATABASE_DIR}" eend $? } |