summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorprlw1 <prlw1@pkgsrc.org>2017-06-14 16:23:09 +0000
committerprlw1 <prlw1@pkgsrc.org>2017-06-14 16:23:09 +0000
commit8dd99e554e1fc3d7fdf0d84d40203778c90bcbe4 (patch)
tree82615598735fe5be3f7419c4692fccd58adb04ed /mk
parent7b3176e84991c07b2d32b6b091b7e2b72453cf87 (diff)
downloadpkgsrc-8dd99e554e1fc3d7fdf0d84d40203778c90bcbe4.tar.gz
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+.
Diffstat (limited to 'mk')
-rw-r--r--mk/check/check-files.mk7
-rw-r--r--mk/pkginstall/bsd.pkginstall.mk58
-rw-r--r--mk/pkginstall/deinstall12
-rw-r--r--mk/pkginstall/icon-themes103
-rw-r--r--mk/pkginstall/install8
-rw-r--r--mk/plist/plist.mk8
-rw-r--r--mk/plist/print-plist.mk5
7 files changed, 195 insertions, 6 deletions
diff --git a/mk/check/check-files.mk b/mk/check/check-files.mk
index 1f5af8012d7..4f06adcd359 100644
--- a/mk/check/check-files.mk
+++ b/mk/check/check-files.mk
@@ -1,4 +1,4 @@
-# $NetBSD: check-files.mk,v 1.34 2017/06/01 02:15:10 jlam Exp $
+# $NetBSD: check-files.mk,v 1.35 2017/06/14 16:23:09 prlw1 Exp $
#
# This file checks that the list of installed files matches the PLIST.
# For that purpose it records the file list of LOCALBASE before and
@@ -101,6 +101,11 @@ CHECK_FILES_SKIP+= ${PREFIX}/.*/fonts.scale
CHECK_FILES_SKIP+= ${PREFIX}/.*/fonts.cache-1
.endif
+# Mutable icon theme cache files
+.if !empty(ICON_THEMES:M[Yy][Ee][Ss])
+CHECK_FILES_SKIP+= ${PREFIX}/share/icons/.*/icon-theme.cache
+.endif
+
# Mutable charset.alias file
CHECK_FILES_SKIP+= ${PREFIX}/lib/charset.alias
diff --git a/mk/pkginstall/bsd.pkginstall.mk b/mk/pkginstall/bsd.pkginstall.mk
index f99f2c0f418..93b6230aab5 100644
--- a/mk/pkginstall/bsd.pkginstall.mk
+++ b/mk/pkginstall/bsd.pkginstall.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkginstall.mk,v 1.70 2017/06/01 13:29:18 jlam Exp $
+# $NetBSD: bsd.pkginstall.mk,v 1.71 2017/06/14 16:23:09 prlw1 Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and implements the
# common INSTALL/DEINSTALL scripts framework. To use the pkginstall
@@ -47,6 +47,7 @@ _PKG_VARS.pkginstall+= \
PKG_SYSCONFDIR_PERMS \
PKG_SHELL \
FONTS_DIRS.ttf FONTS_DIRS.type1 FONTS_DIRS.x11 \
+ ICON_THEMES
_SYS_VARS.pkginstall= \
SETUID_ROOT_PERMS \
SETGID_GAMES_PERMS \
@@ -965,6 +966,61 @@ ${_INSTALL_FONTS_FILE}: ../../mk/pkginstall/fonts
${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
fi
+# ICON_THEMES indicates whether icon theme cache files should be automatically
+# updated with the gtk-update-con-cache tool from a GTK+ package if available.
+# It is either YES or NO and defaults to NO.
+#
+ICON_THEMES?= NO
+
+_INSTALL_ICON_THEMES_FILE= ${_PKGINSTALL_DIR}/icon-themes
+_INSTALL_ICON_THEMES_DATAFILE= ${_PKGINSTALL_DIR}/icon-themes-data
+_INSTALL_UNPACK_TMPL+= ${_INSTALL_ICON_THEMES_FILE}
+_INSTALL_DATA_TMPL+= ${_INSTALL_ICON_THEMES_DATAFILE}
+
+# The icon theme cache is used by GTK+2 and GTK3+ applications.
+# List their update-icon-cache tools.
+#
+.if !empty(ICON_THEMES:M[Yy][Ee][Ss])
+FILES_SUBST+= GTK2_UPDATE_ICON_CACHE=${LOCALBASE}/bin/gtk2-update-icon-cache
+FILES_SUBST+= GTK3_UPDATE_ICON_CACHE=${LOCALBASE}/bin/gtk-update-icon-cache
+.endif
+
+${_INSTALL_ICON_THEMES_DATAFILE}:
+ ${RUN}${MKDIR} ${.TARGET:H}
+ ${RUN}${RM} -f ${.TARGET}
+ ${RUN}${TOUCH} ${TOUCH_ARGS} ${.TARGET}
+
+.if !empty(ICON_THEMES:M[Yy][Ee][Ss])
+.PHONY: install-script-data-icon-themes
+install-script-data: install-script-data-icon-themes
+install-script-data-icon-themes:
+ ${RUN}${_FUNC_STRIP_PREFIX}; \
+ if ${TEST} -x ${INSTALL_FILE}; then \
+ ${ICON_THEMES_cmd} | \
+ while read theme; do \
+ theme=`strip_prefix "$$theme"`; \
+ ${ECHO} "# ICON_THEME: $$theme" \
+ >> ${INSTALL_FILE}; \
+ done; \
+ cd ${PKG_DB_TMPDIR} && ${PKGSRC_SETENV} ${INSTALL_SCRIPTS_ENV} \
+ ${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} \
+ UNPACK +ICON_THEMES; \
+ fi
+.endif
+
+${_INSTALL_ICON_THEMES_FILE}: ${_INSTALL_ICON_THEMES_DATAFILE}
+${_INSTALL_ICON_THEMES_FILE}: ../../mk/pkginstall/icon-themes
+ ${RUN}${MKDIR} ${.TARGET:H}
+ ${RUN} \
+ ${SED} ${FILES_SUBST_SED} ../../mk/pkginstall/icon-themes > ${.TARGET}
+.if empty(ICON_THEMES:M[Yy][Ee][Ss])
+ ${RUN} \
+ if ${_ZERO_FILESIZE_P} ${_INSTALL_ICON_THEMES_DATAFILE}; then \
+ ${RM} -f ${.TARGET}; \
+ ${TOUCH} ${TOUCH_ARGS} ${.TARGET}; \
+ fi
+.endif
+
# PKG_CREATE_USERGROUP indicates whether the INSTALL script should
# automatically add any needed users/groups to the system using
# useradd/groupadd. It is either YES or NO and defaults to YES.
diff --git a/mk/pkginstall/deinstall b/mk/pkginstall/deinstall
index cdfb00be2c7..ad5fc5cfe4f 100644
--- a/mk/pkginstall/deinstall
+++ b/mk/pkginstall/deinstall
@@ -1,4 +1,4 @@
-# $NetBSD: deinstall,v 1.4 2016/04/12 15:52:29 jaapb Exp $
+# $NetBSD: deinstall,v 1.5 2017/06/14 16:23:09 prlw1 Exp $
case ${STAGE} in
DEINSTALL)
@@ -14,6 +14,11 @@ DEINSTALL)
${TEST} ! -x ./+INFO_FILES ||
./+INFO_FILES REMOVE ${PKG_METADATA_DIR}
#
+ # Remove any icon theme caches.
+ #
+ ${TEST} ! -x ./+ICON_THEMES ||
+ ./+ICON_THEMES REMOVE ${PKG_METADATA_DIR}
+ #
# Remove shells from /etc/shells.
#
${TEST} ! -x ./+SHELL ||
@@ -35,6 +40,11 @@ POST-DEINSTALL)
${TEST} ! -x ./+FONTS ||
./+FONTS ${PKG_METADATA_DIR}
#
+ # Update any icon theme caches.
+ #
+ ${TEST} ! -x ./+ICON_THEMES ||
+ ./+ICON_THEMES UPDATE ${PKG_METADATA_DIR}
+ #
# Rebuild the system run-time library search path database.
#
${TEST} ! -x ./+SHLIBS ||
diff --git a/mk/pkginstall/icon-themes b/mk/pkginstall/icon-themes
new file mode 100644
index 00000000000..42d0c6c2c2a
--- /dev/null
+++ b/mk/pkginstall/icon-themes
@@ -0,0 +1,103 @@
+# $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
+
diff --git a/mk/pkginstall/install b/mk/pkginstall/install
index 0304b4ebc17..2edaf97032a 100644
--- a/mk/pkginstall/install
+++ b/mk/pkginstall/install
@@ -1,4 +1,4 @@
-# $NetBSD: install,v 1.4 2016/04/12 15:52:29 jaapb Exp $
+# $NetBSD: install,v 1.5 2017/06/14 16:23:09 prlw1 Exp $
case ${STAGE} in
PRE-INSTALL)
@@ -47,6 +47,12 @@ POST-INSTALL)
${TEST} ! -x ./+FONTS ||
./+FONTS ${PKG_METADATA_DIR}
+ #
+ # Update any icon theme caches.
+ #
+ ${TEST} ! -x ./+ICON_THEMES ||
+ ./+ICON_THEMES UPDATE ${PKG_METADATA_DIR}
+
# Check for any missing bits after we're finished installing.
#
${TEST} ! -x ./+DIRS ||
diff --git a/mk/plist/plist.mk b/mk/plist/plist.mk
index d003a52fe8c..e26d8cda3fd 100644
--- a/mk/plist/plist.mk
+++ b/mk/plist/plist.mk
@@ -1,4 +1,4 @@
-# $NetBSD: plist.mk,v 1.49 2015/07/04 16:18:38 joerg Exp $
+# $NetBSD: plist.mk,v 1.50 2017/06/14 16:23:09 prlw1 Exp $
#
# This Makefile fragment handles the creation of PLISTs for use by
# pkg_create(8).
@@ -283,6 +283,12 @@ INFO_FILES_cmd= \
${AWK} '($$0 !~ "-[0-9]*(\\.gz)?$$") { print }'
.endif
+ICON_THEMES_cmd= \
+ ${CAT} ${PLIST} | \
+ ${PKGSRC_SETENV} ${_PLIST_AWK_ENV} ${AWK} -F / \
+ '$$0 ~ "^share/icons/[^/]+/.*$$" { print $$3 }' | \
+ ${SORT} -u
+
######################################################################
### plist-clean (PRIVATE)
######################################################################
diff --git a/mk/plist/print-plist.mk b/mk/plist/print-plist.mk
index d269bf357eb..aba0ee1548f 100644
--- a/mk/plist/print-plist.mk
+++ b/mk/plist/print-plist.mk
@@ -1,4 +1,4 @@
-# $NetBSD: print-plist.mk,v 1.32 2016/07/25 21:57:23 wiz Exp $
+# $NetBSD: print-plist.mk,v 1.33 2017/06/14 16:23:09 prlw1 Exp $
###
### Automatic PLIST generation
@@ -43,6 +43,9 @@ _PRINT_PLIST_AWK_IGNORE+= || ($$0 ~ /^.*\/fonts\.scale/)
(defined(FONTS_DIRS.x11) && !empty(FONTS_DIRS.x11:M*))
_PRINT_PLIST_AWK_IGNORE+= || ($$0 ~ /^.*\/fonts\.cache-1/)
.endif
+.if defined(ICON_THEMES)
+_PRINT_PLIST_AWK_IGNORE+= || ($$0 ~ /^share\/icons\/*\/icon-theme\.cache$$/)
+.endif
# List the content of $PREFIX and emit "@pkgdir " statements for
# empty directories.