shared-mime-info: use triggers

the rebuild of the database is now handled by a trigger and happen only
once at the end of the transaction instead of after each package
installation.

While make shared-mime-info a runtime only dependency

Reviewed by:	manu, mat
Differential Revision:	https://reviews.freebsd.org/D32452
This commit is contained in:
Baptiste Daroussin 2021-10-11 11:31:35 +02:00
parent 9bf3f59966
commit ddacf99b4f
6 changed files with 48 additions and 54 deletions

View file

@ -1,9 +0,0 @@
# MAINTAINER: gnome@FreeBSD.org
actions: []
post-install: <<EOD
update-mime-database %D/%@ || true
EOD
post-deinstall: <<EOD
update-mime-database %D/%@ || true
EOD

View file

@ -13,8 +13,6 @@ _INCLUDE_USES_SHARED_MIME_INFO_MK= yes
IGNORE= USES=shared-mime-info does not require args
.endif
BUILD_DEPENDS+= update-mime-database:misc/shared-mime-info
RUN_DEPENDS+= update-mime-database:misc/shared-mime-info
PLIST_FILES+= "@shared-mime-info share/mime"
.endif

View file

@ -2,6 +2,7 @@
PORTNAME= shared-mime-info
DISTVERSION= 2.0
PORTREVISION= 1
CATEGORIES= misc gnome
MAINTAINER= desktop@FreeBSD.org
@ -14,7 +15,8 @@ BUILD_DEPENDS= gmake:devel/gmake \
itstool:textproc/itstool \
minixmlto:textproc/minixmlto
USES= gettext gnome localbase meson pathfix pkgconfig shebangfix tar:xz
USES= gettext gnome localbase meson pathfix pkgconfig shebangfix \
tar:xz trigger
CONFIGURE_ARGS= -Dupdate-mimedb=false \
-Dxdgmime-path=${WRKSRC}/src/xdgmime
USE_GNOME= glib20 libxml2
@ -27,13 +29,8 @@ GL_TUPLE= xdg:xdgmime:6663a2288d11b37bc07f5a01b4b85dcd377787e1:xdgmime/src/xdgmi
bash_CMD= /bin/sh
SHEBANG_FILES= ${WRKSRC}/data/freedesktop_generate.sh
SUB_FILES= pkg-install
SUB_LIST= MIMEDIRS="${MIMEDIRS:O:u}"
MIMEDIRS= ${LOCALBASE}/share/mime \
${PREFIX}/share/mime
MIMESUBDIRS= application audio image inode message model multipart \
packages text video x-epoc x-content
packages text video x-epoc x-content font
BINARY_ALIAS= xmlto=minixmlto
@ -45,4 +42,9 @@ post-patch:
pre-configure:
cd ${WRKSRC}/src/xdgmime/src && ${SETENV} ${MAKE_ENV} ${GMAKE}
post-install:
for dir in ${MIMESUBDIRS} ; do \
${MKDIR} ${STAGEDIR}${PREFIX}/share/mime/$${dir} ; \
done
.include <bsd.port.mk>

View file

@ -1,12 +0,0 @@
#!/bin/sh
case $2 in
POST-INSTALL)
for mdir in %%MIMEDIRS%%; do
if [ -d ${mdir} ]; then
%%PREFIX%%/bin/update-mime-database ${mdir}
fi
done
exit 0
;;
esac

View file

@ -0,0 +1,27 @@
path: "%%PREFIX%%/share/mime/packages"
cleanup: {
type: lua
script: <<EOS
local mimedir = "%%PREFIX%%/share/mime/"
local files = { "XMLnamespaces", "aliases", "generic-icons", "globs", "globs2", "icons", "mime.cache", "subclasses", "treemagic", "types", "version"}
for _,filename in pairs(files) do
local fpath = mimedir .. filename
local st = pkg.stat(fpath)
if st then
os.remove(fpath)
end
end
local res = pkg.readdir(mimedir)
if #res == 0 then
os.remove(mimedir)
end
EOS
}
trigger: {
type: lua
sandbox: false
script: <<EOS
print("Building the Shared MIME-Info database cache")
pkg.exec({"%%PREFIX%%/bin/update-mime-database", "%%PREFIX%%/share/mime"})
EOS
}

View file

@ -79,27 +79,15 @@ share/locale/zh_CN/LC_MESSAGES/shared-mime-info.mo
share/locale/zh_HK/LC_MESSAGES/shared-mime-info.mo
share/locale/zh_TW/LC_MESSAGES/shared-mime-info.mo
share/mime/packages/freedesktop.org.xml
@rmtry share/mime/XMLnamespaces
@rmtry share/mime/aliases
@rmtry share/mime/generic-icons
@rmtry share/mime/globs
@rmtry share/mime/globs2
@rmtry share/mime/icons
@rmtry share/mime/magic
@rmtry share/mime/mime.cache
@rmtry share/mime/subclasses
@rmtry share/mime/treemagic
@rmtry share/mime/types
@rmtry share/mime/version
@postunexec rm -fr %D/share/mime/x-epoc 2>/dev/null || true
@postunexec rm -fr %D/share/mime/x-content 2>/dev/null || true
@postunexec rm -fr %D/share/mime/video 2>/dev/null || true
@postunexec rm -fr %D/share/mime/text 2>/dev/null || true
@postunexec rm -fr %D/share/mime/multipart 2>/dev/null || true
@postunexec rm -fr %D/share/mime/model 2>/dev/null || true
@postunexec rm -fr %D/share/mime/message 2>/dev/null || true
@postunexec rm -fr %D/share/mime/inode 2>/dev/null || true
@postunexec rm -fr %D/share/mime/image 2>/dev/null || true
@postunexec rm -fr %D/share/mime/font 2>/dev/null || true
@postunexec rm -fr %D/share/mime/audio 2>/dev/null || true
@postunexec rm -fr %D/share/mime/application 2>/dev/null || true
@dir share/mime/x-epoc
@dir share/mime/x-content
@dir share/mime/video
@dir share/mime/text
@dir share/mime/multipart
@dir share/mime/model
@dir share/mime/message
@dir share/mime/inode
@dir share/mime/image
@dir share/mime/font
@dir share/mime/audio
@dir share/mime/application