Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 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)}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 6 | PACKAGE_WRITE_DEPS += "shared-mime-info-native" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 7 | MIMEDIR = "${datadir}/mime" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8 | |
| 9 | mime_postinst() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 10 | if [ "x$D" != "x" ]; then |
| 11 | $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \ |
| 12 | mlprefix=${MLPREFIX} \ |
| 13 | mimedir=${MIMEDIR} |
| 14 | else |
| 15 | echo "Updating MIME database... this may take a while." |
| 16 | update-mime-database $D${MIMEDIR} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | fi |
| 18 | } |
| 19 | |
| 20 | mime_postrm() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 21 | if [ "x$D" != "x" ]; then |
| 22 | $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \ |
| 23 | mlprefix=${MLPREFIX} \ |
| 24 | mimedir=${MIMEDIR} |
| 25 | else |
| 26 | echo "Updating MIME database... this may take a while." |
| 27 | update-mime-database $D${MIMEDIR} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | fi |
| 29 | } |
| 30 | |
| 31 | python populate_packages_append () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 32 | packages = d.getVar('PACKAGES').split() |
| 33 | pkgdest = d.getVar('PKGDEST') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 34 | mimedir = d.getVar('MIMEDIR') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 35 | |
| 36 | for pkg in packages: |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 37 | mime_packages_dir = '%s/%s%s/packages' % (pkgdest, pkg, mimedir) |
| 38 | mimes_types_found = False |
| 39 | if os.path.exists(mime_packages_dir): |
| 40 | for f in os.listdir(mime_packages_dir): |
| 41 | if f.endswith('.xml'): |
| 42 | mimes_types_found = True |
| 43 | break |
| 44 | if mimes_types_found: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 45 | bb.note("adding mime postinst and postrm scripts to %s" % pkg) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 46 | postinst = d.getVar('pkg_postinst_%s' % pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 47 | if not postinst: |
| 48 | postinst = '#!/bin/sh\n' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 49 | postinst += d.getVar('mime_postinst') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 50 | d.setVar('pkg_postinst_%s' % pkg, postinst) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 51 | postrm = d.getVar('pkg_postrm_%s' % pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 52 | if not postrm: |
| 53 | postrm = '#!/bin/sh\n' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 54 | postrm += d.getVar('mime_postrm') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | d.setVar('pkg_postrm_%s' % pkg, postrm) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame^] | 56 | if pkg != '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") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | } |