Hi,

sorry I wasn't clear in my previous mail. I'll attach test cases and
logs this time.

2011/5/12 Guillem Jover <guil...@debian.org>:
> Hi!
>
> Thanks for the test-case, I've commited it as t-dir-leftover-deadlock,
> and added a new t-dir-leftover-parents which is what I thought you
> were trying to solve initially, given your bug report.

Well, it seems to me that the php5-common/php5-cli problem is
combination of both issues, hence the confusion on my part.

> So I think these two issues should be detangled,

I agree, the two test cases helped :). And the deadlock case is really
not solved by any of our patches.

> and I'll be applying my revised patch to fix the -parents case.

I hope I can convince you that your patch as-is causes a regression.

Here's the log of dpkg --purge php5-common (after removing php5-cli,
php5-common):

D001000: dir_has_conffiles '/etc/php5/conf.d' (from php5-common)
D001000: dir_has_conffiles no
D001000: dir_is_used_by_pkg '/etc/php5/conf.d' (by php5-common)
D001000: dir_is_used_by_pkg considering /etc/php5/conf.d/pdo.ini ...
D001000: dir_has_conffiles '/etc/php5' (from php5-common)
D001000: dir_has_conffiles no
D001000: dir_is_used_by_pkg '/etc/php5' (by php5-common)
D001000: dir_is_used_by_pkg considering /etc/php5/conf.d ...
D001000: dir_has_conffiles '/etc/cron.d' (from php5-common)
D001000: dir_has_conffiles no
D001000: dir_is_used_by_pkg '/etc/cron.d' (by php5-common)
D001000: dir_is_used_by_pkg considering /etc/cron.d/php5 ...
D001000: dir_has_conffiles '/etc' (from php5-common)
D001000: dir_has_conffiles no
D001000: dir_is_used_by_pkg '/etc' (by php5-common)
D001000: dir_is_used_by_pkg considering /etc/cron.d ...

And the /etc/php5/conf.d is left on the system.

You can find the test case attached which works OK with current
unstable dpkg and fails with git version+your patch.

> For a fix for t-dir-leftover-deadlock then
> it's not as straight forward as it might seem and I'd recommend reading
> Raphaël's summary in:
>
>  <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=316521#39>

I see, you're right. After reading the summary and the original bug
reports I see only two solutions to this problem:

a) teach dpkg to remove parent directories not used by other packages
on purge (slight modification of Raphael's case one)

b) write some logic to dpkg-maintscript-helper which would allow the
maintainers to either specify directories to purge in postrm, or
directories to keep in the list on remove.

I don't think it's feasible to search the directories for files not
used by other packages, this would make dpkg very slow in corner cases
(many files in many directories).

( c) would be the simplest solution - just keep directories used by
more packages in the list and remove them on purge, but that's very
ugly)

BTW it's not only "configuration files", but "logfiles" as well, as
all other files not in the packages and created either by maintainer
scripts or by package itself.

> On Wed, 2011-05-11 at 11:28:20 +0200, Ondřej Surý wrote:
>> your patch doesn't fix the problem, and even introduces more problems,
>> because as it is written it leaves all directories which have
>> conffiles on the disk.
>
> That's not correct, it behaves as it should be, but that's not changed
> by my patch, that's the current behaviour already. If a directory
> contains conffiles then they need to be tracked so that they can be
> removed on purge.

See above. The problem is that the directory is not removed on purge.
The 0002 patch applied on top of yours fixes the test case.

Ondrej
-- 
Ondřej Surý <ond...@sury.org>
http://blog.rfc1925.org/
From 33162fb38156c2f4192a216b02e16040e90b81c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= <ond...@sury.org>
Date: Thu, 12 May 2011 09:31:15 +0200
Subject: [PATCH] Add test for leftover directories containing conffiles

---
 Makefile                                           |    3 ++-
 t-conffile-leftover/Makefile                       |   13 +++++++++++++
 .../pkg-conffile-leftover/DEBIAN/conffiles         |    1 +
 .../pkg-conffile-leftover/DEBIAN/control           |    7 +++++++
 4 files changed, 23 insertions(+), 1 deletions(-)
 create mode 100644 t-conffile-leftover/Makefile
 create mode 100644 t-conffile-leftover/pkg-conffile-leftover/DEBIAN/conffiles
 create mode 100644 t-conffile-leftover/pkg-conffile-leftover/DEBIAN/control
 create mode 100644 t-conffile-leftover/pkg-conffile-leftover/test-dir/test-conffile

diff --git a/Makefile b/Makefile
index 7487c97..a16ec72 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,8 @@ TESTS_PASS := \
 	t-symlink-dir \
 	t-substvars \
 	t-failinst-failrm \
-	t-dir-extension-check
+	t-dir-extension-check \
+	t-conffile-leftover
 
 ifneq (,$(filter test-all,$(DPKG_TESTSUITE_OPTIONS)))
 TESTS := $(TESTS_PASS) $(TESTS_FAIL) $(TESTS_MANUAL)
diff --git a/t-conffile-leftover/Makefile b/t-conffile-leftover/Makefile
new file mode 100644
index 0000000..1d4c970
--- /dev/null
+++ b/t-conffile-leftover/Makefile
@@ -0,0 +1,13 @@
+TESTS_DEB := pkg-conffile-leftover
+
+include ../Test.mk
+
+test-case:
+	$(DPKG_INSTALL) pkg-conffile-leftover.deb
+	$(DPKG_REMOVE) pkg-conffile-leftover
+	$(DPKG_PURGE) pkg-conffile-leftover
+	test ! -d /test-dir
+
+test-clean:
+	$(DPKG_PURGE) pkg-conffile-leftover
+	$(BEROOT) rm -rf /test-dir
diff --git a/t-conffile-leftover/pkg-conffile-leftover/DEBIAN/conffiles b/t-conffile-leftover/pkg-conffile-leftover/DEBIAN/conffiles
new file mode 100644
index 0000000..6d57c35
--- /dev/null
+++ b/t-conffile-leftover/pkg-conffile-leftover/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-dir/test-conffile
diff --git a/t-conffile-leftover/pkg-conffile-leftover/DEBIAN/control b/t-conffile-leftover/pkg-conffile-leftover/DEBIAN/control
new file mode 100644
index 0000000..1906f19
--- /dev/null
+++ b/t-conffile-leftover/pkg-conffile-leftover/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conffile-leftover
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Ondřej Surý <ond...@debian.org>
+Architecture: all
+Description: test package - shared directory with configuration file
diff --git a/t-conffile-leftover/pkg-conffile-leftover/test-dir/test-conffile b/t-conffile-leftover/pkg-conffile-leftover/test-dir/test-conffile
new file mode 100644
index 0000000..e69de29
-- 
1.7.2.5

Reply via email to