#!/bin/sh
# Arg: 1
# matchbox-keyboard-im - postinst
#!/bin/sh
if [ "x$D" != "x" ]; then
    for maj_ver in 2 3; do
        if [ -x $D/usr/bin/gtk-query-immodules-$maj_ver.0 ]; then
            IMFILES=$(ls $D/usr/lib/gtk-$maj_ver.0/*/immodules/*.so)
            PSEUDO_UNLOAD=1 qemu-mips64 -r 2.6.32  -L $D -E LD_LIBRARY_PATH=$D/usr/lib:$D/lib $D/usr/bin/gtk-query-immodules-$maj_ver.0 \
                $IMFILES > $D/etc/gtk-$maj_ver.0/gtk.immodules 2>/dev/null &&
                sed -i -e "s:$D::" $D/etc/gtk-$maj_ver.0/gtk.immodules

            [ $? -ne 0 ] && exit 1
        fi
    done

    exit 0
fi
if [ ! -z `which gtk-query-immodules-2.0` ]; then
    gtk-query-immodules-2.0 > /etc/gtk-2.0/gtk.immodules
fi
if [ ! -z `which gtk-query-immodules-3.0` ]; then
    gtk-query-immodules-3.0 > /etc/gtk-3.0/gtk.immodules
fi