diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2021-10-11 07:46:55 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2021-11-17 09:47:29 +0000 |
commit | 37c1a83366f02cdf76b850c630f79c275a418bea (patch) | |
tree | 9877de52846c43f1fd182402aec6e64925986ac3 | |
parent | fca135644fd02bc1e2c81dc59f61c93148f64d5d (diff) | |
download | ports-37c1a83366f02cdf76b850c630f79c275a418bea.tar.gz ports-37c1a83366f02cdf76b850c630f79c275a418bea.zip |
devel/desktop-file-utils: use trigger
Instead of polluting all files with a script to be executed post install
convert the handling of mime database into a trigger
This trigger will regenerate the db each time someone install a files
into the concern directory
On removal of the desktop-file-utils port, it will cleanup its cache.
While here convert the post installation script into a lua script.
Note the db is always run at post installation of the port, just to make
sure the cache is up to date, in case the format changes in the futur
-rw-r--r-- | devel/desktop-file-utils/Makefile | 14 | ||||
-rw-r--r-- | devel/desktop-file-utils/files/desktop-file-utils.ucl.in | 24 | ||||
-rw-r--r-- | devel/desktop-file-utils/files/pkg-deinstall.in | 15 | ||||
-rw-r--r-- | devel/desktop-file-utils/files/pkg-install.in | 11 | ||||
-rw-r--r-- | devel/desktop-file-utils/files/pkg-post-install.lua.in | 2 |
5 files changed, 31 insertions, 35 deletions
diff --git a/devel/desktop-file-utils/Makefile b/devel/desktop-file-utils/Makefile index ff765677b064..4a83a8eab39a 100644 --- a/devel/desktop-file-utils/Makefile +++ b/devel/desktop-file-utils/Makefile @@ -2,6 +2,7 @@ PORTNAME= desktop-file-utils PORTVERSION= 0.26 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= http://freedesktop.org/software/${PORTNAME}/releases/ @@ -11,18 +12,13 @@ COMMENT= Couple of command line utilities for working with desktop entries LICENSE= GPLv2+ LICENSE_FILE= ${WRKSRC}/COPYING -USES= compiler:c11 gettext meson gnome pkgconfig tar:xz +USES= compiler:c11 gettext meson gnome pkgconfig trigger tar:xz USE_GNOME= glib20 -PKGINSTALL= ${WRKDIR}/pkg-install -PKGDEINSTALL= ${WRKDIR}/pkg-deinstall - -PORT_MIMEDIRS= ${LOCALBASE}/share/applications - -MIMEDIRS= ${PORT_MIMEDIRS} - -SUB_FILES= pkg-deinstall pkg-install +MIMEDIRS= share/applications SUB_LIST= MIMEDIRS="${MIMEDIRS}" +PKGPOSTINSTALL= ${WRKDIR}/pkg-post-install +SUB_FILES= pkg-post-install.lua post-install: ${INSTALL_DATA} ${WRKSRC}/misc/desktop-entry-mode.el \ diff --git a/devel/desktop-file-utils/files/desktop-file-utils.ucl.in b/devel/desktop-file-utils/files/desktop-file-utils.ucl.in new file mode 100644 index 000000000000..ed07df4f223f --- /dev/null +++ b/devel/desktop-file-utils/files/desktop-file-utils.ucl.in @@ -0,0 +1,24 @@ +path: "%%PREFIX%%/%%MIMEDIRS%%" +cleanup: { + type: lua + script: <<EOS +local mimedir = "%%PREFIX%%/%%MIMEDIRS%%/" +local cache = mimedir .. "mimeinfo.cache" +local st = pkg.stat(cache) +if st then + os.remove(cache) +end +local res = pkg.readdir(mimedir) +if #res == 0 then + os.remove(mimrdir) +end +EOS +} +trigger: { + type: lua + sandbox: false + script: <<EOS +print("Building cache database of MIME types") +pkg.exec({"%%PREFIX%%/bin/update-desktop-database","-q"}) +EOS +} diff --git a/devel/desktop-file-utils/files/pkg-deinstall.in b/devel/desktop-file-utils/files/pkg-deinstall.in deleted file mode 100644 index 1052c08f1529..000000000000 --- a/devel/desktop-file-utils/files/pkg-deinstall.in +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# -# Remove leftover mimeinfo.cache files. - -if [ "$2" != "POST-DEINSTALL" ]; then - exit 0 -fi - -for mdir in %%MIMEDIRS%%; do - if [ -f ${mdir}/mimeinfo.cache ]; then - rm -f ${mdir}/mimeinfo.cache - fi -done - -exit 0 diff --git a/devel/desktop-file-utils/files/pkg-install.in b/devel/desktop-file-utils/files/pkg-install.in deleted file mode 100644 index 8de802b51f15..000000000000 --- a/devel/desktop-file-utils/files/pkg-install.in +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# -# Initialize the desktop directories and MIME cache. - -if [ "$2" != "POST-INSTALL" ]; then - exit 0 -fi - -${PKG_PREFIX}/bin/update-desktop-database -q - -exit 0 diff --git a/devel/desktop-file-utils/files/pkg-post-install.lua.in b/devel/desktop-file-utils/files/pkg-post-install.lua.in new file mode 100644 index 000000000000..0aec3ae32570 --- /dev/null +++ b/devel/desktop-file-utils/files/pkg-post-install.lua.in @@ -0,0 +1,2 @@ +print("Building cache database of MIME types") +pkg.exec({"%%PREFIX%%/bin/update-desktop-database", "-q"}) |