fontcache.bbclass 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #
  2. # This class will generate the proper postinst/postrm scriptlets for font
  3. # packages.
  4. #
  5. PACKAGE_WRITE_DEPS += "qemu-native"
  6. inherit qemu
  7. FONT_PACKAGES ??= "${PN}"
  8. FONT_EXTRA_RDEPENDS ?= "fontconfig-utils"
  9. FONTCONFIG_CACHE_DIR ?= "${localstatedir}/cache/fontconfig"
  10. FONTCONFIG_CACHE_PARAMS ?= "-v"
  11. # You can change this to e.g. FC_DEBUG=16 to debug fc-cache issues,
  12. # something has to be set, because qemuwrapper is using this variable after -E
  13. # multiple variables aren't allowed because for qemu they are separated
  14. # by comma and in -n "$D" case they should be separated by space
  15. FONTCONFIG_CACHE_ENV ?= "FC_DEBUG=1"
  16. fontcache_common() {
  17. if [ -n "$D" ] ; then
  18. $INTERCEPT_DIR/postinst_intercept update_font_cache ${PKG} mlprefix=${MLPREFIX} \
  19. 'bindir="${bindir}"' \
  20. 'libdir="${libdir}"' \
  21. 'base_libdir="${base_libdir}"' \
  22. 'fontconfigcachedir="${FONTCONFIG_CACHE_DIR}"' \
  23. 'fontconfigcacheparams="${FONTCONFIG_CACHE_PARAMS}"' \
  24. 'fontconfigcacheenv="${FONTCONFIG_CACHE_ENV}"'
  25. else
  26. ${FONTCONFIG_CACHE_ENV} fc-cache ${FONTCONFIG_CACHE_PARAMS}
  27. fi
  28. }
  29. python () {
  30. font_pkgs = d.getVar('FONT_PACKAGES').split()
  31. deps = d.getVar("FONT_EXTRA_RDEPENDS")
  32. for pkg in font_pkgs:
  33. if deps: d.appendVar('RDEPENDS_' + pkg, ' '+deps)
  34. }
  35. python add_fontcache_postinsts() {
  36. for pkg in d.getVar('FONT_PACKAGES').split():
  37. bb.note("adding fonts postinst and postrm scripts to %s" % pkg)
  38. postinst = d.getVar('pkg_postinst_%s' % pkg) or d.getVar('pkg_postinst')
  39. if not postinst:
  40. postinst = '#!/bin/sh\n'
  41. postinst += d.getVar('fontcache_common')
  42. d.setVar('pkg_postinst_%s' % pkg, postinst)
  43. postrm = d.getVar('pkg_postrm_%s' % pkg) or d.getVar('pkg_postrm')
  44. if not postrm:
  45. postrm = '#!/bin/sh\n'
  46. postrm += d.getVar('fontcache_common')
  47. d.setVar('pkg_postrm_%s' % pkg, postrm)
  48. }
  49. PACKAGEFUNCS =+ "add_fontcache_postinsts"