diff options
| -rw-r--r-- | meta/classes/mime.bbclass | 62 | ||||
| -rw-r--r-- | scripts/postinst-intercepts/update_mime_database | 9 |
2 files changed, 41 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 | } |
diff --git a/scripts/postinst-intercepts/update_mime_database b/scripts/postinst-intercepts/update_mime_database new file mode 100644 index 0000000000..582d1e162c --- /dev/null +++ b/scripts/postinst-intercepts/update_mime_database | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # SPDX-License-Identifier: MIT | ||
| 4 | # | ||
| 5 | # Post-install intercept for mime.bbclass | ||
| 6 | |||
| 7 | echo "Updating MIME database... this may take a while." | ||
| 8 | update-mime-database $D${mimedir} | ||
| 9 | |||
