When writing debian packages, sometimes things go wrong in the postinst stage. An error like “the postinstallation script returned an error code of 1″ will occur. This is not very informative.
If you want to debug postinst scripts, you can easily do this on the machine where you (half) installed the package. Normally you can execute /var/lib/dpkg/info/foo.postinst like this:
sh -x /var/lib/dpkg/info/foo.postinst configure
However, if you use debconf, the output will be like this:
+ . /usr/share/debconf/confmodule
+ [ ! ]
+ PERL_DL_NONLAZY=1
+ export PERL_DL_NONLAZY
+ [ ]
+ exec /usr/share/debconf/frontend /var/lib/dpkg/info/foo.postinst
Which is not helpful either. However, you can add “set -x” in /var/lib/dpkg/info/foo.postinst and then just execute it, it will give you the full output.
sh /var/lib/dpkg/info/foo.postinst configure
Now the debugging process can begin!