diff options
Diffstat (limited to 'tests/t-unpack-divert-overwrite')
9 files changed, 104 insertions, 0 deletions
diff --git a/tests/t-unpack-divert-overwrite/Makefile b/tests/t-unpack-divert-overwrite/Makefile new file mode 100644 index 0000000..1ddfdab --- /dev/null +++ b/tests/t-unpack-divert-overwrite/Makefile @@ -0,0 +1,64 @@ +TESTS_DEB := pkg-files pkg-divert pkg-replaces + +include ../Test.mk + +test-case: + # Test failure to install a package overwriting a diversion (order 1). + $(DPKG_INSTALL) pkg-divert.deb + test -e $(DPKG_INSTDIR)/test-file + ! test -e $(DPKG_INSTDIR)/test-other + $(DPKG_INSTALL) pkg-files.deb + test -e $(DPKG_INSTDIR)/test-file + test -e $(DPKG_INSTDIR)/test-other + ! $(DPKG_INSTALL) pkg-replaces.deb + test -e $(DPKG_INSTDIR)/test-file + test -e $(DPKG_INSTDIR)/test-other + $(call pkg_is_installed,pkg-divert) + $(call pkg_is_not_installed,pkg-replaces) + $(DPKG_PURGE) pkg-files + $(DPKG_PURGE) pkg-divert + $(DPKG_PURGE) pkg-replaces + ! test -e $(DPKG_INSTDIR)/test-file + ! test -e $(DPKG_INSTDIR)/test-other + : + # Test failure to install a package overwriting a diversion (order 2). + $(DPKG_INSTALL) pkg-files.deb + test -e $(DPKG_INSTDIR)/test-file + ! test -e $(DPKG_INSTDIR)/test-other + $(DPKG_INSTALL) pkg-divert.deb + test -e $(DPKG_INSTDIR)/test-file + test -e $(DPKG_INSTDIR)/test-other + ! $(DPKG_INSTALL) pkg-replaces.deb + test -e $(DPKG_INSTDIR)/test-file + test -e $(DPKG_INSTDIR)/test-other + $(call pkg_is_installed,pkg-divert) + $(call pkg_is_not_installed,pkg-replaces) + $(DPKG_PURGE) pkg-files + $(DPKG_PURGE) pkg-divert + $(DPKG_PURGE) pkg-replaces + ! test -e $(DPKG_INSTDIR)/test-file + ! test -e $(DPKG_INSTDIR)/test-other + : + # Test success to install a package overwriting a diversion (forced). + $(DPKG_INSTALL) pkg-files.deb + test -e $(DPKG_INSTDIR)/test-file + ! test -e $(DPKG_INSTDIR)/test-other + $(DPKG_INSTALL) pkg-divert.deb + test -e $(DPKG_INSTDIR)/test-file + test -e $(DPKG_INSTDIR)/test-other + $(DPKG_INSTALL) --force-overwrite-diverted pkg-replaces.deb + test -e $(DPKG_INSTDIR)/test-file + test -e $(DPKG_INSTDIR)/test-other + $(call pkg_is_installed,pkg-divert) + $(call pkg_is_installed,pkg-replaces) + $(DPKG_PURGE) pkg-replaces + $(DPKG_PURGE) pkg-divert + $(DPKG_PURGE) pkg-files + ! test -e $(DPKG_INSTDIR)/test-file + ! test -e $(DPKG_INSTDIR)/test-other + + # XXX: In the force case, if we purge pkg-replaces last, then it + # will leave behind on the fsys an unowned file. + +test-clean: + $(DPKG_PURGE) pkg-files pkg-divert pkg-replaces diff --git a/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/control b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/control new file mode 100644 index 0000000..d450089 --- /dev/null +++ b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/control @@ -0,0 +1,8 @@ +Package: pkg-divert +Version: 0 +Section: test +Priority: extra +Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org> +Architecture: all +Description: test package - divert a file + diff --git a/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/postrm b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/postrm new file mode 100755 index 0000000..d27fa0e --- /dev/null +++ b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/postrm @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +if [ "$1" = "purge" ]; then + dpkg-divert --rename --remove /test-file +fi diff --git a/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/preinst b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/preinst new file mode 100755 index 0000000..b12c5b5 --- /dev/null +++ b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/preinst @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +if [ "$1" = "install" ] || [ "$1" = "upgrade" ]; then + dpkg-divert --rename --divert /test-other --add /test-file +fi diff --git a/tests/t-unpack-divert-overwrite/pkg-divert/test-file b/tests/t-unpack-divert-overwrite/pkg-divert/test-file new file mode 100644 index 0000000..94e47d3 --- /dev/null +++ b/tests/t-unpack-divert-overwrite/pkg-divert/test-file @@ -0,0 +1 @@ +test diverted diff --git a/tests/t-unpack-divert-overwrite/pkg-files/DEBIAN/control b/tests/t-unpack-divert-overwrite/pkg-files/DEBIAN/control new file mode 100644 index 0000000..b616257 --- /dev/null +++ b/tests/t-unpack-divert-overwrite/pkg-files/DEBIAN/control @@ -0,0 +1,7 @@ +Package: pkg-files +Version: 0 +Section: test +Priority: extra +Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org> +Architecture: all +Description: test package - provide a file diff --git a/tests/t-unpack-divert-overwrite/pkg-files/test-file b/tests/t-unpack-divert-overwrite/pkg-files/test-file new file mode 100644 index 0000000..6fbc8b5 --- /dev/null +++ b/tests/t-unpack-divert-overwrite/pkg-files/test-file @@ -0,0 +1 @@ +test init diff --git a/tests/t-unpack-divert-overwrite/pkg-replaces/DEBIAN/control b/tests/t-unpack-divert-overwrite/pkg-replaces/DEBIAN/control new file mode 100644 index 0000000..82a29c1 --- /dev/null +++ b/tests/t-unpack-divert-overwrite/pkg-replaces/DEBIAN/control @@ -0,0 +1,8 @@ +Package: pkg-replaces +Version: 0 +Section: test +Priority: extra +Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org> +Architecture: all +Replaces: pkg-files +Description: test package - replaces files diff --git a/tests/t-unpack-divert-overwrite/pkg-replaces/test-other b/tests/t-unpack-divert-overwrite/pkg-replaces/test-other new file mode 100644 index 0000000..faf6603 --- /dev/null +++ b/tests/t-unpack-divert-overwrite/pkg-replaces/test-other @@ -0,0 +1 @@ +test other |