#!/bin/sh
# Both addons must load with every symbol resolved against the installed fcitx5 libraries.
set -e

libs=$(dpkg -L fcitx5-ngosen | grep '/fcitx5/[^/]*\.so$')
[ -n "$libs" ] || { echo "no addon library installed" >&2; exit 1; }
for lib in $libs; do
    python3 -c 'import ctypes, os, sys; ctypes.CDLL(sys.argv[1], os.RTLD_NOW)' "$lib"
    echo "loaded $lib"
done
test -f /usr/share/fcitx5/addon/ngosen.conf
test -f /usr/share/fcitx5/inputmethod/ngosen.conf
