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