Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
| 8 | # TODO use a trigger so that this runs once per package operation run |
| 9 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 10 | GSETTINGS_PACKAGE ?= "${PN}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 12 | python __anonymous() { |
| 13 | pkg = d.getVar("GSETTINGS_PACKAGE") |
| 14 | if pkg: |
| 15 | d.appendVar("PACKAGE_WRITE_DEPS", " glib-2.0-native") |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 16 | d.appendVar("RDEPENDS:" + pkg, " ${MLPREFIX}glib-2.0-utils") |
| 17 | d.appendVar("FILES:" + pkg, " ${datadir}/glib-2.0/schemas") |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 18 | } |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 19 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 20 | gsettings_postinstrm () { |
| 21 | glib-compile-schemas $D${datadir}/glib-2.0/schemas |
| 22 | } |
| 23 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 24 | python populate_packages:append () { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 25 | pkg = d.getVar('GSETTINGS_PACKAGE') |
| 26 | if pkg: |
| 27 | bb.note("adding gsettings postinst scripts to %s" % pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 29 | postinst = d.getVar('pkg_postinst:%s' % pkg) or d.getVar('pkg_postinst') |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 30 | if not postinst: |
| 31 | postinst = '#!/bin/sh\n' |
| 32 | postinst += d.getVar('gsettings_postinstrm') |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 33 | d.setVar('pkg_postinst:%s' % pkg, postinst) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 35 | bb.note("adding gsettings postrm scripts to %s" % pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 37 | postrm = d.getVar('pkg_postrm:%s' % pkg) or d.getVar('pkg_postrm') |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 38 | if not postrm: |
| 39 | postrm = '#!/bin/sh\n' |
| 40 | postrm += d.getVar('gsettings_postinstrm') |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 41 | d.setVar('pkg_postrm:%s' % pkg, postrm) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 42 | } |