From 9397c0f58e3611886d1fdcdb4543a0739372bef2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
Date: Mon, 20 Mar 2017 00:39:46 +0100
Subject: [PATCH 4/5] Fix t-switch-dir-to-symlink-abs/

---
 Makefile                             |   4 +-
 t-switch-dir-to-symlink-abs/Makefile | 117 +++++++++++++++++------------------
 2 files changed, 60 insertions(+), 61 deletions(-)

diff --git a/Makefile b/Makefile
index 99c58bf..458e8d3 100644
--- a/Makefile
+++ b/Makefile
@@ -123,10 +123,10 @@ ifdef DPKG_HAS_MAINTSCRIPT_SWITCH_DIR_SYMLINK
 # FIXME: dpkg-maintscript-helper does not support $DPKG_ROOT (#832176)
 TESTS_PASS += t-switch-symlink-abs-to-dir
 TESTS_PASS += t-switch-symlink-rel-to-dir
-ifndef DPKG_NOT_ROOT
+#ifndef DPKG_NOT_ROOT
 TESTS_PASS += t-switch-dir-to-symlink-abs
 TESTS_PASS += t-switch-dir-to-symlink-rel
-endif
+#endif
 endif
 TESTS_PASS += t-source-minimal
 TESTS_PASS += t-substvars
diff --git a/t-switch-dir-to-symlink-abs/Makefile b/t-switch-dir-to-symlink-abs/Makefile
index c5f8c84..7852cb8 100644
--- a/t-switch-dir-to-symlink-abs/Makefile
+++ b/t-switch-dir-to-symlink-abs/Makefile
@@ -8,31 +8,31 @@ include ../Test.mk
 test-case:
 	# Cannot switch a directory containing conffiles
 	$(DPKG_INSTALL) pkg-dir-conffile-0.deb
-	test -d /test-path
+	test -d '$(DPKG_INSTDIR)/test-path'
 	! $(DPKG_INSTALL) pkg-dir-conffile-1.deb
-	test -d /test-path
+	test -d '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_PURGE) pkg-dir-conffile
 
 	# Cannot switch a directory containing files owned by another package
 	$(DPKG_INSTALL) pkg-dir-file-other.deb
 	$(DPKG_INSTALL) pkg-dir-symlink-int-0.deb
-	test -d /test-path
-	! test -h /test-path
+	test -d '$(DPKG_INSTDIR)/test-path'
+	! test -h '$(DPKG_INSTDIR)/test-path'
 	! $(DPKG_INSTALL) pkg-dir-symlink-int-1.deb
-	test -d /test-path
-	! test -h /test-path
+	test -d '$(DPKG_INSTDIR)/test-path'
+	! test -h '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_PURGE) pkg-dir-symlink-int
 	$(DPKG_PURGE) pkg-dir-file-other
 
 	# Cannot switch a directory containing local files
 	$(DPKG_INSTALL) pkg-dir-symlink-int-0.deb
-	test -d /test-path
-	! test -h /test-path
-	touch '/test-path/local file'
+	test -d '$(DPKG_INSTDIR)/test-path'
+	! test -h '$(DPKG_INSTDIR)/test-path'
+	touch '$(DPKG_INSTDIR)/test-path/local file'
 	! $(DPKG_INSTALL) pkg-dir-symlink-int-1.deb
-	test -d /test-path
-	! test -h /test-path
-	rm '/test-path/local file'
+	test -d '$(DPKG_INSTDIR)/test-path'
+	! test -h '$(DPKG_INSTDIR)/test-path'
+	rm '$(DPKG_INSTDIR)/test-path/local file'
 	$(DPKG_PURGE) pkg-dir-symlink-int
 
 	#
@@ -42,93 +42,92 @@ test-case:
 	# Switch a directory to a symlink, contents moved within the package,
 	# with intermediate full installs.
 	$(DPKG_INSTALL) pkg-dir-symlink-int-0.deb
-	test -d /test-path
-	! test -h /test-path
+	test -d '$(DPKG_INSTDIR)/test-path'
+	! test -h '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_INSTALL) pkg-dir-symlink-int-1.deb
-	test -h /test-path
+	test -h '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_PURGE) pkg-dir-symlink-int
-	! test -e /test-path
+	! test -e '$(DPKG_INSTDIR)/test-path'
 
 	# Switch a directory to a symlink, contents moved within the package,
 	# with full install, upgrade with upack and configure.
 	$(DPKG_INSTALL) pkg-dir-symlink-int-0.deb
-	! test -h /test-path
-	test -d /test-path
+	! test -h '$(DPKG_INSTDIR)/test-path'
+	test -d '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_UNPACK) pkg-dir-symlink-int-1.deb
-	! test -h /test-path
-	test -d /test-path
+	! test -h '$(DPKG_INSTDIR)/test-path'
+	test -d '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_CONFIGURE) pkg-dir-symlink-int
-	test -h /test-path
+	test -h '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_PURGE) pkg-dir-symlink-int
-	! test -e /test-path
+	! test -e '$(DPKG_INSTDIR)/test-path'
 
 	# Switch a directory to a symlink, contents moved within the package,
 	# with two unpacks and configure.
 	$(DPKG_UNPACK) pkg-dir-symlink-int-0.deb
-	! test -h /test-path
-	test -d /test-path
+	! test -h '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_UNPACK) pkg-dir-symlink-int-1.deb
-	! test -h /test-path
-	test -d /test-path
+	! test -h '$(DPKG_INSTDIR)/test-path'
+	test -d '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_CONFIGURE) pkg-dir-symlink-int
-	test -h /test-path
+	test -h '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_PURGE) pkg-dir-symlink-int
-	! test -e /test-path
+	! test -e '$(DPKG_INSTDIR)/test-path'
 
 	# Switch a directory to a symlink, contents moved to another package,
 	# with intermediate full installs.
 	$(DPKG_INSTALL) pkg-dir-symlink-ext-0.deb
-	test -d /test-path
+	test -d '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_INSTALL) pkg-dir-file-moved.deb
-	test -d /test-path
-	test -d /test-dir
+	test -d '$(DPKG_INSTDIR)/test-path'
+	test -d '$(DPKG_INSTDIR)/test-dir'
 	$(DPKG_INSTALL) pkg-dir-symlink-ext-1.deb
-	test -h /test-path
-	test -d /test-path
-	test "`readlink -f /test-path`" = "/test-dir"
-	! test -h /test-dir
-	test -d /test-dir
-	test -f /test-dir/file-normal
+	test -h '$(DPKG_INSTDIR)/test-path'
+	test -d '$(DPKG_INSTDIR)/test-path'
+	test "`readlink -f '$(DPKG_INSTDIR)/test-path'`" = "`readlink -f $(DPKG_INSTDIR)/test-dir`"
+	! test -h '$(DPKG_INSTDIR)/test-dir'
+	test -d '$(DPKG_INSTDIR)/test-dir'
+	test -f '$(DPKG_INSTDIR)/test-dir/file-normal'
 	$(DPKG_PURGE) pkg-dir-symlink-ext
 	$(DPKG_PURGE) pkg-dir-file-moved
 
 	# Switch a directory to a symlink, contents moved to another package,
 	# with full installs, upgrade with upack and configure.
 	$(DPKG_INSTALL) pkg-dir-symlink-ext-0.deb
-	test -d /test-path
+	test -d '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_INSTALL) pkg-dir-file-moved.deb
-	test -d /test-path
-	test -d /test-dir
+	test -d '$(DPKG_INSTDIR)/test-path'
+	test -d '$(DPKG_INSTDIR)/test-dir'
 	$(DPKG_UNPACK) pkg-dir-symlink-ext-1.deb
-	test -d /test-path
-	test -d /test-dir
+	test -d '$(DPKG_INSTDIR)/test-path'
+	test -d '$(DPKG_INSTDIR)/test-dir'
 	$(DPKG_CONFIGURE) -a
-	test -h /test-path
-	test -d /test-path
-	test "`readlink -f /test-path`" = "/test-dir"
-	! test -h /test-dir
-	test -d /test-dir
-	test -f /test-dir/file-normal
+	test -h '$(DPKG_INSTDIR)/test-path'
+	test -d '$(DPKG_INSTDIR)/test-path'
+	test "`readlink -f '$(DPKG_INSTDIR)/test-path'`" = "`readlink -f $(DPKG_INSTDIR)/test-dir`"
+	! test -h '$(DPKG_INSTDIR)/test-dir'
+	test -d '$(DPKG_INSTDIR)/test-dir'
+	test -f '$(DPKG_INSTDIR)/test-dir/file-normal'
 	$(DPKG_PURGE) pkg-dir-symlink-ext
 	$(DPKG_PURGE) pkg-dir-file-moved
 
 	# Switch a directory to a symlink, contents moved to another package,
 	# with three unpacks and configure.
 	$(DPKG_UNPACK) pkg-dir-symlink-ext-0.deb
-	test -d /test-path
+	test -d '$(DPKG_INSTDIR)/test-path'
 	$(DPKG_UNPACK) pkg-dir-file-moved.deb
-	test -d /test-path
-	test -d /test-dir
+	test -d '$(DPKG_INSTDIR)/test-path'
+	test -d '$(DPKG_INSTDIR)/test-dir'
 	$(DPKG_UNPACK) pkg-dir-symlink-ext-1.deb
-	test -d /test-path
-	test -d /test-dir
+	test -d '$(DPKG_INSTDIR)/test-path'
+	test -d '$(DPKG_INSTDIR)/test-dir'
 	$(DPKG_CONFIGURE) -a
-	test -h /test-path
-	test -d /test-path
-	test "`readlink -f /test-path`" = "/test-dir"
-	! test -h /test-dir
-	test -d /test-dir
-	test -f /test-dir/file-normal
+	test -h '$(DPKG_INSTDIR)/test-path'
+	test -d '$(DPKG_INSTDIR)/test-path'
+	test "`readlink -f '$(DPKG_INSTDIR)/test-path'`" = "`readlink -f '$(DPKG_INSTDIR)/test-dir'`"
+	! test -h '$(DPKG_INSTDIR)/test-dir'
+	test -d '$(DPKG_INSTDIR)/test-dir'
+	test -f '$(DPKG_INSTDIR)/test-dir/file-normal'
 	$(DPKG_PURGE) pkg-dir-symlink-ext
 	$(DPKG_PURGE) pkg-dir-file-moved
 
-- 
2.11.0

