This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=87adaff3d92d6cfc7c3078d09c52b55e7d415fae commit 87adaff3d92d6cfc7c3078d09c52b55e7d415fae (HEAD -> main) Author: Guillem Jover <[email protected]> AuthorDate: Thu May 11 02:02:04 2023 +0200 test: Add cases for disappearance on diverted overwrites and third parties Suggested-by: Simon Richter <[email protected]> --- tests/Makefile | 2 + tests/t-disappear-diverted-other/Makefile | 28 ++++++++++ .../pkg-divert/DEBIAN/control | 1 - .../pkg-divert/DEBIAN/postrm | 2 +- .../pkg-divert/DEBIAN/preinst | 2 +- .../pkg-divert}/test-dir/test-normal | 0 .../pkg-diverted}/DEBIAN/control | 4 +- .../pkg-diverted/test-dir/test-divert | 0 .../pkg-replaces}/DEBIAN/control | 6 +- .../pkg-replaces}/test-dir/test-normal | 0 tests/t-unpack-divert-overwrite/Makefile | 64 ++++++++++++++++++++++ .../pkg-divert}/DEBIAN/control | 4 +- .../pkg-divert}/DEBIAN/postrm | 3 +- .../pkg-divert/DEBIAN/preinst | 3 +- .../pkg-divert}/test-file | 0 .../pkg-files/DEBIAN/control | 0 .../pkg-files/test-file | 0 .../pkg-replaces}/DEBIAN/control | 6 +- .../pkg-replaces/test-other | 1 + 19 files changed, 109 insertions(+), 17 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 3240e8c87..141376648 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -35,6 +35,7 @@ TESTS_PASS += t-unpack-symlink TESTS_PASS += t-unpack-hardlink TESTS_PASS += t-unpack-divert-hardlink TESTS_PASS += t-unpack-divert-nowarn +TESTS_PASS += t-unpack-divert-overwrite TESTS_PASS += t-unpack-fifo ifdef DPKG_AS_ROOT # No permissions for devices @@ -48,6 +49,7 @@ TESTS_PASS += t-dir-leftover-conffile TESTS_PASS += t-disappear TESTS_PASS += t-disappear-depended TESTS_PASS += t-disappear-diverted +TESTS_PASS += t-disappear-diverted-other TESTS_PASS += t-disappear-empty TESTS_PASS += t-provides TESTS_PASS += t-provides-self diff --git a/tests/t-disappear-diverted-other/Makefile b/tests/t-disappear-diverted-other/Makefile new file mode 100644 index 000000000..d483b9ad5 --- /dev/null +++ b/tests/t-disappear-diverted-other/Makefile @@ -0,0 +1,28 @@ +TESTS_DEB := pkg-divert pkg-diverted pkg-replaces + +include ../Test.mk + +test-case: + # Test disappearing diverted package with a not contended pathname. + $(DPKG_INSTALL) pkg-divert.deb + $(DPKG_INSTALL) pkg-diverted.deb + $(DPKG_INSTALL) pkg-replaces.deb + # Should disappear because there is no contended pathname. + $(call pkg_is_not_installed,pkg-divert) + $(DPKG_PURGE) pkg-divert + $(DPKG_PURGE) pkg-diverted + $(DPKG_PURGE) pkg-replaces + : + # Test disappearing diverted package with a not contended pathname. + $(DPKG_INSTALL) pkg-divert.deb + $(DPKG_INSTALL) pkg-replaces.deb + # Should disappear because there is no contended pathname. + $(call pkg_is_not_installed,pkg-divert) + $(DPKG_PURGE) pkg-divert + $(DPKG_PURGE) pkg-replaces + +test-clean: + $(DPKG_PURGE) pkg-divert + $(DPKG_PURGE) pkg-diverted + $(DPKG_PURGE) pkg-replaces + diff --git a/tests/t-disappear-diverted/pkg-divert/DEBIAN/control b/tests/t-disappear-diverted-other/pkg-divert/DEBIAN/control similarity index 89% copy from tests/t-disappear-diverted/pkg-divert/DEBIAN/control copy to tests/t-disappear-diverted-other/pkg-divert/DEBIAN/control index 42515eb7b..b30476201 100644 --- a/tests/t-disappear-diverted/pkg-divert/DEBIAN/control +++ b/tests/t-disappear-diverted-other/pkg-divert/DEBIAN/control @@ -4,6 +4,5 @@ Section: test Priority: extra Maintainer: Dpkg Developers <[email protected]> Architecture: all -Replaces: pkg-disappear Description: test package - divert on disappearing package diff --git a/tests/t-disappear-diverted/pkg-divert/DEBIAN/postrm b/tests/t-disappear-diverted-other/pkg-divert/DEBIAN/postrm similarity index 58% copy from tests/t-disappear-diverted/pkg-divert/DEBIAN/postrm copy to tests/t-disappear-diverted-other/pkg-divert/DEBIAN/postrm index 3787c6627..98891f625 100755 --- a/tests/t-disappear-diverted/pkg-divert/DEBIAN/postrm +++ b/tests/t-disappear-diverted-other/pkg-divert/DEBIAN/postrm @@ -3,6 +3,6 @@ set -e if [ "$1" = "purge" ] || [ "$1" = "disappear" ]; then - dpkg-divert --rename --remove /test-dir/test-normal + dpkg-divert --rename --remove /test-dir/test-divert fi diff --git a/tests/t-disappear-diverted/pkg-divert/DEBIAN/preinst b/tests/t-disappear-diverted-other/pkg-divert/DEBIAN/preinst similarity index 60% copy from tests/t-disappear-diverted/pkg-divert/DEBIAN/preinst copy to tests/t-disappear-diverted-other/pkg-divert/DEBIAN/preinst index 898c3c50c..ad840e694 100755 --- a/tests/t-disappear-diverted/pkg-divert/DEBIAN/preinst +++ b/tests/t-disappear-diverted-other/pkg-divert/DEBIAN/preinst @@ -3,6 +3,6 @@ set -e if [ "$1" = "install" ] || [ "$1" = "upgrade" ]; then - dpkg-divert --rename --add /test-dir/test-normal + dpkg-divert --rename --add /test-dir/test-divert fi diff --git a/tests/t-disappear-depended/pkg-disappear/test-dir/test-normal b/tests/t-disappear-diverted-other/pkg-divert/test-dir/test-normal similarity index 100% copy from tests/t-disappear-depended/pkg-disappear/test-dir/test-normal copy to tests/t-disappear-diverted-other/pkg-divert/test-dir/test-normal diff --git a/tests/t-disappear/pkg-normal/DEBIAN/control b/tests/t-disappear-diverted-other/pkg-diverted/DEBIAN/control similarity index 67% copy from tests/t-disappear/pkg-normal/DEBIAN/control copy to tests/t-disappear-diverted-other/pkg-diverted/DEBIAN/control index 09e51b29c..cb428af03 100644 --- a/tests/t-disappear/pkg-normal/DEBIAN/control +++ b/tests/t-disappear-diverted-other/pkg-diverted/DEBIAN/control @@ -1,8 +1,8 @@ -Package: pkg-normal +Package: pkg-diverted Version: 0.0-1 Section: test Priority: extra Maintainer: Dpkg Developers <[email protected]> Architecture: all -Description: test package - normal +Description: test package - diverted diff --git a/lib/dpkg/t/data/meminfo-no-data b/tests/t-disappear-diverted-other/pkg-diverted/test-dir/test-divert similarity index 100% copy from lib/dpkg/t/data/meminfo-no-data copy to tests/t-disappear-diverted-other/pkg-diverted/test-dir/test-divert diff --git a/tests/t-disappear-depended/pkg-normal/DEBIAN/control b/tests/t-disappear-diverted-other/pkg-replaces/DEBIAN/control similarity index 56% copy from tests/t-disappear-depended/pkg-normal/DEBIAN/control copy to tests/t-disappear-diverted-other/pkg-replaces/DEBIAN/control index 6d825371a..e41beda33 100644 --- a/tests/t-disappear-depended/pkg-normal/DEBIAN/control +++ b/tests/t-disappear-diverted-other/pkg-replaces/DEBIAN/control @@ -1,9 +1,9 @@ -Package: pkg-normal +Package: pkg-replaces Version: 0.0-1 Section: test Priority: extra Maintainer: Dpkg Developers <[email protected]> Architecture: all -Replaces: pkg-disappear -Description: test package - normal +Replaces: pkg-divert +Description: test package - replaces to disappear diff --git a/tests/t-disappear-depended/pkg-disappear/test-dir/test-normal b/tests/t-disappear-diverted-other/pkg-replaces/test-dir/test-normal similarity index 100% copy from tests/t-disappear-depended/pkg-disappear/test-dir/test-normal copy to tests/t-disappear-diverted-other/pkg-replaces/test-dir/test-normal diff --git a/tests/t-unpack-divert-overwrite/Makefile b/tests/t-unpack-divert-overwrite/Makefile new file mode 100644 index 000000000..2a7fee6b3 --- /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 overwritting 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 overwritting 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 overwritting 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-file-conflicts/pkg-b/DEBIAN/control b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/control similarity index 65% copy from tests/t-file-conflicts/pkg-b/DEBIAN/control copy to tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/control index 135098aa4..d450089e7 100644 --- a/tests/t-file-conflicts/pkg-b/DEBIAN/control +++ b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/control @@ -1,8 +1,8 @@ -Package: pkg-b +Package: pkg-divert Version: 0 Section: test Priority: extra Maintainer: Dpkg Developers <[email protected]> Architecture: all -Description: test package - conflicting file +Description: test package - divert a file diff --git a/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/postrm b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/postrm similarity index 51% copy from tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/postrm copy to tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/postrm index adf47cb89..d27fa0ecd 100755 --- a/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/postrm +++ b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/postrm @@ -3,6 +3,5 @@ set -e if [ "$1" = "purge" ]; then - dpkg-divert --remove --rename /test-conffile + dpkg-divert --rename --remove /test-file fi - diff --git a/tests/t-disappear-diverted/pkg-divert/DEBIAN/preinst b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/preinst similarity index 55% copy from tests/t-disappear-diverted/pkg-divert/DEBIAN/preinst copy to tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/preinst index 898c3c50c..b12c5b561 100755 --- a/tests/t-disappear-diverted/pkg-divert/DEBIAN/preinst +++ b/tests/t-unpack-divert-overwrite/pkg-divert/DEBIAN/preinst @@ -3,6 +3,5 @@ set -e if [ "$1" = "install" ] || [ "$1" = "upgrade" ]; then - dpkg-divert --rename --add /test-dir/test-normal + dpkg-divert --rename --divert /test-other --add /test-file fi - diff --git a/tests/t-unpack-divert-hardlink/pkg-hardlink/test-file b/tests/t-unpack-divert-overwrite/pkg-divert/test-file similarity index 100% copy from tests/t-unpack-divert-hardlink/pkg-hardlink/test-file copy to tests/t-unpack-divert-overwrite/pkg-divert/test-file diff --git a/tests/t-unpack-divert-nowarn/pkg-files/DEBIAN/control b/tests/t-unpack-divert-overwrite/pkg-files/DEBIAN/control similarity index 100% copy from tests/t-unpack-divert-nowarn/pkg-files/DEBIAN/control copy to tests/t-unpack-divert-overwrite/pkg-files/DEBIAN/control diff --git a/tests/t-unpack-divert-nowarn/pkg-files/test-file b/tests/t-unpack-divert-overwrite/pkg-files/test-file similarity index 100% copy from tests/t-unpack-divert-nowarn/pkg-files/test-file copy to tests/t-unpack-divert-overwrite/pkg-files/test-file diff --git a/tests/t-breaks-essential/pkg-b/DEBIAN/control b/tests/t-unpack-divert-overwrite/pkg-replaces/DEBIAN/control similarity index 58% copy from tests/t-breaks-essential/pkg-b/DEBIAN/control copy to tests/t-unpack-divert-overwrite/pkg-replaces/DEBIAN/control index c0da700ab..82a29c190 100644 --- a/tests/t-breaks-essential/pkg-b/DEBIAN/control +++ b/tests/t-unpack-divert-overwrite/pkg-replaces/DEBIAN/control @@ -1,8 +1,8 @@ -Package: pkg-b +Package: pkg-replaces Version: 0 Section: test Priority: extra Maintainer: Dpkg Developers <[email protected]> Architecture: all -Breaks: lib-a (<< 1) -Description: test package - breaking package +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 000000000..faf660303 --- /dev/null +++ b/tests/t-unpack-divert-overwrite/pkg-replaces/test-other @@ -0,0 +1 @@ +test other -- Dpkg.Org's dpkg

