On Thu, Sep 13, 2007 at 01:18:14AM +0200, Kurt Roeckx wrote:
> 
> You're right, this seems to be rather confusing.  I think what it's
> trying to say is if abort-remove fails, set to Failed-Config, else keep
> the (Installed) state.  It should probably also keep the other states.
> 
> You could also argue that if abort-remove was succesful, it should be in
> installed state, and that abort-remove in most cases should do the same
> as configure.  But as far as I understand things, abort-remove should
> only undo what the prerm remove did, which isn't the same as configuring
> it.

AIUI, for most packages, calls of the postinst are identical; that is,
the postinst always does the same thing.  However, in the abstract, I
agree.

> Does it (allow to) call the prerm in Config-files or Half-installed
> state?  I think in Config-files state, you probably want to keep it, and
> if my memory is good it doesn't allow you to remove the package in
> Half-installed state.  If that's the case, the 
> state = abort_remove_ok?prev_state:failed_config; looks right to me.

I believe config-files doesn't call the prerm, just the postrm (seeing
as policy claims the prerm doesn't exist anymore), and I also remember
that half-installed requires a reinstallation first.

Therefore, I've attached another patch (instead of the previous one) or
the top two patches from the git repository:
git://crustytoothpaste.ath.cx/bmc/repo/dpkg.git master

> We should probably open a bug against policy to make this more clear.

Please do.  I'm not a DD, so I have no authority to request changes to
policy.  I think a complete state diagram might be useful, but I don't
really want to expend the effort to create one.

-- 
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..7b9c271 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-09-12  brian m. carlson  <[EMAIL PROTECTED]>
+
+	* src/cleanup.c (cu_prermremove): Set status to half-configured
+	when abort-remove fails.
+
+2007-09-12  brian m. carlson  <[EMAIL PROTECTED]>
+
+	* src/remove.c (deferred_remove): Save old package status when
+	removing packages.
+	* src/cleanup.c (cu_prermremove): 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..01829af 100644
--- a/src/cleanup.c
+++ b/src/cleanup.c
@@ -233,12 +233,13 @@ 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;
+  if (cleanup_pkg_failed++) { pkg->status= stat_halfconfigured; return; }
+  pkg->status= *oldpkgstatus;
+  pkg->eflag &= ~eflagf_reinstreq;
   maintainer_script_installed(pkg,POSTINSTFILE,"post-installation",
                               "abort-remove", NULL);
-  pkg->status= stat_installed;
-  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