Package: dpkg Version: 1.15.3.1 Hello,
I debugged a failure in ubuntu today where the package "update-motd" was updated to a new version that contained no files (that was intentional, the package was supposed to go away) [1]. Dpkg noticed that the package was empty and purged it during (after?) apt ran it with --unpack. Later apt tried to configure the package (because in its worldview the package was a upgrade so it needs a --unpack and then a --configure). This failed because the package was no longer there. I would like to ask for a new force option that apt can use to turn this into a non-fatal error. Either a --force-no-purge-if-empty (or something similar) or a more broader --force-configure-bad (or a better matching name). I implemented the later and will attach it to this bugreport. But I'm also happy to do the former or solve it in a different way. The patch is against the current ubuntu version of dpkg, but it applies to current git. Cheers, Michael [1] https://bugs.launchpad.net/ubuntu/+source/update-motd/+bug/400462
diff -Nru dpkg-1.15.3.1ubuntu1/src/configure.c dpkg-1.15.3.1ubuntu2/src/configure.c --- dpkg-1.15.3.1ubuntu1/src/configure.c 2009-07-08 18:44:31.000000000 +0200 +++ dpkg-1.15.3.1ubuntu2/src/configure.c 2009-07-17 11:11:17.000000000 +0200 @@ -90,15 +90,26 @@ struct stat stab; enum conffopt what; static const char *EMPTY_HASH = "-"; - - if (pkg->status == stat_notinstalled) - ohshit(_("no package named `%s' is installed, cannot configure"),pkg->name); - if (pkg->status == stat_installed) - ohshit(_("package %.250s is already installed and configured"), pkg->name); - if (pkg->status != stat_unpacked && pkg->status != stat_halfconfigured) - ohshit(_("package %.250s is not ready for configuration\n" - " cannot configure (current status `%.250s')"), - pkg->name, statusinfos[pkg->status].name); + + if (pkg->status == stat_notinstalled) { + forcibleerr(fc_configurebad, + _("no package named `%s' is installed, cannot " + "configure"),pkg->name); + return; + } + if (pkg->status == stat_installed) { + forcibleerr(fc_configurebad, + _("package %.250s is already installed and " + "configured"), pkg->name); + return; + } + if (pkg->status != stat_unpacked && pkg->status != stat_halfconfigured) { + forcibleerr(fc_configurebad, + _("package %.250s is not ready for configuration\n" + " cannot configure (current status `%.250s')"), + pkg->name, statusinfos[pkg->status].name); + return; + } if (dependtry > 1) if (findbreakcycle(pkg)) diff -Nru dpkg-1.15.3.1ubuntu1/src/main.c dpkg-1.15.3.1ubuntu2/src/main.c --- dpkg-1.15.3.1ubuntu1/src/main.c 2009-07-08 11:06:39.000000000 +0200 +++ dpkg-1.15.3.1ubuntu2/src/main.c 2009-07-17 10:56:11.000000000 +0200 @@ -167,7 +167,7 @@ int f_triggers = 0; unsigned long f_debug=0; /* Change fc_overwrite to 1 to enable force-overwrite by default */ -int fc_downgrade=1, fc_configureany=0, fc_hold=0, fc_removereinstreq=0, fc_overwrite=0; +int fc_downgrade=1, fc_configureany=0, fc_configurebad=0, fc_hold=0, fc_removereinstreq=0, fc_overwrite=0; int fc_removeessential=0, fc_conflicts=0, fc_depends=0, fc_dependsversion=0; int fc_breaks=0, fc_badpath=0, fc_overwritediverted=0, fc_architecture=0; int fc_nonroot=0, fc_overwritedir=0, fc_conff_new=0, fc_conff_miss=0; @@ -185,6 +185,7 @@ } forceinfos[]= { { "downgrade", &fc_downgrade }, { "configure-any", &fc_configureany }, + { "configure-bad", &fc_configurebad }, { "hold", &fc_hold }, { "remove-reinstreq", &fc_removereinstreq }, { "remove-essential", &fc_removeessential }, diff -Nru dpkg-1.15.3.1ubuntu1/src/main.h dpkg-1.15.3.1ubuntu2/src/main.h --- dpkg-1.15.3.1ubuntu1/src/main.h 2009-07-08 11:06:40.000000000 +0200 +++ dpkg-1.15.3.1ubuntu2/src/main.h 2009-07-17 11:02:53.000000000 +0200 @@ -89,7 +89,7 @@ extern int f_autodeconf, f_nodebsig; extern int f_triggers; extern unsigned long f_debug; -extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, fc_overwrite; +extern int fc_downgrade, fc_configureany, fc_configurebad, fc_hold, fc_removereinstreq, fc_overwrite; extern int fc_removeessential, fc_conflicts, fc_depends, fc_dependsversion; extern int fc_breaks, fc_badpath, fc_overwritediverted, fc_architecture; extern int fc_nonroot, fc_overwritedir, fc_conff_new, fc_conff_miss;