blob: 9bb0af8b26a266a714fe90adfd243aa22536e05e [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
25 gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache
26 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027fi
28}
29
30gtk_immodule_cache_postrm() {
31if [ "x$D" != "x" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080032 $INTERCEPT_DIR/postinst_intercept update_gtk_immodules_cache ${PKG} \
33 mlprefix=${MLPREFIX} \
34 binprefix=${MLPREFIX} \
35 libdir=${libdir} \
36 libexecdir=${libexecdir} \
37 base_libdir=${base_libdir} \
38 bindir=${bindir}
39else
40 if [ ! -z `which gtk-query-immodules-2.0` ]; then
41 gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache
42 fi
43 if [ ! -z `which gtk-query-immodules-3.0` ]; then
44 gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache
45 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046fi
47}
48
49python populate_packages_append () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050050 gtkimmodules_pkgs = d.getVar('GTKIMMODULES_PACKAGES').split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051
52 for pkg in gtkimmodules_pkgs:
53 bb.note("adding gtk-immodule-cache postinst and postrm scripts to %s" % pkg)
54
Brad Bishop6e60e8b2018-02-01 10:27:11 -050055 postinst = d.getVar('pkg_postinst_%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056 if not postinst:
57 postinst = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050058 postinst += d.getVar('gtk_immodule_cache_postinst')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059 d.setVar('pkg_postinst_%s' % pkg, postinst)
60
Brad Bishop6e60e8b2018-02-01 10:27:11 -050061 postrm = d.getVar('pkg_postrm_%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062 if not postrm:
63 postrm = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064 postrm += d.getVar('gtk_immodule_cache_postrm')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065 d.setVar('pkg_postrm_%s' % pkg, postrm)
66}
67
68python __anonymous() {
69 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
70 gtkimmodules_check = d.getVar('GTKIMMODULES_PACKAGES', False)
71 if not gtkimmodules_check:
72 bb_filename = d.getVar('FILE', False)
Patrick Williamsc0f7c042017-02-23 20:41:17 -060073 bb.fatal("ERROR: %s inherits gtk-immodules-cache but doesn't set GTKIMMODULES_PACKAGES" % bb_filename)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074}
75