07d0f9c259338601ac2d0ee0dc836e92480d6821
[vuplus_openembedded] / classes / mime.bbclass
1 DEPENDS += "shared-mime-info-native shared-mime-info"
2 RDEPENDS += "shared-mime-info"
3
4 mime_postinst() {
5 if [ "$1" = configure ]; then
6         if [ -x ${bindir}/update-mime-database ] ; then
7                 echo "Updating MIME database... this may take a while."
8                 update-mime-database $D${datadir}/mime
9         else
10                 echo "Missing ${bindir}/update-mime-database, update of mime database failed!"
11                 exit 1
12         fi
13 fi
14 }
15
16 mime_postrm() {
17 if [ "$1" = remove ] || [ "$1" = upgrade ]; then
18         if [ -x ${bindir}/update-mime-database ] ; then
19                 echo "Updating MIME database... this may take a while."
20                 update-mime-database $D${datadir}/mime
21         else
22                 echo "Missing ${bindir}/update-mime-database, update of mime database failed!"
23                 exit 1
24         fi
25 fi
26 }
27
28 python populate_packages_append () {
29         import os.path, re
30         packages = bb.data.getVar('PACKAGES', d, 1).split()
31         workdir = bb.data.getVar('WORKDIR', d, 1)
32         
33         for pkg in packages:
34                 mime_dir = '%s/install/%s/usr/share/mime/packages' % (workdir, pkg)
35                 mimes = []
36                 mime_re = re.compile(".*\.xml$")
37                 if os.path.exists(mime_dir):
38                         for f in os.listdir(mime_dir):
39                                 if mime_re.match(f):
40                                         mimes.append(f)
41                 if mimes != []:
42                         bb.note("adding mime postinst and prerm scripts to %s" % pkg)
43                         postinst = bb.data.getVar('pkg_postinst_%s' % pkg, d, 1) or bb.data.getVar('pkg_postinst', d, 1)
44                         if not postinst:
45                                 postinst = '#!/bin/sh\n'
46                         postinst += bb.data.getVar('mime_postinst', d, 1)
47                         bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d)
48                         prerm = bb.data.getVar('pkg_prerm_%s' % pkg, d, 1) or bb.data.getVar('pkg_prerm', d, 1)
49                         if not prerm:
50                                 prerm = '#!/bin/sh\n'
51                         prerm += bb.data.getVar('mime_prerm', d, 1)
52                         bb.data.setVar('pkg_prerm_%s' % pkg, prerm, d)
53
54 }