Debugging Debian package installations

I've upgraded my postfix Debian package from 2.2.4-1.0.1 to 2.2.6-1. This didn't succeed immediately. I am not quite sure what caused the trouble: either a bug in the postfix packaging, or a corruption of my debconf database, caused by some other problem. Anyway, in order to fix the problem I had to dive into Debian packageinstall debugging voodoo. Here's what I've seen:

  root@nagy:~# aptitude dist-upgrade
  Setting up postfix (2.2.6-1) ...
  dpkg: error processing postfix (--configure):
   subprocess post-installation script returned error exit status 10
  Errors were encountered while processing:

And here's what I've done: Let's debug the --configure-phase:

  root@nagy:~# dpkg -D777 --configure postfix
  D000040: ok 2 msgs >><<
  Setting up postfix (2.2.6-1) ...
  D000002: fork/exec /var/lib/dpkg/info/postfix.postinst ( configure 2.2.4-1.0.1 )

OK, the postinst script causes trouble, let's run that in verbose mode:

  root@nagy:~# sh -x /var/lib/dpkg/info/postfix.postinst configure 2.2.4-1.0.1
  + . /usr/share/debconf/confmodule
  + [ !  ]
  + export PERL_DL_NONLAZY
  + exec /usr/share/debconf/frontend /var/lib/dpkg/info/postfix.postinst configure 2.2.4-1.0.1

Aha, this script fails while running debconf. Let's run debconf in debugging mode:

  root@nagy:~# DEBCONF_DEBUG=developer /usr/share/debconf/frontend /var/lib/dpkg/info/postfix.postinst configure 2.2.4-1.0.1
  debconf (developer): <-- FSET postfix/root_address changed false
  debconf (developer): --> 0 false
  debconf (developer): <-- FSET postfix/destinations changed false
  debconf (developer): --> 10 postfix/destinations doesn't exist

Hrm, it seems our debconf database lacks a postfix setting. Let's fix this in a quick-and-dirty way:

  root@nagy:/var/cache/debconf# vi config.dat
  root@nagy:/var/cache/debconf# diff -u config.dat.orig config.dat
  --- config.dat.orig     2005-12-14 14:52:07.530481383 +0100
  +++ config.dat  2005-12-14 14:57:37.868350290 +0100
  @@ -1293,6 +1293,10 @@
   Template: passwd/username-bad
   Owners: passwd

  +Name: postfix/destinations
  +Template: postfix/destinations
  +Owners: postfix
   Name: postfix/bad_recipient_delimiter
   Template: postfix/bad_recipient_delimiter
   Owners: postfix

Did this help? Yes:

  root@nagy:~# aptitude install postfix
  Setting up postfix (2.2.6-1) ...

Joost van Baal, December 2005

PS: Роман "CoolCold" Овчинников (aka Roman Ovchinnikov) told me on FreeNode IRC, on April 1, 2011 it's probably better not to run

   DEBCONF_DEBUG=developer /usr/share/debconf/frontend /var/lib/dpkg/info/postfix.postinst configure 2.2.4-1.0.1

but to run

   DEBCONF_DEBUG=developer dpkg -D777 --configure postfix

instead, since this takes care of properly setting variables like ERL_DL_NONLAZY=1 e.a. Thanks Роман! Valid XHTML 1.1