This is about the bug in dpkg that makes it forget /etc and /etc/defoma
belong to ttf-bitstream-vera (among others) when removing the package,
but leaving /etc/defoma/hints (which
contains /etc/defoma/hints/ttf-bitstream-vera.hints). When the defoma
packgae is purged, dpkg then complains about the directory not being
empty.

I reported earlier that Goswin's patch failed. I've now looked at it a
bit further, and attach what I think is a fixed version. Two important
differences: mine does not put empty elements into the list in the
listclosure function, and does not call push_leftover with
"&list" (which would result in a
pointer-to-pointer-to-pointer-to-struct-fileinlist), but just with
"list".

I hope this now works. I've tested it briefly with piuparts, and will be
doing so further in the near future.

I have recently made a change to piuparts so that it minimizes the
chroot it uses by removing (with debfoster) all unnecessary packages. As
a result, it happens that all (or almost all) piuparts runs now fail,
because many of the important/standard packages (which formerly weren't
being tested) get installed and removed and this triggers the dpkg bug.
Because of that, I'd appreciate a quick resolution of this, and if I can
help, please tell me. Thanks.

diff -ru dpkg-1.13.11/debian/changelog dpkg-1.13.11.patched/debian/changelog
--- dpkg-1.13.11/debian/changelog	2005-08-17 06:45:20.000000000 +0300
+++ dpkg-1.13.11.patched/debian/changelog	2005-12-28 22:43:01.000000000 +0200
@@ -1,3 +1,10 @@
+dpkg (1.13.11.0.0.999) unstable; urgency=low
+
+  * NOT TO BE UPLOADED.
+  * Testing Goswin Brederlow's patch for #318825.
+
+ -- Lars Wirzenius <[EMAIL PROTECTED]>  Wed, 28 Dec 2005 22:42:29 +0200
+
 dpkg (1.13.11) unstable; urgency=low
   
   The "Good, clean fun" Release.
diff -ru dpkg-1.13.11/src/remove.c dpkg-1.13.11.patched/src/remove.c
--- dpkg-1.13.11/src/remove.c	2005-08-14 21:23:51.000000000 +0300
+++ dpkg-1.13.11.patched/src/remove.c	2005-12-29 01:57:31.000000000 +0200
@@ -188,6 +188,43 @@
   *leftoverp= newentry;
 }
 
+/* Generate closure of list by recursively adding all parent directories that
+ * don't already exist
+ */
+void listclosure(struct fileinlist **list) {
+  struct fileinlist *tmp1= *list;
+  struct filenamenode *namenode;
+  while(tmp1) {
+    char *dirname= m_malloc(strlen(tmp1->namenode->name)+1);
+    char *p = dirname + strlen(tmp1->namenode->name);
+    strcpy(dirname,tmp1->namenode->name);
+    while(p > dirname) {
+      struct fileinlist *tmp2= *list;
+      debug(dbg_eachfiledetail, "removal_bulk reinclude test `%s'", dirname);
+      while(p > dirname && *p != '/') { // get dirname
+        *p = 0;
+	--p;
+      }
+      *p = 0;
+      if (strcmp(dirname, "") != 0 && strcmp(dirname, "/") != 0) {
+        while(tmp2) {
+    	  debug(dbg_eachfiledetail, "removal_bulk reinclude cmp `%s'", tmp2->namenode->name);
+          if (strcmp(dirname, tmp2->namenode->name) == 0)
+	    break;
+	  tmp2= tmp2->next;
+        }
+      }
+      if (!tmp2) {
+	debug(dbg_eachfiledetail, "removal_bulk reinclude add `%s'", dirname);
+	namenode= findnamenode(dirname,0);
+	push_leftover(list,namenode);
+      }
+    }
+    free(dirname);
+    tmp1= tmp1->next;
+  }
+}
+
 static void removal_bulk_remove_files(
     struct pkginfo *pkg, 
     int *out_foundpostrm) 
@@ -275,6 +312,7 @@
       }
       if (unlink(fnvb.buf)) ohshite(_("cannot remove file `%.250s'"),fnvb.buf);
     }
+    listclosure(&leftover);
     write_filelist_except(pkg,leftover,0);
     maintainer_script_installed(pkg, POSTRMFILE, "post-removal",
                                 "remove", (char*)0);
@@ -373,6 +411,7 @@
     push_leftover(&leftover,namenode);
     continue;
   }
+  listclosure(&leftover);
   write_filelist_except(pkg,leftover,0);
 
   modstatdb_note(pkg);

Reply via email to