gsettings.bbclass 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # A bbclass to handle installed GSettings (glib) schemas, updated the compiled
  2. # form on package install and remove.
  3. #
  4. # The compiled schemas are platform-agnostic, so we can depend on
  5. # glib-2.0-native for the native tool and run the postinst script when the
  6. # rootfs builds to save a little time on first boot.
  7. # TODO use a trigger so that this runs once per package operation run
  8. GSETTINGS_PACKAGE ?= "${PN}"
  9. python __anonymous() {
  10. pkg = d.getVar("GSETTINGS_PACKAGE")
  11. if pkg:
  12. d.appendVar("PACKAGE_WRITE_DEPS", " glib-2.0-native")
  13. d.appendVar("RDEPENDS_" + pkg, " ${MLPREFIX}glib-2.0-utils")
  14. d.appendVar("FILES_" + pkg, " ${datadir}/glib-2.0/schemas")
  15. }
  16. gsettings_postinstrm () {
  17. glib-compile-schemas $D${datadir}/glib-2.0/schemas
  18. }
  19. python populate_packages_append () {
  20. pkg = d.getVar('GSETTINGS_PACKAGE')
  21. if pkg:
  22. bb.note("adding gsettings postinst scripts to %s" % pkg)
  23. postinst = d.getVar('pkg_postinst_%s' % pkg) or d.getVar('pkg_postinst')
  24. if not postinst:
  25. postinst = '#!/bin/sh\n'
  26. postinst += d.getVar('gsettings_postinstrm')
  27. d.setVar('pkg_postinst_%s' % pkg, postinst)
  28. bb.note("adding gsettings postrm scripts to %s" % pkg)
  29. postrm = d.getVar('pkg_postrm_%s' % pkg) or d.getVar('pkg_postrm')
  30. if not postrm:
  31. postrm = '#!/bin/sh\n'
  32. postrm += d.getVar('gsettings_postinstrm')
  33. d.setVar('pkg_postrm_%s' % pkg, postrm)
  34. }