# old version (without -$pkgrel): ${1%%-*}
# new version (without -$pkgrel): ${2%%-*}

PKGNAME="jcpkcs11-2"

# arg 1:  the new package version
pre_install() {
    pre_upgrade $@
}

# arg 1:  the new package version
post_install() {
    post_upgrade $@
}

# arg 1:  the new package version
# arg 2:  the old package version
pre_upgrade() {
    true
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
    bash /usr/lib/${PKGNAME}/update_all_plists.sh
    systemctl --quiet restart systemd-udevd.service &>/dev/null
    if which systemctl >/dev/null 2>&1; then
	systemctl --quiet enable pcscd.socket &>/dev/null
        systemctl --quiet restart pcscd.socket pcscd.service &>/dev/null
    elif [[ -f /etc/init.d/pcscd ]]; then
        /etc/init.d/pcscd enable >/dev/null 2>&1
        /etc/init.d/pcscd restart >/dev/null 2>&1
    fi
    which ldconfig >/dev/null 2>&1 && ldconfig 2>/dev/null
    return 0
}

# arg 1:  the old package version
pre_remove() {
    which ldconfig >/dev/null 2>&1 && ldconfig 2>/dev/null
    return 0
}

# arg 1:  the old package version
post_remove() {
    true
}
