mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
mime.bbclass: rework
* add a short descriptions of class' use case * remove checks for update-mime-database - it can be considered available: * at build time by PACKAGE_WRITE_DEPS * at package upgrade by RDEPENDS chain pkg -> shared-mime-info-data -> shared-mime-info * simplify (accelerate?) xml file extension detection * run update-mime-database once only at image creation to avoid expensive redundant operations * allow shared-mime-info to inherit mime.bbclass by avoiding circular dependencies (From OE-Core rev: 6467b7b98c9a55e27d1ab9f253ec48da2a722e77) Signed-off-by: Andreas Müller <schnitzeltony@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
3d3f59d2c8
commit
c8e3a0a442
|
@ -1,46 +1,47 @@
|
||||||
DEPENDS += "shared-mime-info"
|
#
|
||||||
|
# This class is used by recipes installing mime types
|
||||||
|
#
|
||||||
|
|
||||||
|
DEPENDS += "${@bb.utils.contains('BPN', 'shared-mime-info', '', 'shared-mime-info', d)}"
|
||||||
PACKAGE_WRITE_DEPS += "shared-mime-info-native"
|
PACKAGE_WRITE_DEPS += "shared-mime-info-native"
|
||||||
|
MIMEDIR = "${datadir}/mime"
|
||||||
|
|
||||||
mime_postinst() {
|
mime_postinst() {
|
||||||
if [ "$1" = configure ]; then
|
if [ "x$D" != "x" ]; then
|
||||||
UPDATEMIMEDB=`which update-mime-database`
|
$INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \
|
||||||
if [ -x "$UPDATEMIMEDB" ] ; then
|
mlprefix=${MLPREFIX} \
|
||||||
echo "Updating MIME database... this may take a while."
|
mimedir=${MIMEDIR}
|
||||||
$UPDATEMIMEDB $D${datadir}/mime
|
|
||||||
else
|
else
|
||||||
echo "Missing update-mime-database, update of mime database failed!"
|
echo "Updating MIME database... this may take a while."
|
||||||
exit 1
|
update-mime-database $D${MIMEDIR}
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
mime_postrm() {
|
mime_postrm() {
|
||||||
if [ "$1" = remove ] || [ "$1" = upgrade ]; then
|
if [ "x$D" != "x" ]; then
|
||||||
UPDATEMIMEDB=`which update-mime-database`
|
$INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \
|
||||||
if [ -x "$UPDATEMIMEDB" ] ; then
|
mlprefix=${MLPREFIX} \
|
||||||
echo "Updating MIME database... this may take a while."
|
mimedir=${MIMEDIR}
|
||||||
$UPDATEMIMEDB $D${datadir}/mime
|
|
||||||
else
|
else
|
||||||
echo "Missing update-mime-database, update of mime database failed!"
|
echo "Updating MIME database... this may take a while."
|
||||||
exit 1
|
update-mime-database $D${MIMEDIR}
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
python populate_packages_append () {
|
python populate_packages_append () {
|
||||||
import re
|
|
||||||
packages = d.getVar('PACKAGES').split()
|
packages = d.getVar('PACKAGES').split()
|
||||||
pkgdest = d.getVar('PKGDEST')
|
pkgdest = d.getVar('PKGDEST')
|
||||||
|
mimedir = d.getVar('MIMEDIR')
|
||||||
|
|
||||||
for pkg in packages:
|
for pkg in packages:
|
||||||
mime_dir = '%s/%s/usr/share/mime/packages' % (pkgdest, pkg)
|
mime_packages_dir = '%s/%s%s/packages' % (pkgdest, pkg, mimedir)
|
||||||
mimes = []
|
mimes_types_found = False
|
||||||
mime_re = re.compile(".*\.xml$")
|
if os.path.exists(mime_packages_dir):
|
||||||
if os.path.exists(mime_dir):
|
for f in os.listdir(mime_packages_dir):
|
||||||
for f in os.listdir(mime_dir):
|
if f.endswith('.xml'):
|
||||||
if mime_re.match(f):
|
mimes_types_found = True
|
||||||
mimes.append(f)
|
break
|
||||||
if mimes:
|
if mimes_types_found:
|
||||||
bb.note("adding mime postinst and postrm scripts to %s" % pkg)
|
bb.note("adding mime postinst and postrm scripts to %s" % pkg)
|
||||||
postinst = d.getVar('pkg_postinst_%s' % pkg)
|
postinst = d.getVar('pkg_postinst_%s' % pkg)
|
||||||
if not postinst:
|
if not postinst:
|
||||||
|
@ -52,6 +53,7 @@ python populate_packages_append () {
|
||||||
postrm = '#!/bin/sh\n'
|
postrm = '#!/bin/sh\n'
|
||||||
postrm += d.getVar('mime_postrm')
|
postrm += d.getVar('mime_postrm')
|
||||||
d.setVar('pkg_postrm_%s' % pkg, postrm)
|
d.setVar('pkg_postrm_%s' % pkg, postrm)
|
||||||
|
if pkg != 'shared-mime-info-data':
|
||||||
bb.note("adding shared-mime-info-data dependency to %s" % pkg)
|
bb.note("adding shared-mime-info-data dependency to %s" % pkg)
|
||||||
d.appendVar('RDEPENDS_' + pkg, " " + d.getVar('MLPREFIX')+"shared-mime-info-data")
|
d.appendVar('RDEPENDS_' + pkg, " " + d.getVar('MLPREFIX')+"shared-mime-info-data")
|
||||||
}
|
}
|
||||||
|
|
9
scripts/postinst-intercepts/update_mime_database
Normal file
9
scripts/postinst-intercepts/update_mime_database
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
#
|
||||||
|
# Post-install intercept for mime.bbclass
|
||||||
|
|
||||||
|
echo "Updating MIME database... this may take a while."
|
||||||
|
update-mime-database $D${mimedir}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user