blob: c099cd38e429e12149cd4fbdc40f8457cf8be6ab [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
5DEPENDS =+ "qemu-native"
6
7inherit qemu
8
9GTKIMMODULES_PACKAGES ?= "${PN}"
10
11gtk_immodule_cache_postinst() {
12if [ "x$D" != "x" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050013 if [ -x $D${bindir}/gtk-query-immodules-2.0 ]; then
14 IMFILES=$(ls $D${libdir}/gtk-2.0/*/immodules/*.so)
15 ${@qemu_run_binary(d, '$D', '${bindir}/gtk-query-immodules-2.0')} \
16 $IMFILES > $D${libdir}/gtk-2.0/2.10.0/immodules.cache 2>/dev/null &&
17 sed -i -e "s:$D::" $D${libdir}/gtk-2.0/2.10.0/immodules.cache
18 elif [ -x $D${bindir}/gtk-query-immodules-3.0 ]; then
19 IMFILES=$(ls $D${libdir}/gtk-3.0/*/immodules/*.so)
20 ${@qemu_run_binary(d, '$D', '${bindir}/gtk-query-immodules-3.0')} \
21 $IMFILES > $D${libdir}/gtk-3.0/3.0.0/immodules.cache 2>/dev/null &&
22 sed -i -e "s:$D::" $D${libdir}/gtk-3.0/3.0.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050025 [ $? -ne 0 ] && exit 1
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 exit 0
27fi
28if [ ! -z `which gtk-query-immodules-2.0` ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050029 gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030fi
31if [ ! -z `which gtk-query-immodules-3.0` ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050032 gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033fi
34}
35
36gtk_immodule_cache_postrm() {
37if [ "x$D" != "x" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050038 if [ -x $D${bindir}/gtk-query-immodules-2.0 ]; then
39 IMFILES=$(ls $D${libdir}/gtk-2.0/*/immodules/*.so)
40 ${@qemu_run_binary(d, '$D', '${bindir}/gtk-query-immodules-2.0')} \
41 $IMFILES > $D${libdir}/gtk-2.0/2.10.0/immodules.cache 2>/dev/null &&
42 sed -i -e "s:$D::" $D${libdir}/gtk-2.0/2.10.0/immodules.cache
43 elif [ -x $D${bindir}/gtk-query-immodules-3.0 ]; then
44 IMFILES=$(ls $D${libdir}/gtk-3.0/*/immodules/*.so)
45 ${@qemu_run_binary(d, '$D', '${bindir}/gtk-query-immodules-3.0')} \
46 $IMFILES > $D${libdir}/gtk-3.0/3.0.0/immodules.cache 2>/dev/null &&
47 sed -i -e "s:$D::" $D${libdir}/gtk-3.0/3.0.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050050 [ $? -ne 0 ] && exit 1
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051 exit 0
52fi
53if [ ! -z `which gtk-query-immodules-2.0` ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050054 gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055fi
56if [ ! -z `which gtk-query-immodules-3.0` ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050057 gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058fi
59}
60
61python populate_packages_append () {
62 gtkimmodules_pkgs = d.getVar('GTKIMMODULES_PACKAGES', True).split()
63
64 for pkg in gtkimmodules_pkgs:
65 bb.note("adding gtk-immodule-cache postinst and postrm scripts to %s" % pkg)
66
67 postinst = d.getVar('pkg_postinst_%s' % pkg, True)
68 if not postinst:
69 postinst = '#!/bin/sh\n'
70 postinst += d.getVar('gtk_immodule_cache_postinst', True)
71 d.setVar('pkg_postinst_%s' % pkg, postinst)
72
73 postrm = d.getVar('pkg_postrm_%s' % pkg, True)
74 if not postrm:
75 postrm = '#!/bin/sh\n'
76 postrm += d.getVar('gtk_immodule_cache_postrm', True)
77 d.setVar('pkg_postrm_%s' % pkg, postrm)
78}
79
80python __anonymous() {
81 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
82 gtkimmodules_check = d.getVar('GTKIMMODULES_PACKAGES', False)
83 if not gtkimmodules_check:
84 bb_filename = d.getVar('FILE', False)
85 raise bb.build.FuncFailed("ERROR: %s inherits gtk-immodules-cache but doesn't set GTKIMMODULES_PACKAGES" % bb_filename)
86}
87