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 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 5 | PACKAGE_WRITE_DEPS += "qemu-native" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 18 | fi |
| 19 | if [ -x $D${bindir}/gtk-query-immodules-3.0 ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 20 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 26 | [ $? -ne 0 ] && exit 1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | exit 0 |
| 28 | fi |
| 29 | if [ ! -z `which gtk-query-immodules-2.0` ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 30 | 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] | 31 | fi |
| 32 | if [ ! -z `which gtk-query-immodules-3.0` ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 33 | 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] | 34 | fi |
| 35 | } |
| 36 | |
| 37 | gtk_immodule_cache_postrm() { |
| 38 | if [ "x$D" != "x" ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 39 | 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 Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 44 | fi |
| 45 | if [ -x $D${bindir}/gtk-query-immodules-3.0 ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 46 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 50 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 52 | [ $? -ne 0 ] && exit 1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 | exit 0 |
| 54 | fi |
| 55 | if [ ! -z `which gtk-query-immodules-2.0` ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 56 | 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] | 57 | fi |
| 58 | if [ ! -z `which gtk-query-immodules-3.0` ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 59 | 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] | 60 | fi |
| 61 | } |
| 62 | |
| 63 | python populate_packages_append () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 64 | gtkimmodules_pkgs = d.getVar('GTKIMMODULES_PACKAGES').split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 65 | |
| 66 | for pkg in gtkimmodules_pkgs: |
| 67 | bb.note("adding gtk-immodule-cache postinst and postrm scripts to %s" % pkg) |
| 68 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 69 | postinst = d.getVar('pkg_postinst_%s' % pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 70 | if not postinst: |
| 71 | postinst = '#!/bin/sh\n' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 72 | postinst += d.getVar('gtk_immodule_cache_postinst') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | d.setVar('pkg_postinst_%s' % pkg, postinst) |
| 74 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 75 | postrm = d.getVar('pkg_postrm_%s' % pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 76 | if not postrm: |
| 77 | postrm = '#!/bin/sh\n' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 78 | postrm += d.getVar('gtk_immodule_cache_postrm') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | d.setVar('pkg_postrm_%s' % pkg, postrm) |
| 80 | } |
| 81 | |
| 82 | python __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 Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 87 | bb.fatal("ERROR: %s inherits gtk-immodules-cache but doesn't set GTKIMMODULES_PACKAGES" % bb_filename) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | } |
| 89 | |