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 |
| 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 |
| 25 | fi |
| 26 | if [ ! -z `which gtk-query-immodules-2.0` ]; then |
| 27 | gtk-query-immodules-2.0 > /etc/gtk-2.0/gtk.immodules |
| 28 | fi |
| 29 | if [ ! -z `which gtk-query-immodules-3.0` ]; then |
| 30 | gtk-query-immodules-3.0 > /etc/gtk-3.0/gtk.immodules |
| 31 | fi |
| 32 | } |
| 33 | |
| 34 | gtk_immodule_cache_postrm() { |
| 35 | if [ "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 |
| 48 | fi |
| 49 | if [ ! -z `which gtk-query-immodules-2.0` ]; then |
| 50 | gtk-query-immodules-2.0 > /etc/gtk-2.0/gtk.immodules |
| 51 | fi |
| 52 | if [ ! -z `which gtk-query-immodules-3.0` ]; then |
| 53 | gtk-query-immodules-3.0 > /etc/gtk-3.0/gtk.immodules |
| 54 | fi |
| 55 | } |
| 56 | |
| 57 | python 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 | |
| 76 | python __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 | |