diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-10 14:35:29 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-12 15:27:17 +0100 |
commit | fd1517e2b51a170f2427122c6b95396db251d827 (patch) | |
tree | dabfe3e631339c2fc99a9ee7febb0f9c128e325e /meta/classes-recipe/mime.bbclass | |
parent | 10317912ee319ccf7f83605d438b5cbf9663f296 (diff) | |
download | poky-fd1517e2b51a170f2427122c6b95396db251d827.tar.gz |
classes: Update classes to match new bitbake class scope functionality
Move classes to classes-global or classes-recipe as appropriate to take
advantage of new bitbake functionality to check class scope/usage.
(From OE-Core rev: f5c128008365e141082c129417eb72d2751e8045)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/mime.bbclass')
-rw-r--r-- | meta/classes-recipe/mime.bbclass | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/meta/classes-recipe/mime.bbclass b/meta/classes-recipe/mime.bbclass new file mode 100644 index 0000000000..9b13f62bda --- /dev/null +++ b/meta/classes-recipe/mime.bbclass | |||
@@ -0,0 +1,76 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | # | ||
8 | # This class is used by recipes installing mime types | ||
9 | # | ||
10 | |||
11 | DEPENDS += "${@bb.utils.contains('BPN', 'shared-mime-info', '', 'shared-mime-info', d)}" | ||
12 | PACKAGE_WRITE_DEPS += "shared-mime-info-native" | ||
13 | MIMEDIR = "${datadir}/mime" | ||
14 | |||
15 | mime_postinst() { | ||
16 | if [ "x$D" != "x" ]; then | ||
17 | $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \ | ||
18 | mlprefix=${MLPREFIX} \ | ||
19 | mimedir=${MIMEDIR} | ||
20 | else | ||
21 | echo "Updating MIME database... this may take a while." | ||
22 | update-mime-database $D${MIMEDIR} | ||
23 | fi | ||
24 | } | ||
25 | |||
26 | mime_postrm() { | ||
27 | if [ "x$D" != "x" ]; then | ||
28 | $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \ | ||
29 | mlprefix=${MLPREFIX} \ | ||
30 | mimedir=${MIMEDIR} | ||
31 | else | ||
32 | echo "Updating MIME database... this may take a while." | ||
33 | # $D${MIMEDIR}/packages belong to package shared-mime-info-data, | ||
34 | # packages like libfm-mime depend on shared-mime-info-data. | ||
35 | # after shared-mime-info-data uninstalled, $D${MIMEDIR}/packages | ||
36 | # is removed, but update-mime-database need this dir to update | ||
37 | # database, workaround to create one and remove it later | ||
38 | if [ ! -d $D${MIMEDIR}/packages ]; then | ||
39 | mkdir -p $D${MIMEDIR}/packages | ||
40 | update-mime-database $D${MIMEDIR} | ||
41 | rmdir --ignore-fail-on-non-empty $D${MIMEDIR}/packages | ||
42 | else | ||
43 | update-mime-database $D${MIMEDIR} | ||
44 | fi | ||
45 | fi | ||
46 | } | ||
47 | |||
48 | python populate_packages:append () { | ||
49 | packages = d.getVar('PACKAGES').split() | ||
50 | pkgdest = d.getVar('PKGDEST') | ||
51 | mimedir = d.getVar('MIMEDIR') | ||
52 | |||
53 | for pkg in packages: | ||
54 | mime_packages_dir = '%s/%s%s/packages' % (pkgdest, pkg, mimedir) | ||
55 | mimes_types_found = False | ||
56 | if os.path.exists(mime_packages_dir): | ||
57 | for f in os.listdir(mime_packages_dir): | ||
58 | if f.endswith('.xml'): | ||
59 | mimes_types_found = True | ||
60 | break | ||
61 | if mimes_types_found: | ||
62 | bb.note("adding mime postinst and postrm scripts to %s" % pkg) | ||
63 | postinst = d.getVar('pkg_postinst:%s' % pkg) | ||
64 | if not postinst: | ||
65 | postinst = '#!/bin/sh\n' | ||
66 | postinst += d.getVar('mime_postinst') | ||
67 | d.setVar('pkg_postinst:%s' % pkg, postinst) | ||
68 | postrm = d.getVar('pkg_postrm:%s' % pkg) | ||
69 | if not postrm: | ||
70 | postrm = '#!/bin/sh\n' | ||
71 | postrm += d.getVar('mime_postrm') | ||
72 | d.setVar('pkg_postrm:%s' % pkg, postrm) | ||
73 | if pkg != 'shared-mime-info-data': | ||
74 | bb.note("adding shared-mime-info-data dependency to %s" % pkg) | ||
75 | d.appendVar('RDEPENDS:' + pkg, " " + d.getVar('MLPREFIX')+"shared-mime-info-data") | ||
76 | } | ||