Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # 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 | |
| 5 | DEPENDS =+ "qemu-native" |
| 6 | |
| 7 | inherit qemu |
| 8 | |
| 9 | GTKIMMODULES_PACKAGES ?= "${PN}" |
| 10 | |
| 11 | gtk_immodule_cache_postinst() { |
| 12 | if [ "x$D" != "x" ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 13 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 25 | [ $? -ne 0 ] && exit 1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 26 | exit 0 |
| 27 | fi |
| 28 | if [ ! -z `which gtk-query-immodules-2.0` ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 29 | gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | fi |
| 31 | if [ ! -z `which gtk-query-immodules-3.0` ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 32 | gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 33 | fi |
| 34 | } |
| 35 | |
| 36 | gtk_immodule_cache_postrm() { |
| 37 | if [ "x$D" != "x" ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 38 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 48 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 49 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 50 | [ $? -ne 0 ] && exit 1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | exit 0 |
| 52 | fi |
| 53 | if [ ! -z `which gtk-query-immodules-2.0` ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 54 | gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | fi |
| 56 | if [ ! -z `which gtk-query-immodules-3.0` ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 57 | gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 58 | fi |
| 59 | } |
| 60 | |
| 61 | python 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 | |
| 80 | python __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 | |