blob: 8d176a884e79386ce8fc0f7575081dfb3c5acf28 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001#
2# This class is used by recipes installing mime types
3#
4
5DEPENDS += "${@bb.utils.contains('BPN', 'shared-mime-info', '', 'shared-mime-info', d)}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05006PACKAGE_WRITE_DEPS += "shared-mime-info-native"
Andrew Geissler82c905d2020-04-13 13:39:40 -05007MIMEDIR = "${datadir}/mime"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008
9mime_postinst() {
Andrew Geissler82c905d2020-04-13 13:39:40 -050010if [ "x$D" != "x" ]; then
11 $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \
12 mlprefix=${MLPREFIX} \
13 mimedir=${MIMEDIR}
14else
15 echo "Updating MIME database... this may take a while."
16 update-mime-database $D${MIMEDIR}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017fi
18}
19
20mime_postrm() {
Andrew Geissler82c905d2020-04-13 13:39:40 -050021if [ "x$D" != "x" ]; then
22 $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \
23 mlprefix=${MLPREFIX} \
24 mimedir=${MIMEDIR}
25else
26 echo "Updating MIME database... this may take a while."
Andrew Geisslerd25ed322020-06-27 00:28:28 -050027 # $D${MIMEDIR}/packages belong to package shared-mime-info-data,
28 # packages like libfm-mime depend on shared-mime-info-data.
29 # after shared-mime-info-data uninstalled, $D${MIMEDIR}/packages
30 # is removed, but update-mime-database need this dir to update
31 # database, workaround to create one and remove it later
32 if [ ! -d $D${MIMEDIR}/packages ]; then
33 mkdir -p $D${MIMEDIR}/packages
34 update-mime-database $D${MIMEDIR}
35 rmdir --ignore-fail-on-non-empty $D${MIMEDIR}/packages
36 else
37 update-mime-database $D${MIMEDIR}
38fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039fi
40}
41
Patrick Williams213cb262021-08-07 19:21:33 -050042python populate_packages:append () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043 packages = d.getVar('PACKAGES').split()
44 pkgdest = d.getVar('PKGDEST')
Andrew Geissler82c905d2020-04-13 13:39:40 -050045 mimedir = d.getVar('MIMEDIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046
47 for pkg in packages:
Andrew Geissler82c905d2020-04-13 13:39:40 -050048 mime_packages_dir = '%s/%s%s/packages' % (pkgdest, pkg, mimedir)
49 mimes_types_found = False
50 if os.path.exists(mime_packages_dir):
51 for f in os.listdir(mime_packages_dir):
52 if f.endswith('.xml'):
53 mimes_types_found = True
54 break
55 if mimes_types_found:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056 bb.note("adding mime postinst and postrm scripts to %s" % pkg)
Patrick Williams213cb262021-08-07 19:21:33 -050057 postinst = d.getVar('pkg_postinst:%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058 if not postinst:
59 postinst = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050060 postinst += d.getVar('mime_postinst')
Patrick Williams213cb262021-08-07 19:21:33 -050061 d.setVar('pkg_postinst:%s' % pkg, postinst)
62 postrm = d.getVar('pkg_postrm:%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063 if not postrm:
64 postrm = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050065 postrm += d.getVar('mime_postrm')
Patrick Williams213cb262021-08-07 19:21:33 -050066 d.setVar('pkg_postrm:%s' % pkg, postrm)
Andrew Geissler82c905d2020-04-13 13:39:40 -050067 if pkg != 'shared-mime-info-data':
68 bb.note("adding shared-mime-info-data dependency to %s" % pkg)
Patrick Williams213cb262021-08-07 19:21:33 -050069 d.appendVar('RDEPENDS:' + pkg, " " + d.getVar('MLPREFIX')+"shared-mime-info-data")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050070}