blob: 2107517540ba558dbaba2bf51d09e2a52e4f2897 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# This class will update the inputmethod module cache for virtual keyboards
2#
3# Usage: Set GTKIMMODULES_PACKAGES to the packages that needs to update the inputmethod modules
4
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005PACKAGE_WRITE_DEPS += "qemu-native"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006
7inherit qemu
8
9GTKIMMODULES_PACKAGES ?= "${PN}"
10
11gtk_immodule_cache_postinst() {
12if [ "x$D" != "x" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080013 $INTERCEPT_DIR/postinst_intercept update_gtk_immodules_cache ${PKG} \
14 mlprefix=${MLPREFIX} \
15 binprefix=${MLPREFIX} \
16 libdir=${libdir} \
17 libexecdir=${libexecdir} \
18 base_libdir=${base_libdir} \
19 bindir=${bindir}
20else
21 if [ ! -z `which gtk-query-immodules-2.0` ]; then
22 gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache
23 fi
24 if [ ! -z `which gtk-query-immodules-3.0` ]; then
Andrew Geisslerb7d28612020-07-24 16:15:54 -050025 mkdir -p ${libdir}/gtk-3.0/3.0.0
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080026 gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache
27 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028fi
29}
30
31gtk_immodule_cache_postrm() {
32if [ "x$D" != "x" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080033 $INTERCEPT_DIR/postinst_intercept update_gtk_immodules_cache ${PKG} \
34 mlprefix=${MLPREFIX} \
35 binprefix=${MLPREFIX} \
36 libdir=${libdir} \
37 libexecdir=${libexecdir} \
38 base_libdir=${base_libdir} \
39 bindir=${bindir}
40else
41 if [ ! -z `which gtk-query-immodules-2.0` ]; then
42 gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache
43 fi
44 if [ ! -z `which gtk-query-immodules-3.0` ]; then
45 gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache
46 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050047fi
48}
49
Patrick Williams213cb262021-08-07 19:21:33 -050050python populate_packages:append () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050051 gtkimmodules_pkgs = d.getVar('GTKIMMODULES_PACKAGES').split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052
53 for pkg in gtkimmodules_pkgs:
54 bb.note("adding gtk-immodule-cache postinst and postrm scripts to %s" % pkg)
55
Patrick Williams213cb262021-08-07 19:21:33 -050056 postinst = d.getVar('pkg_postinst:%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057 if not postinst:
58 postinst = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050059 postinst += d.getVar('gtk_immodule_cache_postinst')
Patrick Williams213cb262021-08-07 19:21:33 -050060 d.setVar('pkg_postinst:%s' % pkg, postinst)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061
Patrick Williams213cb262021-08-07 19:21:33 -050062 postrm = d.getVar('pkg_postrm:%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063 if not postrm:
64 postrm = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050065 postrm += d.getVar('gtk_immodule_cache_postrm')
Patrick Williams213cb262021-08-07 19:21:33 -050066 d.setVar('pkg_postrm:%s' % pkg, postrm)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067}
68
69python __anonymous() {
70 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
71 gtkimmodules_check = d.getVar('GTKIMMODULES_PACKAGES', False)
72 if not gtkimmodules_check:
73 bb_filename = d.getVar('FILE', False)
Patrick Williamsc0f7c042017-02-23 20:41:17 -060074 bb.fatal("ERROR: %s inherits gtk-immodules-cache but doesn't set GTKIMMODULES_PACKAGES" % bb_filename)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075}
76