Hello all.

Here is a working prototype of cache invalidating helper framework.
With it you can just add something like:

MODULES +=      updb
MODUPDB_WHAT =  desktop-files icons

and have all RUN_DEPENDS and @exec/@unexec-goo added to final plist
on the fly. Module is MULTI_PACKAGES aware but require small patch
to bsd.port.mk (see below). PKG_ARGS_TAIL is the same as PKG_ARGS
but is appended at the last; this way we get packaging list fragments
where they belong, at the end of the plist.

In the future I think it's possible to add automatic checks in plist
create/update stage, making make-plist warn when something is missed.

Comments and flames are welcome. :)

--
WBR,
Vadim Zhukov


Index: mk/bsd.port.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
retrieving revision 1.1183
diff -u -p -r1.1183 bsd.port.mk
--- mk/bsd.port.mk      4 Aug 2012 14:23:30 -0000       1.1183
+++ mk/bsd.port.mk      12 Aug 2012 17:56:02 -0000
@@ -993,6 +993,9 @@ PKG_ARGS${_S} += -A'${PKG_ARCH${_S}}'
 .  if !defined(_COMMENT${_S})
 ERRORS += "Fatal: Missing comment for ${_S:S/^-$/main package/}."
 .  endif
+
+PKG_ARGS${_S} += ${PKG_ARGS_TAIL}
+PKG_ARGS${_S} += ${PKG_ARGS_TAIL${_S}}
 .endfor
 
 GUNZIP_CMD ?= /usr/bin/gunzip -f
Index: mk/updb.port.mk
===================================================================
RCS file: mk/updb.port.mk
diff -N mk/updb.port.mk
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ mk/updb.port.mk     12 Aug 2012 17:56:02 -0000
@@ -0,0 +1,82 @@
+# $OpenBSD$
+# Simplify adding different "update-*" goo.
+# Written by Vadim Zhukov 2012, public domain
+#
+# How to use:
+# - Set MODUPDB_WHAT to a list of caches you want to invalidate/rebuild,
+#   list of possible names below.
+# - If any icon caches should be invalidated, set MODUPDB_ICON_THEMES to
+#   a list of themes to be updated. List is fixed, see below.
+#
+#
+# What                 Effect
+# =====================================================
+# desktop-files                Runs update-desktop-database
+# icons                        Runs gtk-update-icon-cache
+# mime                 Runs update-mime-database
+#
+#
+# Icon theme           Where
+# =====================================================
+# hicolor              ${PREFIX}/share/icons/hicolor
+# oxygen               ${PREFIX}/share/icons/oxygen
+# oxygen-colored       ${PREFIX}/share/icons/Oxygen_Black
+#                      ${PREFIX}/share/icons/Oxygen_Blue
+#                      ${PREFIX}/share/icons/Oxygen_White
+#                      ${PREFIX}/share/icons/Oxygen_Yellow
+#                      ${PREFIX}/share/icons/Oxygen_Zion
+#
+
+MODUPDB_WHAT ?=
+MODUPDB_ICON_THEMES ?=         hicolor
+_MODUPDB_PFRAG_BASE =          ${PORTSDIR}/infrastructure/plist
+
+# List of all cache types and corresponding RUN_DEPENDS for them
+_MODUPDB_DEPS_MAP = \
+       desktop-files   devel/desktop-file-utils \
+       icons           x11/gtk+2,-guic \
+       mime            misc/shared-mime-info \
+
+
+.if !defined(MULTI_PACKAGES) || empty(MULTI_PACKAGES)
+# Make users happy, do not use "-" subpackage to allow usual
+# "make show=RUN_DEPENDS" checks
+
+. for _what _dep in ${_MODUPDB_DEPS_MAP}
+.   if ${MODUPDB_WHAT:M${_what}}
+RUN_DEPENDS += ${_dep}
+
+.     if "${_what}" == "icons"
+.       for _t in ${MODUPDB_ICON_THEMES}
+PKG_ARGS_TAIL +=       -f ${_MODUPDB_PFRAG_BASE}/PFRAG.icons-${_t}
+.       endfor
+.     else
+PKG_ARGS_TAIL +=       -f ${_MODUPDB_PFRAG_BASE}/PFRAG.${_what}
+.     endif
+
+.   endif
+. endfor
+
+.else
+# Go thorugh subpackages as usual
+
+. for _s in ${MULTI_PACKAGES}
+MODUPDB_WHAT${_s} ?=           ${MODUPDB_WHAT}
+MODUPDB_ICON_THEMES${_s} ?=    ${MODUPDB_ICON_THEMES}
+
+.   for _what _dep in ${_MODUPDB_DEPS_MAP}
+.     if ${MODUPDB_WHAT${_s}:M${_what}}
+RUN_DEPENDS${_s} +=    ${_dep}
+
+.       if "${_what}" == "icons"
+.         for _t in ${MODUPDB_ICON_THEMES${_s}}
+PKG_ARGS_TAIL${_s} +=  -f ${_MODUPDB_PFRAG_BASE}/PFRAG.icons-${_t}
+.         endfor
+.       else
+PKG_ARGS_TAIL${_s} +=  -f ${_MODUPDB_PFRAG_BASE}/PFRAG.${_what}
+.       endif
+
+.     endif
+.   endfor
+. endfor
+.endif
Index: plist/PFRAG.desktop-files
===================================================================
RCS file: plist/PFRAG.desktop-files
diff -N plist/PFRAG.desktop-files
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ plist/PFRAG.desktop-files   12 Aug 2012 17:56:02 -0000
@@ -0,0 +1,2 @@
+@exec %D/bin/update-desktop-database
+@unexec-delete %D/bin/update-desktop-database
Index: plist/PFRAG.icons-hicolor
===================================================================
RCS file: plist/PFRAG.icons-hicolor
diff -N plist/PFRAG.icons-hicolor
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ plist/PFRAG.icons-hicolor   12 Aug 2012 17:56:02 -0000
@@ -0,0 +1,2 @@
+@exec %D/bin/gtk-update-icon-cache -q -t %D/share/icons/hicolor
+@unexec-delete %D/bin/gtk-update-icon-cache -q -t %D/share/icons/hicolor
Index: plist/PFRAG.icons-oxygen
===================================================================
RCS file: plist/PFRAG.icons-oxygen
diff -N plist/PFRAG.icons-oxygen
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ plist/PFRAG.icons-oxygen    12 Aug 2012 17:56:02 -0000
@@ -0,0 +1,2 @@
+@exec %D/bin/gtk-update-icon-cache -q -t %D/share/icons/oxygen
+@unexec-delete %D/bin/gtk-update-icon-cache -q -t %D/share/icons/oxygen
Index: plist/PFRAG.icons-oxygen-colored
===================================================================
RCS file: plist/PFRAG.icons-oxygen-colored
diff -N plist/PFRAG.icons-oxygen-colored
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ plist/PFRAG.icons-oxygen-colored    12 Aug 2012 17:56:02 -0000
@@ -0,0 +1,10 @@
+@exec %D/bin/gtk-update-icon-cache -q -t %D/share/icons/Oxygen_Black
+@unexec-delete %D/bin/gtk-update-icon-cache -q -t %D/share/icons/Oxygen_Black
+@exec %D/bin/gtk-update-icon-cache -q -t %D/share/icons/Oxygen_Blue
+@unexec-delete %D/bin/gtk-update-icon-cache -q -t %D/share/icons/Oxygen_Blue
+@exec %D/bin/gtk-update-icon-cache -q -t %D/share/icons/Oxygen_White
+@unexec-delete %D/bin/gtk-update-icon-cache -q -t %D/share/icons/Oxygen_White
+@exec %D/bin/gtk-update-icon-cache -q -t %D/share/icons/Oxygen_Yellow
+@unexec-delete %D/bin/gtk-update-icon-cache -q -t %D/share/icons/Oxygen_Yellow
+@exec %D/bin/gtk-update-icon-cache -q -t %D/share/icons/Oxygen_Zion
+@unexec-delete %D/bin/gtk-update-icon-cache -q -t %D/share/icons/Oxygen_Zion
Index: plist/PFRAG.mime
===================================================================
RCS file: plist/PFRAG.mime
diff -N plist/PFRAG.mime
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ plist/PFRAG.mime    12 Aug 2012 17:56:02 -0000
@@ -0,0 +1,2 @@
+@exec %D/bin/update-mime-database %D/share/mime
+@unexec-delete %D/bin/update-mime-database %D/share/mime

Reply via email to