mime.bbclass 1.9 KB

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