summaryrefslogtreecommitdiffstats
path: root/meta/classes/mime.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/mime.bbclass')
-rw-r--r--meta/classes/mime.bbclass58
1 files changed, 58 insertions, 0 deletions
diff --git a/meta/classes/mime.bbclass b/meta/classes/mime.bbclass
new file mode 100644
index 0000000000..690610e49d
--- /dev/null
+++ b/meta/classes/mime.bbclass
@@ -0,0 +1,58 @@
1DEPENDS += "shared-mime-info-native shared-mime-info"
2
3EXTRA_OECONF += "--disable-update-mimedb"
4
5mime_postinst() {
6if [ "$1" = configure ]; then
7 UPDATEMIMEDB=`which update-mime-database`
8 if [ -x "$UPDATEMIMEDB" ] ; then
9 echo "Updating MIME database... this may take a while."
10 $UPDATEMIMEDB $D${datadir}/mime
11 else
12 echo "Missing update-mime-database, update of mime database failed!"
13 exit 1
14 fi
15fi
16}
17
18mime_postrm() {
19if [ "$1" = remove ] || [ "$1" = upgrade ]; then
20 UPDATEMIMEDB=`which update-mime-database`
21 if [ -x "$UPDATEMIMEDB" ] ; then
22 echo "Updating MIME database... this may take a while."
23 $UPDATEMIMEDB $D${datadir}/mime
24 else
25 echo "Missing update-mime-database, update of mime database failed!"
26 exit 1
27 fi
28fi
29}
30
31python populate_packages_append () {
32 import re
33 packages = d.getVar('PACKAGES', True).split()
34 pkgdest = d.getVar('PKGDEST', True)
35
36 for pkg in packages:
37 mime_dir = '%s/%s/usr/share/mime/packages' % (pkgdest, pkg)
38 mimes = []
39 mime_re = re.compile(".*\.xml$")
40 if os.path.exists(mime_dir):
41 for f in os.listdir(mime_dir):
42 if mime_re.match(f):
43 mimes.append(f)
44 if mimes:
45 bb.note("adding mime postinst and postrm scripts to %s" % pkg)
46 postinst = d.getVar('pkg_postinst_%s' % pkg, True)
47 if not postinst:
48 postinst = '#!/bin/sh\n'
49 postinst += d.getVar('mime_postinst', True)
50 d.setVar('pkg_postinst_%s' % pkg, postinst)
51 postrm = d.getVar('pkg_postrm_%s' % pkg, True)
52 if not postrm:
53 postrm = '#!/bin/sh\n'
54 postrm += d.getVar('mime_postrm', True)
55 d.setVar('pkg_postrm_%s' % pkg, postrm)
56 bb.note("adding shared-mime-info-data dependency to %s" % pkg)
57 d.appendVar('RDEPENDS_' + pkg, " shared-mime-info-data")
58}