How force remove when post-installation script always fail

Solution 1:

You may need to manually remove the package using:

sudo dpkg --purge --force-all package

Replace package with the name of the package.

Do note: its recommended to report a bug if the package is not yours or is unknown to you what the script does.

Solution 2:

trying to remove xmail with dpkg --purge --force-all xmail failed because the pre-removal script was exiting with a failure attempting to stop the xmail daemon. I found the solution here: https://serverfault.com/questions/179570/how-to-remove-a-package-which-post-installation-and-pre-removal-script-fails

specifically, I edited /var/lib/dpkg/info/xmail.prerm and changed || exit $! to || true