blob: 0a6316da47d25a606aa90e821f2f23d8e966067b [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
13 for maj_ver in 2 3; do
14 if [ -x $D${bindir}/gtk-query-immodules-$maj_ver.0 ]; then
15 IMFILES=$(ls $D${libdir}/gtk-$maj_ver.0/*/immodules/*.so)
16 ${@qemu_run_binary(d, '$D', '${bindir}/gtk-query-immodules-$maj_ver.0')} \
17 $IMFILES > $D/etc/gtk-$maj_ver.0/gtk.immodules 2>/dev/null &&
18 sed -i -e "s:$D::" $D/etc/gtk-$maj_ver.0/gtk.immodules
19
20 [ $? -ne 0 ] && exit 1
21 fi
22 done
23
24 exit 0
25fi
26if [ ! -z `which gtk-query-immodules-2.0` ]; then
27 gtk-query-immodules-2.0 > /etc/gtk-2.0/gtk.immodules
28fi
29if [ ! -z `which gtk-query-immodules-3.0` ]; then
30 gtk-query-immodules-3.0 > /etc/gtk-3.0/gtk.immodules
31fi
32}
33
34gtk_immodule_cache_postrm() {
35if [ "x$D" != "x" ]; then
36 for maj_ver in 2 3; do
37 if [ -x $D${bindir}/gtk-query-immodules-$maj_ver.0 ]; then
38 IMFILES=$(ls $D${libdir}/gtk-$maj_ver.0/*/immodules/*.so)
39 ${@qemu_run_binary(d, '$D', '${bindir}/gtk-query-immodules-$maj_ver.0')} \
40 $IMFILES > $D/etc/gtk-$maj_ver.0/gtk.immodules 2>/dev/null &&
41 sed -i -e "s:$D::" $D/etc/gtk-$maj_ver.0/gtk.immodules
42
43 [ $? -ne 0 ] && exit 1
44 fi
45 done
46
47 exit 0
48fi
49if [ ! -z `which gtk-query-immodules-2.0` ]; then
50 gtk-query-immodules-2.0 > /etc/gtk-2.0/gtk.immodules
51fi
52if [ ! -z `which gtk-query-immodules-3.0` ]; then
53 gtk-query-immodules-3.0 > /etc/gtk-3.0/gtk.immodules
54fi
55}
56
57python populate_packages_append () {
58 gtkimmodules_pkgs = d.getVar('GTKIMMODULES_PACKAGES', True).split()
59
60 for pkg in gtkimmodules_pkgs:
61 bb.note("adding gtk-immodule-cache postinst and postrm scripts to %s" % pkg)
62
63 postinst = d.getVar('pkg_postinst_%s' % pkg, True)
64 if not postinst:
65 postinst = '#!/bin/sh\n'
66 postinst += d.getVar('gtk_immodule_cache_postinst', True)
67 d.setVar('pkg_postinst_%s' % pkg, postinst)
68
69 postrm = d.getVar('pkg_postrm_%s' % pkg, True)
70 if not postrm:
71 postrm = '#!/bin/sh\n'
72 postrm += d.getVar('gtk_immodule_cache_postrm', True)
73 d.setVar('pkg_postrm_%s' % pkg, postrm)
74}
75
76python __anonymous() {
77 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
78 gtkimmodules_check = d.getVar('GTKIMMODULES_PACKAGES', False)
79 if not gtkimmodules_check:
80 bb_filename = d.getVar('FILE', False)
81 raise bb.build.FuncFailed("ERROR: %s inherits gtk-immodules-cache but doesn't set GTKIMMODULES_PACKAGES" % bb_filename)
82}
83