blob: 8fbe1dd1fb4adbb958d4f133b0c8c248cd45d5bd [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7# This class will update the inputmethod module cache for virtual keyboards
8#
9# Usage: Set GTKIMMODULES_PACKAGES to the packages that needs to update the inputmethod modules
10
11PACKAGE_WRITE_DEPS += "qemu-native"
12
13inherit qemu
14
15GTKIMMODULES_PACKAGES ?= "${PN}"
16
17gtk_immodule_cache_postinst() {
18if [ "x$D" != "x" ]; then
19 $INTERCEPT_DIR/postinst_intercept update_gtk_immodules_cache ${PKG} \
20 mlprefix=${MLPREFIX} \
21 binprefix=${MLPREFIX} \
22 libdir=${libdir} \
23 libexecdir=${libexecdir} \
24 base_libdir=${base_libdir} \
25 bindir=${bindir}
26else
27 if [ ! -z `which gtk-query-immodules-2.0` ]; then
28 gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache
29 fi
30 if [ ! -z `which gtk-query-immodules-3.0` ]; then
31 mkdir -p ${libdir}/gtk-3.0/3.0.0
32 gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache
33 fi
34fi
35}
36
37gtk_immodule_cache_postrm() {
38if [ "x$D" != "x" ]; then
39 $INTERCEPT_DIR/postinst_intercept update_gtk_immodules_cache ${PKG} \
40 mlprefix=${MLPREFIX} \
41 binprefix=${MLPREFIX} \
42 libdir=${libdir} \
43 libexecdir=${libexecdir} \
44 base_libdir=${base_libdir} \
45 bindir=${bindir}
46else
47 if [ ! -z `which gtk-query-immodules-2.0` ]; then
48 gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache
49 fi
50 if [ ! -z `which gtk-query-immodules-3.0` ]; then
51 gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache
52 fi
53fi
54}
55
56python populate_packages:append () {
57 gtkimmodules_pkgs = d.getVar('GTKIMMODULES_PACKAGES').split()
58
59 for pkg in gtkimmodules_pkgs:
60 bb.note("adding gtk-immodule-cache postinst and postrm scripts to %s" % pkg)
61
62 postinst = d.getVar('pkg_postinst:%s' % pkg)
63 if not postinst:
64 postinst = '#!/bin/sh\n'
65 postinst += d.getVar('gtk_immodule_cache_postinst')
66 d.setVar('pkg_postinst:%s' % pkg, postinst)
67
68 postrm = d.getVar('pkg_postrm:%s' % pkg)
69 if not postrm:
70 postrm = '#!/bin/sh\n'
71 postrm += d.getVar('gtk_immodule_cache_postrm')
72 d.setVar('pkg_postrm:%s' % pkg, postrm)
73}
74
75python __anonymous() {
76 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
77 gtkimmodules_check = d.getVar('GTKIMMODULES_PACKAGES', False)
78 if not gtkimmodules_check:
79 bb_filename = d.getVar('FILE', False)
80 bb.fatal("ERROR: %s inherits gtk-immodules-cache but doesn't set GTKIMMODULES_PACKAGES" % bb_filename)
81}
82