From: Brian M. Carlson Date: Fri, 14 Sep 2007 05:24:56 +0000 (+0300) Subject: Fix failed install followed by failed remove resulting in installed state X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca909d6711804e51f48415d31aa2fc630943cd03;p=dpkg Fix failed install followed by failed remove resulting in installed state After ' remove' fails and while doing the error unwinding, if the ' abort-remove' call succeeds, preserve the old status instead of unconditionally setting it to 'Installed'. --- diff --git a/ChangeLog b/ChangeLog index 598af202..b76379c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-09-14 Brian M. Carlson + + * src/remove.c (deferred_remove): Store the previous package status + when calling ' remove' and pass it to push_cleanup. + * src/cleanup.c (cu_prermremove): Restore previous stored status if + the ' abort-remove' call succeeds. + 2007-09-08 Guillem Jover * scripts/dpkg-buildpackage.sh: Use fakeroot, if present, as default diff --git a/debian/changelog b/debian/changelog index c461eebc..2893b1b0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,10 @@ dpkg (1.14.7) UNRELEASED; urgency=low dpkg-buildpackage. * Fix typos in dpkg-deb.1 and start-stop-daemon.8. Closes: #441051 Thanks to A. Costa. + * After ' remove' fails and while doing the error unwinding, if + the ' abort-remove' call succeeds, preserve the old status + instead of unconditionally setting it to 'Installed'. Closes: #432893 + Thanks to Brian M. Carlson. [ Updated dpkg translations ] * Portuguese (Miguel Figueiredo). Closes: #441113 diff --git a/src/cleanup.c b/src/cleanup.c index 108ee2c1..d1ebb68a 100644 --- a/src/cleanup.c +++ b/src/cleanup.c @@ -233,11 +233,12 @@ void cu_postrmupgrade(int argc, void **argv) { void cu_prermremove(int argc, void **argv) { struct pkginfo *pkg= (struct pkginfo*)argv[0]; + enum pkgstatus *oldpkgstatus= (enum pkgstatus*)argv[1]; if (cleanup_pkg_failed++) return; maintainer_script_installed(pkg,POSTINSTFILE,"post-installation", "abort-remove", NULL); - pkg->status= stat_installed; + pkg->status= *oldpkgstatus; pkg->eflag &= ~eflagf_reinstreq; modstatdb_note(pkg); cleanup_pkg_failed--; diff --git a/src/remove.c b/src/remove.c index abcfc9ff..b0fea250 100644 --- a/src/remove.c +++ b/src/remove.c @@ -166,9 +166,13 @@ void deferred_remove(struct pkginfo *pkg) { if (pkg->status == stat_halfconfigured || pkg->status == stat_installed) { if (pkg->status == stat_installed || pkg->status == stat_halfconfigured) { + static enum pkgstatus oldpkgstatus; + + oldpkgstatus= pkg->status; pkg->status= stat_halfconfigured; modstatdb_note(pkg); - push_cleanup(cu_prermremove,~ehflag_normaltidy, 0,0, 1,(void*)pkg); + push_cleanup(cu_prermremove, ~ehflag_normaltidy, 0, 0, 2, + (void *)pkg, (void *)&oldpkgstatus); maintainer_script_installed(pkg, PRERMFILE, "pre-removal", "remove", NULL); }