Kaynağa Gözat

Fix failed install followed by failed remove resulting in installed state

After '<prerm> remove' fails and while doing the error unwinding, if
the '<postinst> abort-remove' call succeeds, preserve the old status
instead of unconditionally setting it to 'Installed'.
Brian M. Carlson 19 yıl önce
ebeveyn
işleme
ca909d6711
4 değiştirilmiş dosya ile 18 ekleme ve 2 silme
  1. 7 0
      ChangeLog
  2. 4 0
      debian/changelog
  3. 2 1
      src/cleanup.c
  4. 5 1
      src/remove.c

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+2007-09-14  Brian M. Carlson  <sandals@crustytoothpaste.ath.cx>
+
+	* src/remove.c (deferred_remove): Store the previous package status
+	when calling '<prerm> remove' and pass it to push_cleanup.
+	* src/cleanup.c (cu_prermremove): Restore previous stored status if
+	the '<postinst> abort-remove' call succeeds.
+
 2007-09-08  Guillem Jover  <guillem@debian.org>
 
 	* scripts/dpkg-buildpackage.sh: Use fakeroot, if present, as default

+ 4 - 0
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 '<prerm> remove' fails and while doing the error unwinding, if
+    the '<postinst> 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

+ 2 - 1
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--;

+ 5 - 1
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);
     }