The included patch fixes this bug in dpkg, bug which is in the TODO list for it. I'm not really sure if I got the debug messages right, though, that's not a major problem. I've tested it on many system, it behaves correctly, which is, removes all empty directories left after removing the conffiles files.
diff -ur dpkg-1.10.8/main/remove.c dpkg-1.10.8-patch/main/remove.c
--- dpkg-1.10.8/main/remove.c 2002-05-06 19:18:16.000000000 +0300
+++ dpkg-1.10.8-patch/main/remove.c 2002-09-18 06:09:07.000000000 +0300
@@ -242,17 +242,19 @@
debug(dbg_eachfiledetail, "removal_bulk removing `%s'", fnvb.buf);
if (!rmdir(fnvb.buf) || errno == ENOENT || errno == ELOOP) continue;
if (errno == ENOTEMPTY) {
- fprintf(stderr,
- _("dpkg - warning: while removing %.250s, directory `%.250s'
not empty "
- "so not removed.\n"),
- pkg->name, namenode->name);
+ if (pkg->want != want_purge)
+ fprintf(stderr,
+ _("dpkg - warning: while removing %.250s, directory `%.250s'
not empty "
+ "so not removed.\n"),
+ pkg->name, namenode->name);
push_leftover(&leftover,namenode);
continue;
} else if (errno == EBUSY || errno == EPERM) {
- fprintf(stderr, _("dpkg - warning: while removing %.250s,"
- " unable to remove directory `%.250s':"
- " %s - directory may be a mount point ?\n"),
- pkg->name, namenode->name, strerror(errno));
+ if (pkg->want != want_purge)
+ fprintf(stderr, _("dpkg - warning: while removing %.250s,"
+ " unable to remove directory `%.250s':"
+ " %s - directory may be a mount point ?\n"),
+ pkg->name, namenode->name, strerror(errno));
push_leftover(&leftover,namenode);
continue;
}
@@ -442,7 +444,44 @@
maintainer_script_installed(pkg, POSTRMFILE, "post-removal",
"purge", (char*)0);
- /* fixme: retry empty directories */
+ reversefilelist_init(&rlistit,pkg->clientdata->files);
+
+ if (pkg->want == want_purge) {
+ debug(dbg_general,"removal_bulk removing empty directories of package %s"
+ ,pkg->name);
+ while ((namenode= reversefilelist_next(&rlistit))) {
+ varbufreset(&fnvb);
+ varbufaddstr(&fnvb,instdir);
+ varbufaddstr(&fnvb,namenodetouse(namenode,pkg)->name);
+ varbufaddc(&fnvb,0);
+ /* By the time we get here, there won't be but directories left for
+ * us to remove anyway, the rest will just be conffiles, which are
+ * still in the file list.
+ */
+ if (stat(fnvb.buf,&stab) || !S_ISDIR(stab.st_mode)) continue;
+ /* Only delete a directory or a link to one if we're the only
+ * package which uses it. Other files should only be listed
+ * in this package (but we don't check).
+ */
+ if (isdirectoryinuse(namenode,pkg)) continue;
+
+ debug(dbg_eachfiledetail, "removal_bulk removing '%s'", fnvb.buf);
+ if (!rmdir(fnvb.buf) || errno == ENOENT || errno == ELOOP) continue;
+ if (errno == ENOTEMPTY) {
+ fprintf(stderr,
+ _("dpkg - warning: while removing %.250s, directory %.250s'
not empty "
+ "so not removed.\n"),
+ pkg->name, namenode->name);
+ continue;
+ } else if (errno == EBUSY || errno == EPERM) {
+ fprintf(stderr, _("dpkg - warning: while removing %.250s,"
+ " unable to remove directory %.250s':"
+ " %s - directory may be a mount point ?\n"),
+ pkg->name, namenode->name, strerror(errno));
+ continue;
+ }
+ }
+ }
}
--
PGP public key: http://www.wolfheart.ro/pubkey.asc
signature.asc
Description: This is a digitally signed message part

