blob: 0df15831c4648f829af87cd50942f725727d82d2 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001DEPENDS += "shared-mime-info"
2PACKAGE_WRITE_DEPS += "shared-mime-info-native"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05003
4mime_postinst() {
5if [ "$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
14fi
15}
16
17mime_postrm() {
18if [ "$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
27fi
28}
29
30python populate_packages_append () {
31 import re
Brad Bishop6e60e8b2018-02-01 10:27:11 -050032 packages = d.getVar('PACKAGES').split()
33 pkgdest = d.getVar('PKGDEST')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034
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 Bishop6e60e8b2018-02-01 10:27:11 -050045 postinst = d.getVar('pkg_postinst_%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046 if not postinst:
47 postinst = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050048 postinst += d.getVar('mime_postinst')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049 d.setVar('pkg_postinst_%s' % pkg, postinst)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050050 postrm = d.getVar('pkg_postrm_%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051 if not postrm:
52 postrm = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050053 postrm += d.getVar('mime_postrm')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054 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}