pkgsrc/mk/pkginstall/icon-themes
prlw1 5c827f6f0e Essentially from OBATA Akio in private mail, June 2015:
Introduce Icon Theme cache handling framework

Icon Theme cache files are used by GTK+ and maintained with the
gtk-update-icon-cache tool.  Each Icon Theme package duplicates
its own maintainance scripts: only the specified icon theme directory
differs.  With this framework, if packages have ICON_THEMES=yes,
associated icon themes will be detected and their cache files will
be maintained automatically.

Change cache handling behaviour as follows:
* Icon theme caches will be updated if either gtk2+ or gtk3+
  gtk-update-icon-cache tool is available.
* With installation of gtk2+ package, not only hicolor icon theme but
  also any other icon theme cache files will be updated.
* Prevent removal of icon caches at deinstall, gtk3+ may be installed and
  using them.
* Ditto with gtk3+, gtk2+ may not be installed now, so caches must be
  maintained by gtk3+.
2017-06-14 16:23:09 +00:00

103 lines
2.1 KiB
Text

# $NetBSD: icon-themes,v 1.1 2017/06/14 16:23:09 prlw1 Exp $
#
# Generate an +ICON_THEMES script that handles the icon theme cache for
# the package.
#
case "${STAGE},$1" in
UNPACK,|UNPACK,+ICON_THEMES)
${CAT} > ./+ICON_THEMES << 'EOF'
#!@SH@
#
# +ICON_THEMES - icon theme cache management script
#
# Usage: ./+ICON_THEMES ADD|REMOVE [metadatadir]
#
# This script supports two actions, UPDATE and REMOVE, that will update or
# remove cache files for icon themes from the package associated with
# <metadatadir>.
#
# Lines starting with "# ICON_THEME: " are data read by this script that
# name the icon theme and directory containing the "index.theme".
#
# # ICON_THEME: hicolor
# # ICON_THEME: gnome
#
# For each ICON_THEME entry, if the path is relative, that it is taken to be
# relative to ${PKG_PREFIX}/share/icons.
#
ECHO="@ECHO@"
GREP="@GREP@"
INSTALL_INFO="@INSTALL_INFO@"
MKDIR="@MKDIR@"
PWD_CMD="@PWD_CMD@"
RM="@RM@"
RMDIR="@RMDIR@"
SED="@SED@"
SORT="@SORT@"
TEST="@TEST@"
GTK2_UPDATE_ICON_CACHE="@GTK2_UPDATE_ICON_CACHE@"
GTK3_UPDATE_ICON_CACHE="@GTK3_UPDATE_ICON_CACHE@"
: ${GTK_UPDATE_ICON_CACHE=@TRUE@}
SELF=$0
ACTION=$1
CURDIR=`${PWD_CMD}`
PKG_METADATA_DIR="${2-${CURDIR}}"
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
: ${PKG_PREFIX=@PREFIX@}
for _t in ${GTK3_UPDATE_ICON_CACHE} ${GTK2_UPDATE_ICON_CACHE}; do
if ${TEST} -x $_t; then
GTK_UPDATE_ICON_CACHE=$_t;
break;
fi
done
update_icon_cache()
{
_dir="$1"
if ${TEST} ! -f "$_dir/index.theme"; then
:
else
${GTK_UPDATE_ICON_CACHE} -f -q "$_dir"
fi
}
exitcode=0
case $ACTION in
UPDATE)
${SED} -n "/^\# ICON_THEME: /{s/^\# ICON_THEME: //;p;}" ${SELF} | \
${SORT} -u |
while read theme; do
case $theme in
"") continue ;;
[!/]*) theme="${PKG_PREFIX}/share/icons/$theme" ;;
esac
update_icon_cache $theme
done
;;
REMOVE)
${SED} -n "/^\# ICON_THEME: /{s/^\# ICON_THEME: //;p;}" ${SELF} | \
${SORT} -u |
while read theme; do
case $theme in
"") continue ;;
[!/]*) theme="${PKG_PREFIX}/share/icons/$theme" ;;
esac
${RM} -f "$theme/icon-theme.cache"
done
;;
esac
exit $exitcode
EOF
${SED} -n "/^\# ICON_THEME: /p" ${SELF} >> ./+ICON_THEMES
${CHMOD} +x ./+ICON_THEMES
;;
esac