lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [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 | PACKAGE_WRITE_DEPS += "qemu-native" |
| 6 | |
| 7 | inherit qemu |
| 8 | |
| 9 | GTKIMMODULES_PACKAGES ?= "${PN}" |
| 10 | |
| 11 | gtk_immodule_cache_postinst() { |
| 12 | if [ "x$D" != "x" ]; then |
| 13 | $INTERCEPT_DIR/postinst_intercept update_gtk_immodules_cache ${PKG} \ |
| 14 | mlprefix=${MLPREFIX} \ |
| 15 | binprefix=${MLPREFIX} \ |
| 16 | libdir=${libdir} \ |
| 17 | libexecdir=${libexecdir} \ |
| 18 | base_libdir=${base_libdir} \ |
| 19 | bindir=${bindir} |
| 20 | else |
| 21 | if [ ! -z `which gtk-query-immodules-2.0` ]; then |
| 22 | gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache |
| 23 | fi |
| 24 | if [ ! -z `which gtk-query-immodules-3.0` ]; then |
| 25 | mkdir -p ${libdir}/gtk-3.0/3.0.0 |
| 26 | gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache |
| 27 | fi |
| 28 | fi |
| 29 | } |
| 30 | |
| 31 | gtk_immodule_cache_postrm() { |
| 32 | if [ "x$D" != "x" ]; then |
| 33 | $INTERCEPT_DIR/postinst_intercept update_gtk_immodules_cache ${PKG} \ |
| 34 | mlprefix=${MLPREFIX} \ |
| 35 | binprefix=${MLPREFIX} \ |
| 36 | libdir=${libdir} \ |
| 37 | libexecdir=${libexecdir} \ |
| 38 | base_libdir=${base_libdir} \ |
| 39 | bindir=${bindir} |
| 40 | else |
| 41 | if [ ! -z `which gtk-query-immodules-2.0` ]; then |
| 42 | gtk-query-immodules-2.0 > ${libdir}/gtk-2.0/2.10.0/immodules.cache |
| 43 | fi |
| 44 | if [ ! -z `which gtk-query-immodules-3.0` ]; then |
| 45 | gtk-query-immodules-3.0 > ${libdir}/gtk-3.0/3.0.0/immodules.cache |
| 46 | fi |
| 47 | fi |
| 48 | } |
| 49 | |
| 50 | python populate_packages_append () { |
| 51 | gtkimmodules_pkgs = d.getVar('GTKIMMODULES_PACKAGES').split() |
| 52 | |
| 53 | for pkg in gtkimmodules_pkgs: |
| 54 | bb.note("adding gtk-immodule-cache postinst and postrm scripts to %s" % pkg) |
| 55 | |
| 56 | postinst = d.getVar('pkg_postinst_%s' % pkg) |
| 57 | if not postinst: |
| 58 | postinst = '#!/bin/sh\n' |
| 59 | postinst += d.getVar('gtk_immodule_cache_postinst') |
| 60 | d.setVar('pkg_postinst_%s' % pkg, postinst) |
| 61 | |
| 62 | postrm = d.getVar('pkg_postrm_%s' % pkg) |
| 63 | if not postrm: |
| 64 | postrm = '#!/bin/sh\n' |
| 65 | postrm += d.getVar('gtk_immodule_cache_postrm') |
| 66 | d.setVar('pkg_postrm_%s' % pkg, postrm) |
| 67 | } |
| 68 | |
| 69 | python __anonymous() { |
| 70 | if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d): |
| 71 | gtkimmodules_check = d.getVar('GTKIMMODULES_PACKAGES', False) |
| 72 | if not gtkimmodules_check: |
| 73 | bb_filename = d.getVar('FILE', False) |
| 74 | bb.fatal("ERROR: %s inherits gtk-immodules-cache but doesn't set GTKIMMODULES_PACKAGES" % bb_filename) |
| 75 | } |
| 76 | |