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