blob: 3d82dbe9e3421e695e580d70e285420ba9fc4506 [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
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
Patrick Williamsc0f7c042017-02-23 20:41:17 -060018 fi
19 if [ -x $D${bindir}/gtk-query-immodules-3.0 ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050020 IMFILES=$(ls $D${libdir}/gtk-3.0/*/immodules/*.so)
21 ${@qemu_run_binary(d, '$D', '${bindir}/gtk-query-immodules-3.0')} \
22 $IMFILES > $D${libdir}/gtk-3.0/3.0.0/immodules.cache 2>/dev/null &&
23 sed -i -e "s:$D::" $D${libdir}/gtk-3.0/3.0.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050026 [ $? -ne 0 ] && exit 1
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027 exit 0
28fi
29if [ ! -z `which gtk-query-immodules-2.0` ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050030 gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031fi
32if [ ! -z `which gtk-query-immodules-3.0` ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050033 gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034fi
35}
36
37gtk_immodule_cache_postrm() {
38if [ "x$D" != "x" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050039 if [ -x $D${bindir}/gtk-query-immodules-2.0 ]; then
40 IMFILES=$(ls $D${libdir}/gtk-2.0/*/immodules/*.so)
41 ${@qemu_run_binary(d, '$D', '${bindir}/gtk-query-immodules-2.0')} \
42 $IMFILES > $D${libdir}/gtk-2.0/2.10.0/immodules.cache 2>/dev/null &&
43 sed -i -e "s:$D::" $D${libdir}/gtk-2.0/2.10.0/immodules.cache
Patrick Williamsc0f7c042017-02-23 20:41:17 -060044 fi
45 if [ -x $D${bindir}/gtk-query-immodules-3.0 ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050046 IMFILES=$(ls $D${libdir}/gtk-3.0/*/immodules/*.so)
47 ${@qemu_run_binary(d, '$D', '${bindir}/gtk-query-immodules-3.0')} \
48 $IMFILES > $D${libdir}/gtk-3.0/3.0.0/immodules.cache 2>/dev/null &&
49 sed -i -e "s:$D::" $D${libdir}/gtk-3.0/3.0.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050052 [ $? -ne 0 ] && exit 1
Patrick Williamsc124f4f2015-09-15 14:41:29 -050053 exit 0
54fi
55if [ ! -z `which gtk-query-immodules-2.0` ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050056 gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057fi
58if [ ! -z `which gtk-query-immodules-3.0` ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050059 gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060fi
61}
62
63python populate_packages_append () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064 gtkimmodules_pkgs = d.getVar('GTKIMMODULES_PACKAGES').split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065
66 for pkg in gtkimmodules_pkgs:
67 bb.note("adding gtk-immodule-cache postinst and postrm scripts to %s" % pkg)
68
Brad Bishop6e60e8b2018-02-01 10:27:11 -050069 postinst = d.getVar('pkg_postinst_%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050070 if not postinst:
71 postinst = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050072 postinst += d.getVar('gtk_immodule_cache_postinst')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073 d.setVar('pkg_postinst_%s' % pkg, postinst)
74
Brad Bishop6e60e8b2018-02-01 10:27:11 -050075 postrm = d.getVar('pkg_postrm_%s' % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050076 if not postrm:
77 postrm = '#!/bin/sh\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050078 postrm += d.getVar('gtk_immodule_cache_postrm')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079 d.setVar('pkg_postrm_%s' % pkg, postrm)
80}
81
82python __anonymous() {
83 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
84 gtkimmodules_check = d.getVar('GTKIMMODULES_PACKAGES', False)
85 if not gtkimmodules_check:
86 bb_filename = d.getVar('FILE', False)
Patrick Williamsc0f7c042017-02-23 20:41:17 -060087 bb.fatal("ERROR: %s inherits gtk-immodules-cache but doesn't set GTKIMMODULES_PACKAGES" % bb_filename)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088}
89