package dpkg
tags 432893 + patch
kthxbye

Attached is a patch that *should* fix this bug.  It simply restores the
previous state of a package when a removal fails, instead of simply
setting it to installed.  Preliminary testing seems to confirm that this
works.  A changelog entry is also included.

You may also find the patch as the top commit on
git://crustytoothpaste.ath.cx/bmc/repo/dpkg.git master

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 713 440 7475 | http://crustytoothpaste.ath.cx/~bmc | My opinion only
OpenPGP: RSA v4 4096b 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
diff --git a/ChangeLog b/ChangeLog
index 598af20..a11914a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-09-12  brian m. carlson  <[EMAIL PROTECTED]>
+
+	* src/remove.c: Save old package status when removing packages.
+	* src/cleanup.c: Restore old package status when removal fails.
+
 2007-09-08  Guillem Jover  <[EMAIL PROTECTED]>
 
 	* scripts/dpkg-buildpackage.sh: Use fakeroot, if present, as default
diff --git a/src/cleanup.c b/src/cleanup.c
index 108ee2c..ac03842 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 abcfc9f..b5f10fa 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -84,9 +84,11 @@ void deferred_remove(struct pkginfo *pkg) {
   struct varbuf raemsgs;
   int rok;
   struct dependency *dep;
+  static enum pkgstatus oldpkgstatus;
 
   debug(dbg_general,"deferred_remove package %s",pkg->name);
   
+  oldpkgstatus= pkg->status;
   if (pkg->status == stat_notinstalled) {
     fprintf(stderr,
             _("dpkg - warning: ignoring request to remove %.250s which isn't installed.\n"),
@@ -168,7 +170,8 @@ void deferred_remove(struct pkginfo *pkg) {
     if (pkg->status == stat_installed || pkg->status == stat_halfconfigured) {
       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);
     }

Attachment: signature.asc
Description: Digital signature

Reply via email to