mime.bbclass 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #
  2. # This class is used by recipes installing mime types
  3. #
  4. DEPENDS += "${@bb.utils.contains('BPN', 'shared-mime-info', '', 'shared-mime-info', d)}"
  5. PACKAGE_WRITE_DEPS += "shared-mime-info-native"
  6. MIMEDIR = "${datadir}/mime"
  7. mime_postinst() {
  8. if [ "x$D" != "x" ]; then
  9. $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \
  10. mlprefix=${MLPREFIX} \
  11. mimedir=${MIMEDIR}
  12. else
  13. echo "Updating MIME database... this may take a while."
  14. update-mime-database $D${MIMEDIR}
  15. fi
  16. }
  17. mime_postrm() {
  18. if [ "x$D" != "x" ]; then
  19. $INTERCEPT_DIR/postinst_intercept update_mime_database ${PKG} \
  20. mlprefix=${MLPREFIX} \
  21. mimedir=${MIMEDIR}
  22. else
  23. echo "Updating MIME database... this may take a while."
  24. update-mime-database $D${MIMEDIR}
  25. fi
  26. }
  27. python populate_packages_append () {
  28. packages = d.getVar('PACKAGES').split()
  29. pkgdest = d.getVar('PKGDEST')
  30. mimedir = d.getVar('MIMEDIR')
  31. for pkg in packages:
  32. mime_packages_dir = '%s/%s%s/packages' % (pkgdest, pkg, mimedir)
  33. mimes_types_found = False
  34. if os.path.exists(mime_packages_dir):
  35. for f in os.listdir(mime_packages_dir):
  36. if f.endswith('.xml'):
  37. mimes_types_found = True
  38. break
  39. if mimes_types_found:
  40. bb.note("adding mime postinst and postrm scripts to %s" % pkg)
  41. postinst = d.getVar('pkg_postinst_%s' % pkg)
  42. if not postinst:
  43. postinst = '#!/bin/sh\n'
  44. postinst += d.getVar('mime_postinst')
  45. d.setVar('pkg_postinst_%s' % pkg, postinst)
  46. postrm = d.getVar('pkg_postrm_%s' % pkg)
  47. if not postrm:
  48. postrm = '#!/bin/sh\n'
  49. postrm += d.getVar('mime_postrm')
  50. d.setVar('pkg_postrm_%s' % pkg, postrm)
  51. if pkg != 'shared-mime-info-data':
  52. bb.note("adding shared-mime-info-data dependency to %s" % pkg)
  53. d.appendVar('RDEPENDS_' + pkg, " " + d.getVar('MLPREFIX')+"shared-mime-info-data")
  54. }