From 805da7cd066fa8ddf50c4954a8ef24f7eda0fe85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= <ondrej@sury.org>
Date: Wed, 11 May 2011 10:58:20 +0200
Subject: [PATCH] Add test for leftover dirs for directories containing files purged
 from postrm (all ucf conffiles).

---
 Makefile                                          |    1 +
 t-dir-leftover/Makefile                           |   15 +++++++++++++++
 t-dir-leftover/pkg-dir-leftover-0/DEBIAN/control  |    8 ++++++++
 t-dir-leftover/pkg-dir-leftover-0/DEBIAN/postinst |   10 ++++++++++
 t-dir-leftover/pkg-dir-leftover-0/DEBIAN/postrm   |    7 +++++++
 t-dir-leftover/pkg-dir-leftover-1/DEBIAN/control  |    9 +++++++++
 t-dir-leftover/pkg-dir-leftover-1/DEBIAN/postinst |   10 ++++++++++
 t-dir-leftover/pkg-dir-leftover-1/DEBIAN/postrm   |    7 +++++++
 8 files changed, 67 insertions(+), 0 deletions(-)
 create mode 100644 t-dir-leftover/Makefile
 create mode 100644 t-dir-leftover/pkg-dir-leftover-0/DEBIAN/control
 create mode 100755 t-dir-leftover/pkg-dir-leftover-0/DEBIAN/postinst
 create mode 100755 t-dir-leftover/pkg-dir-leftover-0/DEBIAN/postrm
 create mode 100644 t-dir-leftover/pkg-dir-leftover-1/DEBIAN/control
 create mode 100755 t-dir-leftover/pkg-dir-leftover-1/DEBIAN/postinst
 create mode 100755 t-dir-leftover/pkg-dir-leftover-1/DEBIAN/postrm

diff --git a/Makefile b/Makefile
index 0458cef..ac28e97 100644
--- a/Makefile
+++ b/Makefile
@@ -57,6 +57,7 @@ TESTS_PASS := \
 	t-symlink-dir \
 	t-substvars \
 	t-failinst-failrm \
+	t-dir-leftover \
 	t-dir-extension-check
 
 ifneq (,$(filter test-all,$(DPKG_TESTSUITE_OPTIONS)))
diff --git a/t-dir-leftover/Makefile b/t-dir-leftover/Makefile
new file mode 100644
index 0000000..1599370
--- /dev/null
+++ b/t-dir-leftover/Makefile
@@ -0,0 +1,15 @@
+TESTS_DEB := pkg-dir-leftover-0 pkg-dir-leftover-1
+
+include ../Test.mk
+
+test-case:
+	$(DPKG_INSTALL) pkg-dir-leftover-0.deb
+	$(DPKG_INSTALL) pkg-dir-leftover-1.deb
+	$(DPKG_REMOVE) pkg-dir-leftover-1
+	$(DPKG_REMOVE) pkg-dir-leftover-0
+	$(DPKG_PURGE) pkg-dir-leftover-0
+	$(DPKG_PURGE) pkg-dir-leftover-1
+	test ! -d /test-confdir
+
+test-clean:
+	rmdir /test-confdir
diff --git a/t-dir-leftover/pkg-dir-leftover-0/DEBIAN/control b/t-dir-leftover/pkg-dir-leftover-0/DEBIAN/control
new file mode 100644
index 0000000..c24544d
--- /dev/null
+++ b/t-dir-leftover/pkg-dir-leftover-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-dir-leftover-0
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Ondřej Surý <ondrej@debian.org>
+Architecture: all
+Description: test package - confdir not removed
+
diff --git a/t-dir-leftover/pkg-dir-leftover-0/DEBIAN/postinst b/t-dir-leftover/pkg-dir-leftover-0/DEBIAN/postinst
new file mode 100755
index 0000000..11f39e3
--- /dev/null
+++ b/t-dir-leftover/pkg-dir-leftover-0/DEBIAN/postinst
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+case "$1" in
+    configure)
+	touch /test-confdir/test-conffile-0
+	;;
+esac
+
+
+     
\ No newline at end of file
diff --git a/t-dir-leftover/pkg-dir-leftover-0/DEBIAN/postrm b/t-dir-leftover/pkg-dir-leftover-0/DEBIAN/postrm
new file mode 100755
index 0000000..1624f61
--- /dev/null
+++ b/t-dir-leftover/pkg-dir-leftover-0/DEBIAN/postrm
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+case "$1" in
+    purge)
+	rm /test-confdir/test-conffile-0
+	;;
+esac
diff --git a/t-dir-leftover/pkg-dir-leftover-1/DEBIAN/control b/t-dir-leftover/pkg-dir-leftover-1/DEBIAN/control
new file mode 100644
index 0000000..d7e5dc2
--- /dev/null
+++ b/t-dir-leftover/pkg-dir-leftover-1/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-dir-leftover-1
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Ondřej Surý <ondrej@debian.org>
+Architecture: all
+Depends: pkg-dir-leftover-0
+Description: test package - confdir not removed
+
diff --git a/t-dir-leftover/pkg-dir-leftover-1/DEBIAN/postinst b/t-dir-leftover/pkg-dir-leftover-1/DEBIAN/postinst
new file mode 100755
index 0000000..1415d73
--- /dev/null
+++ b/t-dir-leftover/pkg-dir-leftover-1/DEBIAN/postinst
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+case "$1" in
+    configure)
+	touch /test-confdir/test-conffile-1
+	;;
+esac
+
+
+     
\ No newline at end of file
diff --git a/t-dir-leftover/pkg-dir-leftover-1/DEBIAN/postrm b/t-dir-leftover/pkg-dir-leftover-1/DEBIAN/postrm
new file mode 100755
index 0000000..e9d7079
--- /dev/null
+++ b/t-dir-leftover/pkg-dir-leftover-1/DEBIAN/postrm
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+case "$1" in
+    purge)
+	rm /test-confdir/test-conffile-1
+	;;
+esac
-- 
1.7.2.5

