How to debug dpkg configure error in subprocess post-installation?

Ok, I have found the solution for this problem. Thought I was unable to crank up the logging to get more data, the data already presented had the clue to the problem.

dpkg: error processing spamassassin (--configure):
subprocess installed post-installation script returned error exit status 1

says dpkg encountered an error processing spamassassin while running configure. Next line tels us the post-installation script did not finish correct.

In the /var/lib/dpkg/info dir we can locate the script files of dpkg, the file: spamassassin.postinst gives us the script file which generated the error.

Within this file we know we have to look at the code runned by configure:

if [ "$1" = "configure" ]; then

and after some debugging I found out the line:

su debian-spamd -c "sa-update --gpghomedir /var/lib/spamassassin/sa-update-keys \ --import /usr/share/spamassassin/GPG.KEY"

returned exit code 1 (run command @commandline and use echo $? next to get the exit code)

The problem was that the user debian-spamd already existed on my system but its login shell was /bin/false. Su-ing with /bin/false returns without any message but exitcode 1.

Adding -s /bin/sh to the command solved the problem though in the end I did alter the login shell of the user to stay in sync with future updates.


Generally to debug such issues, you would edit /var/lib/dpkg/info/spamassassin.postinst (or .preinst, pr .prerm or .postrm; depending on which one is failing) and change #!/bin/sh at the top line to #!/bin/sh -x (same thing if it bash instead: just add -x)

That would provide you with line-by-line debug of shell script, so you could tell where it exits with non-zero code (causing the installation/upgrade to fail).

It would probably require at least some shell scripting skills to debug, though.

Tags:

Dpkg