diff options
author | Andreas Müller <schnitzeltony@gmail.com> | 2020-01-17 22:29:02 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-01-19 13:24:38 +0000 |
commit | c8e3a0a4423e26290fb34823dcdbb2c04f3391b7 (patch) | |
tree | a740b4c08cc4fb949e6f7e9691cfe83937a783cb /meta | |
parent | 3d3f59d2c8315ffd34ab9867870642fec4fe1c2b (diff) | |
download | poky-c8e3a0a4423e26290fb34823dcdbb2c04f3391b7.tar.gz |
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>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/mime.bbclass | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/meta/classes/mime.bbclass b/meta/classes/mime.bbclass index 6c7b868f79..c9072adf3b 100644 --- a/meta/classes/mime.bbclass +++ b/meta/classes/mime.bbclass | |||
@@ -1,46 +1,47 @@ | |||
1 | DEPENDS += "shared-mime-info" | 1 | # |
2 | # This class is used by recipes installing mime types | ||
3 | # | ||
4 | |||
5 | DEPENDS += "${@bb.utils.contains('BPN', 'shared-mime-info', '', 'shared-mime-info', d)}" | ||
2 | PACKAGE_WRITE_DEPS += "shared-mime-info-native" | 6 | PACKAGE_WRITE_DEPS += "shared-mime-info-native" |
7 | MIMEDIR = "${datadir}/mime" | ||
3 | 8 | ||
4 | mime_postinst() { | 9 | mime_postinst() { |
5 | if [ "$1" = configure ]; then | 10 | if [ "x$D" != "x" ]; then |
6 | UPDATEMIMEDB=`which update-mime-database` | 11 | $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \ |
7 | if [ -x "$UPDATEMIMEDB" ] ; then | 12 | mlprefix=${MLPREFIX} \ |
8 | echo "Updating MIME database... this may take a while." | 13 | mimedir=${MIMEDIR} |
9 | $UPDATEMIMEDB $D${datadir}/mime | 14 | else |
10 | else | 15 | echo "Updating MIME database... this may take a while." |
11 | echo "Missing update-mime-database, update of mime database failed!" | 16 | update-mime-database $D${MIMEDIR} |
12 | exit 1 | ||
13 | fi | ||
14 | fi | 17 | fi |
15 | } | 18 | } |
16 | 19 | ||
17 | mime_postrm() { | 20 | mime_postrm() { |
18 | if [ "$1" = remove ] || [ "$1" = upgrade ]; then | 21 | if [ "x$D" != "x" ]; then |
19 | UPDATEMIMEDB=`which update-mime-database` | 22 | $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \ |
20 | if [ -x "$UPDATEMIMEDB" ] ; then | 23 | mlprefix=${MLPREFIX} \ |
21 | echo "Updating MIME database... this may take a while." | 24 | mimedir=${MIMEDIR} |
22 | $UPDATEMIMEDB $D${datadir}/mime | 25 | else |
23 | else | 26 | echo "Updating MIME database... this may take a while." |
24 | echo "Missing update-mime-database, update of mime database failed!" | 27 | update-mime-database $D${MIMEDIR} |
25 | exit 1 | ||
26 | fi | ||
27 | fi | 28 | fi |
28 | } | 29 | } |
29 | 30 | ||
30 | python populate_packages_append () { | 31 | python populate_packages_append () { |
31 | import re | ||
32 | packages = d.getVar('PACKAGES').split() | 32 | packages = d.getVar('PACKAGES').split() |
33 | pkgdest = d.getVar('PKGDEST') | 33 | pkgdest = d.getVar('PKGDEST') |
34 | mimedir = d.getVar('MIMEDIR') | ||
34 | 35 | ||
35 | for pkg in packages: | 36 | for pkg in packages: |
36 | mime_dir = '%s/%s/usr/share/mime/packages' % (pkgdest, pkg) | 37 | mime_packages_dir = '%s/%s%s/packages' % (pkgdest, pkg, mimedir) |
37 | mimes = [] | 38 | mimes_types_found = False |
38 | mime_re = re.compile(".*\.xml$") | 39 | if os.path.exists(mime_packages_dir): |
39 | if os.path.exists(mime_dir): | 40 | for f in os.listdir(mime_packages_dir): |
40 | for f in os.listdir(mime_dir): | 41 | if f.endswith('.xml'): |
41 | if mime_re.match(f): | 42 | mimes_types_found = True |
42 | mimes.append(f) | 43 | break |
43 | if mimes: | 44 | if mimes_types_found: |
44 | bb.note("adding mime postinst and postrm scripts to %s" % pkg) | 45 | bb.note("adding mime postinst and postrm scripts to %s" % pkg) |
45 | postinst = d.getVar('pkg_postinst_%s' % pkg) | 46 | postinst = d.getVar('pkg_postinst_%s' % pkg) |
46 | if not postinst: | 47 | if not postinst: |
@@ -52,6 +53,7 @@ python populate_packages_append () { | |||
52 | postrm = '#!/bin/sh\n' | 53 | postrm = '#!/bin/sh\n' |
53 | postrm += d.getVar('mime_postrm') | 54 | postrm += d.getVar('mime_postrm') |
54 | d.setVar('pkg_postrm_%s' % pkg, postrm) | 55 | d.setVar('pkg_postrm_%s' % pkg, postrm) |
55 | bb.note("adding shared-mime-info-data dependency to %s" % pkg) | 56 | if pkg != 'shared-mime-info-data': |
56 | d.appendVar('RDEPENDS_' + pkg, " " + d.getVar('MLPREFIX')+"shared-mime-info-data") | 57 | bb.note("adding shared-mime-info-data dependency to %s" % pkg) |
58 | d.appendVar('RDEPENDS_' + pkg, " " + d.getVar('MLPREFIX')+"shared-mime-info-data") | ||
57 | } | 59 | } |