#!/bin/sh
# Maintainer script of the generated rcalc .deb (see scripts/build-deb.sh).
set -e

case "$1" in
    configure)
        ;;
    abort-upgrade|abort-remove|abort-deconfigure)
        exit 0
        ;;
    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
        ;;
esac

# Refresh the XDG caches. Never fail the installation because of them: the
# tools may be absent (minimal systems, chroot, dpkg -x in a container).
if command -v update-desktop-database >/dev/null 2>&1; then
    update-desktop-database -q /usr/share/applications || true
fi

if command -v gtk-update-icon-cache >/dev/null 2>&1; then
    gtk-update-icon-cache -q -t -f /usr/share/icons/hicolor || true
fi

if command -v appstreamcli >/dev/null 2>&1; then
    appstreamcli refresh --force >/dev/null 2>&1 || true
fi

exit 0
