Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | DEPENDS += "shared-mime-info" |
| 2 | PACKAGE_WRITE_DEPS += "shared-mime-info-native" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3 | |
| 4 | mime_postinst() { |
| 5 | if [ "$1" = configure ]; then |
| 6 | UPDATEMIMEDB=`which update-mime-database` |
| 7 | if [ -x "$UPDATEMIMEDB" ] ; then |
| 8 | echo "Updating MIME database... this may take a while." |
| 9 | $UPDATEMIMEDB $D${datadir}/mime |
| 10 | else |
| 11 | echo "Missing update-mime-database, update of mime database failed!" |
| 12 | exit 1 |
| 13 | fi |
| 14 | fi |
| 15 | } |
| 16 | |
| 17 | mime_postrm() { |
| 18 | if [ "$1" = remove ] || [ "$1" = upgrade ]; then |
| 19 | UPDATEMIMEDB=`which update-mime-database` |
| 20 | if [ -x "$UPDATEMIMEDB" ] ; then |
| 21 | echo "Updating MIME database... this may take a while." |
| 22 | $UPDATEMIMEDB $D${datadir}/mime |
| 23 | else |
| 24 | echo "Missing update-mime-database, update of mime database failed!" |
| 25 | exit 1 |
| 26 | fi |
| 27 | fi |
| 28 | } |
| 29 | |
| 30 | python populate_packages_append () { |
| 31 | import re |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 32 | packages = d.getVar('PACKAGES').split() |
| 33 | pkgdest = d.getVar('PKGDEST') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | |
| 35 | for pkg in packages: |
| 36 | mime_dir = '%s/%s/usr/share/mime/packages' % (pkgdest, pkg) |
| 37 | mimes = [] |
| 38 | mime_re = re.compile(".*\.xml$") |
| 39 | if os.path.exists(mime_dir): |
| 40 | for f in os.listdir(mime_dir): |
| 41 | if mime_re.match(f): |
| 42 | mimes.append(f) |
| 43 | if mimes: |
| 44 | bb.note("adding mime postinst and postrm scripts to %s" % pkg) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 45 | postinst = d.getVar('pkg_postinst_%s' % pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | if not postinst: |
| 47 | postinst = '#!/bin/sh\n' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 48 | postinst += d.getVar('mime_postinst') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 49 | d.setVar('pkg_postinst_%s' % pkg, postinst) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 50 | postrm = d.getVar('pkg_postrm_%s' % pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | if not postrm: |
| 52 | postrm = '#!/bin/sh\n' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 53 | postrm += d.getVar('mime_postrm') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 54 | d.setVar('pkg_postrm_%s' % pkg, postrm) |
| 55 | bb.note("adding shared-mime-info-data dependency to %s" % pkg) |
| 56 | d.appendVar('RDEPENDS_' + pkg, " shared-mime-info-data") |
| 57 | } |