summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 09:40:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 09:40:31 +0000
commitb86570f63e533abcbcb97c2572e0e5732a96307b (patch)
treecabc83be691530ae685c45a8bc7620ccc0e1ebdf /tests
parentInitial commit. (diff)
downloaddpkg-b86570f63e533abcbcb97c2572e0e5732a96307b.tar.xz
dpkg-b86570f63e533abcbcb97c2572e0e5732a96307b.zip
Adding upstream version 1.20.13.upstream/1.20.13upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/Feature.mk19
-rw-r--r--tests/Makefile155
-rw-r--r--tests/README57
-rw-r--r--tests/Test.mk124
-rwxr-xr-xtests/db-regen34
-rw-r--r--tests/dpkgdb/available0
-rw-r--r--tests/dpkgdb/diversions0
-rw-r--r--tests/dpkgdb/lock0
-rw-r--r--tests/dpkgdb/lock-frontend0
-rw-r--r--tests/dpkgdb/statoverride0
-rw-r--r--tests/dpkgdb/status0
-rw-r--r--tests/dpkgdb/triggers/Lock0
-rw-r--r--tests/dpkgdb/triggers/Unincorp0
-rw-r--r--tests/t-breaks-essential/Makefile13
-rw-r--r--tests/t-breaks-essential/lib-a-0/DEBIAN/control8
-rw-r--r--tests/t-breaks-essential/lib-a-1/DEBIAN/control8
-rw-r--r--tests/t-breaks-essential/pkg-b/DEBIAN/control8
-rw-r--r--tests/t-breaks-multiarch/Makefile22
-rw-r--r--tests/t-breaks-multiarch/lib-a-0-amd64/DEBIAN/control8
-rw-r--r--tests/t-breaks-multiarch/lib-a-0-i386/DEBIAN/control8
-rw-r--r--tests/t-breaks-multiarch/lib-a-1-amd64/DEBIAN/control8
-rw-r--r--tests/t-breaks-multiarch/lib-a-1-i386/DEBIAN/control8
-rw-r--r--tests/t-breaks-multiarch/lib-b-0-amd64/DEBIAN/control8
-rw-r--r--tests/t-breaks-multiarch/lib-b-0-i386/DEBIAN/control8
-rw-r--r--tests/t-breaks-multiarch/lib-b-1-amd64/DEBIAN/control8
-rw-r--r--tests/t-breaks-multiarch/lib-b-1-i386/DEBIAN/control8
-rw-r--r--tests/t-breaks-multiarch/pkg-c/DEBIAN/control8
-rw-r--r--tests/t-breaks-protected/Makefile13
-rw-r--r--tests/t-breaks-protected/lib-a-0/DEBIAN/control8
-rw-r--r--tests/t-breaks-protected/lib-a-1/DEBIAN/control8
-rw-r--r--tests/t-breaks-protected/pkg-b/DEBIAN/control8
-rw-r--r--tests/t-breaks/Makefile12
-rw-r--r--tests/t-breaks/lib-a-0/DEBIAN/control7
-rw-r--r--tests/t-breaks/lib-a-1/DEBIAN/control7
-rw-r--r--tests/t-breaks/lib-b-0/DEBIAN/control7
-rw-r--r--tests/t-breaks/lib-b-1/DEBIAN/control7
-rw-r--r--tests/t-breaks/pkg-c/DEBIAN/control8
-rw-r--r--tests/t-buildinfo/Makefile11
-rw-r--r--tests/t-buildinfo/db-buildinfo/status28
-rw-r--r--tests/t-buildinfo/db-buildinfo/updates/.keep0
-rw-r--r--tests/t-buildinfo/pkg-source/debian/changelog5
-rw-r--r--tests/t-buildinfo/pkg-source/debian/control13
-rw-r--r--tests/t-buildinfo/pkg-source/debian/source/format1
-rw-r--r--tests/t-conffile-conflict/Makefile44
-rw-r--r--tests/t-conffile-conflict/pkg-conff-a/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-conflict/pkg-conff-a/DEBIAN/control8
-rw-r--r--tests/t-conffile-conflict/pkg-conff-a/test-conffile1
-rw-r--r--tests/t-conffile-conflict/pkg-conff-b/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-conflict/pkg-conff-b/DEBIAN/control8
-rw-r--r--tests/t-conffile-conflict/pkg-conff-b/test-conffile1
-rw-r--r--tests/t-conffile-conflict/pkg-conff-c/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-conflict/pkg-conff-c/DEBIAN/control9
-rw-r--r--tests/t-conffile-conflict/pkg-conff-c/test-conffile1
-rw-r--r--tests/t-conffile-declarative-removal/Makefile101
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/DEBIAN/control7
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/test-dir/test-conffile-to-be-removed0
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/DEBIAN/control7
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/test-dir/test-conffile-owned0
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-removal-present/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-removal-present/DEBIAN/control7
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-removal-present/test-dir/test-conffile-to-be-removed0
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-v1/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-v1/DEBIAN/control7
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-v1/test-dir/test-conffile-to-be-removed0
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-v2/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-declarative-removal/pkg-conffile-v2/DEBIAN/control7
-rw-r--r--tests/t-conffile-divert-conffile/Makefile13
-rw-r--r--tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/control8
-rwxr-xr-xtests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/postrm8
-rwxr-xr-xtests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/preinst9
-rw-r--r--tests/t-conffile-divert-conffile/pkg-conff-divert/test-conffile1
-rw-r--r--tests/t-conffile-divert-conffile/pkg-conff/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-divert-conffile/pkg-conff/DEBIAN/control8
-rw-r--r--tests/t-conffile-divert-conffile/pkg-conff/test-conffile1
-rw-r--r--tests/t-conffile-divert-normal/Makefile13
-rw-r--r--tests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/control8
-rwxr-xr-xtests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/postrm8
-rwxr-xr-xtests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/preinst9
-rw-r--r--tests/t-conffile-divert-normal/pkg-conff-divert/test-conffile1
-rw-r--r--tests/t-conffile-divert-normal/pkg-conff/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-divert-normal/pkg-conff/DEBIAN/control8
-rw-r--r--tests/t-conffile-divert-normal/pkg-conff/test-conffile1
-rw-r--r--tests/t-conffile-forceask/Makefile16
-rw-r--r--tests/t-conffile-forceask/mod-conffile1
-rw-r--r--tests/t-conffile-forceask/pkg-conff-forceask-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-forceask/pkg-conff-forceask-0/DEBIAN/control9
-rw-r--r--tests/t-conffile-forceask/pkg-conff-forceask-0/test-conffile1
-rw-r--r--tests/t-conffile-forceask/pkg-conff-forceask-1/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-forceask/pkg-conff-forceask-1/DEBIAN/control9
-rw-r--r--tests/t-conffile-forceask/pkg-conff-forceask-1/test-conffile1
-rw-r--r--tests/t-conffile-forceask/ref-conffile1
-rw-r--r--tests/t-conffile-forcemiss/Makefile16
-rw-r--r--tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/DEBIAN/control7
-rw-r--r--tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/test-conffile1
-rw-r--r--tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/DEBIAN/control7
-rw-r--r--tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/test-conffile1
-rw-r--r--tests/t-conffile-forcemiss/ref-conffile1
-rw-r--r--tests/t-conffile-forcenew/Makefile17
-rw-r--r--tests/t-conffile-forcenew/mod-conffile1
-rw-r--r--tests/t-conffile-forcenew/pkg-conff-forcenew-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-forcenew/pkg-conff-forcenew-0/DEBIAN/control9
-rw-r--r--tests/t-conffile-forcenew/pkg-conff-forcenew-0/test-conffile1
-rw-r--r--tests/t-conffile-forcenew/pkg-conff-forcenew-1/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-forcenew/pkg-conff-forcenew-1/DEBIAN/control9
-rw-r--r--tests/t-conffile-forcenew/pkg-conff-forcenew-1/test-conffile1
-rw-r--r--tests/t-conffile-forcenew/ref-conffile1
-rw-r--r--tests/t-conffile-normal/Makefile15
-rw-r--r--tests/t-conffile-normal/pkg-conffile/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-normal/pkg-conffile/DEBIAN/control7
-rw-r--r--tests/t-conffile-normal/pkg-conffile/test-dir/test-conffile0
-rw-r--r--tests/t-conffile-obsolete/Makefile42
-rw-r--r--tests/t-conffile-obsolete/pkg-conff-obsolete-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-obsolete/pkg-conff-obsolete-0/DEBIAN/control8
-rw-r--r--tests/t-conffile-obsolete/pkg-conff-obsolete-0/test-conffile1
-rw-r--r--tests/t-conffile-obsolete/pkg-conff-obsolete-1/DEBIAN/control8
-rw-r--r--tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/control8
-rwxr-xr-xtests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/postinst4
-rwxr-xr-xtests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/postrm4
-rwxr-xr-xtests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/preinst9
-rw-r--r--tests/t-conffile-orphan/Makefile14
-rw-r--r--tests/t-conffile-orphan/pkg-conff-orphan-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-orphan/pkg-conff-orphan-0/DEBIAN/control8
-rw-r--r--tests/t-conffile-orphan/pkg-conff-orphan-0/test-conffile1
-rw-r--r--tests/t-conffile-orphan/pkg-conff-orphan-1/DEBIAN/control8
-rw-r--r--tests/t-conffile-orphan/pkg-conff-takeover/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-orphan/pkg-conff-takeover/DEBIAN/control8
-rw-r--r--tests/t-conffile-orphan/pkg-conff-takeover/test-conffile1
-rw-r--r--tests/t-conffile-prompt/Makefile20
-rw-r--r--tests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/conffiles2
-rw-r--r--tests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/control8
-rwxr-xr-xtests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/postinst3
-rw-r--r--tests/t-conffile-prompt/pkg-conff-prompt-0/test-conffile1
-rw-r--r--tests/t-conffile-prompt/pkg-conff-prompt-1/DEBIAN/conffiles2
-rw-r--r--tests/t-conffile-prompt/pkg-conff-prompt-1/DEBIAN/control8
-rw-r--r--tests/t-conffile-prompt/pkg-conff-prompt-1/test-conffile1
-rw-r--r--tests/t-conffile-rename/Makefile34
-rw-r--r--tests/t-conffile-rename/pkg-conff-rename-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-rename/pkg-conff-rename-0/DEBIAN/control8
-rw-r--r--tests/t-conffile-rename/pkg-conff-rename-0/test-conffile-old1
-rw-r--r--tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/control8
-rwxr-xr-xtests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/postinst4
-rwxr-xr-xtests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/postrm4
-rwxr-xr-xtests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/preinst9
-rw-r--r--tests/t-conffile-rename/pkg-conff-rename-1/test-conffile-new1
-rw-r--r--tests/t-conffile-replaces-disappear/Makefile51
-rw-r--r--tests/t-conffile-replaces-disappear/pkg-conff-original/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-disappear/pkg-conff-original/DEBIAN/control8
-rw-r--r--tests/t-conffile-replaces-disappear/pkg-conff-original/test-conffile1
-rw-r--r--tests/t-conffile-replaces-disappear/pkg-conff-takeover/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-disappear/pkg-conff-takeover/DEBIAN/control9
-rw-r--r--tests/t-conffile-replaces-disappear/pkg-conff-takeover/test-conffile1
-rw-r--r--tests/t-conffile-replaces-disappear/ref-conffile1
-rw-r--r--tests/t-conffile-replaces-diverted/Makefile18
-rw-r--r--tests/t-conffile-replaces-diverted/pkg-conff-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-diverted/pkg-conff-0/DEBIAN/control7
-rw-r--r--tests/t-conffile-replaces-diverted/pkg-conff-0/test/conffile1
-rw-r--r--tests/t-conffile-replaces-diverted/pkg-conff-1/DEBIAN/control7
-rw-r--r--tests/t-conffile-replaces-diverted/pkg-conff-move/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-diverted/pkg-conff-move/DEBIAN/control8
-rw-r--r--tests/t-conffile-replaces-diverted/pkg-conff-move/test/conffile1
-rw-r--r--tests/t-conffile-replaces-downgrade/Makefile20
-rw-r--r--tests/t-conffile-replaces-downgrade/pkg-conff-original-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-downgrade/pkg-conff-original-0/DEBIAN/control8
-rw-r--r--tests/t-conffile-replaces-downgrade/pkg-conff-original-0/test-conffile1
-rw-r--r--tests/t-conffile-replaces-downgrade/pkg-conff-original-0/test-original0
-rw-r--r--tests/t-conffile-replaces-downgrade/pkg-conff-original-1/DEBIAN/control8
-rw-r--r--tests/t-conffile-replaces-downgrade/pkg-conff-original-1/test-original0
-rw-r--r--tests/t-conffile-replaces-downgrade/pkg-conff-takeover/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-downgrade/pkg-conff-takeover/DEBIAN/control9
-rw-r--r--tests/t-conffile-replaces-downgrade/pkg-conff-takeover/test-conffile1
-rw-r--r--tests/t-conffile-replaces-downgrade/pkg-conff-takeover/test-takeover0
-rw-r--r--tests/t-conffile-replaces-downgrade/ref-conffile1
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/Makefile61
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/DEBIAN/control8
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/test-conffile1
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/test-original0
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/DEBIAN/control8
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/test-conffile1
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/test-original0
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/DEBIAN/control9
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/test-conffile1
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/test-takeover0
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/DEBIAN/control9
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/test-conffile1
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/test-takeover0
-rw-r--r--tests/t-conffile-replaces-existing-and-upgrade/ref-conffile1
-rw-r--r--tests/t-conffile-replaces-existing/Makefile48
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-original-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-original-0/DEBIAN/control8
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-original-0/test-conffile1
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-original-0/test-original0
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-original-1/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-original-1/DEBIAN/control8
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-original-1/test-conffile1
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-original-1/test-original0
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-takeover/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-takeover/DEBIAN/control9
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-takeover/test-conffile1
-rw-r--r--tests/t-conffile-replaces-existing/pkg-conff-takeover/test-takeover0
-rw-r--r--tests/t-conffile-replaces-existing/ref-conffile1
-rw-r--r--tests/t-conffile-replaces-upgrade/Makefile58
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-original/DEBIAN/conffiles2
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-original/DEBIAN/control8
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-original/test-conffile1
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-original/test-confpath1
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-original/test-original0
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/DEBIAN/conffiles2
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/DEBIAN/control9
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-conffile1
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-confpath1
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-takeover0
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/DEBIAN/conffiles2
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/DEBIAN/control9
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-conffile1
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-confpath1
-rw-r--r--tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-takeover0
-rw-r--r--tests/t-conffile-replaces-upgrade/ref-conffile1
-rw-r--r--tests/t-conffile-replaces/Makefile44
-rw-r--r--tests/t-conffile-replaces/pkg-conff-original/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces/pkg-conff-original/DEBIAN/control8
-rw-r--r--tests/t-conffile-replaces/pkg-conff-original/test-conffile1
-rw-r--r--tests/t-conffile-replaces/pkg-conff-original/test-original0
-rw-r--r--tests/t-conffile-replaces/pkg-conff-takeover/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-replaces/pkg-conff-takeover/DEBIAN/control9
-rw-r--r--tests/t-conffile-replaces/pkg-conff-takeover/test-conffile1
-rw-r--r--tests/t-conffile-replaces/pkg-conff-takeover/test-takeover0
-rw-r--r--tests/t-conffile-replaces/ref-conffile1
-rw-r--r--tests/t-conffile-root-option/Makefile39
-rw-r--r--tests/t-conffile-root-option/pkg-conff-a-1/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-root-option/pkg-conff-a-1/DEBIAN/control7
-rw-r--r--tests/t-conffile-root-option/pkg-conff-a-1/test-conffile1
-rw-r--r--tests/t-conffile-root-option/pkg-conff-a-2/DEBIAN/control7
-rw-r--r--tests/t-conffile-root-option/pkg-conff-b-1/DEBIAN/control7
-rw-r--r--tests/t-conffile-root-option/pkg-conff-b-2/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-root-option/pkg-conff-b-2/DEBIAN/control7
-rw-r--r--tests/t-conffile-root-option/pkg-conff-b-2/test-conffile1
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/Makefile20
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/DEBIAN/control8
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/test-conffile1
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/test-original0
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-1/DEBIAN/control8
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-1/test-original0
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/DEBIAN/conffiles1
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/DEBIAN/control9
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/test-conffile1
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/test-takeover0
-rw-r--r--tests/t-conffile-versioned-replaces-downgrade/ref-conffile1
-rw-r--r--tests/t-conflict-provide-replace-interface/Makefile18
-rw-r--r--tests/t-conflict-provide-replace-interface/pkg-a/DEBIAN/control10
-rw-r--r--tests/t-conflict-provide-replace-interface/pkg-b/DEBIAN/control11
-rw-r--r--tests/t-conflict-provide-replace-real/Makefile13
-rw-r--r--tests/t-conflict-provide-replace-real/pkg-a/DEBIAN/control8
-rw-r--r--tests/t-conflict-provide-replace-real/pkg-a/test-conflict0
-rw-r--r--tests/t-conflict-provide-replace-real/pkg-b/DEBIAN/control11
-rw-r--r--tests/t-conflict-provide-replace-real/pkg-b/test-conflict0
-rw-r--r--tests/t-conflict-provide-replace-virtual-multiarch/Makefile23
-rw-r--r--tests/t-conflict-provide-replace-virtual-multiarch/pkg-real-amd64/DEBIAN/control10
-rw-r--r--tests/t-conflict-provide-replace-virtual-multiarch/pkg-real-i386/DEBIAN/control10
-rw-r--r--tests/t-conflict-provide-replace-virtual-multiarch/pkg-virt-amd64/DEBIAN/control12
-rw-r--r--tests/t-conflict-provide-replace-virtual-multiarch/pkg-virt-i386/DEBIAN/control12
-rw-r--r--tests/t-conflict-provide-replace-virtual/Makefile13
-rw-r--r--tests/t-conflict-provide-replace-virtual/pkg-a/DEBIAN/control11
-rw-r--r--tests/t-conflict-provide-replace-virtual/pkg-b/DEBIAN/control11
-rw-r--r--tests/t-conflicts/Makefile15
-rw-r--r--tests/t-conflicts/pkg-a/DEBIAN/control8
-rw-r--r--tests/t-conflicts/pkg-b/DEBIAN/control7
-rw-r--r--tests/t-control-bogus/Makefile32
-rw-r--r--tests/t-control-bogus/pkg-bogus-blank/DEBIAN/control18
-rw-r--r--tests/t-control-bogus/pkg-bogus-colon/DEBIAN/control8
-rw-r--r--tests/t-control-bogus/pkg-bogus-fieldname-empty/DEBIAN/control8
-rw-r--r--tests/t-control-bogus/pkg-bogus-fieldname-partial/DEBIAN/control7
-rw-r--r--tests/t-control-bogus/pkg-bogus-format-string/DEBIAN/control7
-rw-r--r--tests/t-control-no-arch/Makefile22
-rw-r--r--tests/t-control-no-arch/pkg-no-arch/DEBIAN/control6
-rw-r--r--tests/t-db/Makefile60
-rw-r--r--tests/t-db/db-bogus-dupe-diff-single/status18
-rw-r--r--tests/t-db/db-bogus-dupe-diff-single/updates/.keep0
-rw-r--r--tests/t-db/db-bogus-dupe-same-single/status18
-rw-r--r--tests/t-db/db-bogus-dupe-same-single/updates/.keep0
-rw-r--r--tests/t-db/db-bogus-multi-update/status16
-rw-r--r--tests/t-db/db-bogus-multi-update/updates/000110
-rw-r--r--tests/t-db/db-bogus-multi-update/updates/00029
-rw-r--r--tests/t-db/db-bogus-multi/status29
-rw-r--r--tests/t-db/db-bogus-multi/updates/.keep0
-rw-r--r--tests/t-db/db-bogus-single/status19
-rw-r--r--tests/t-db/db-bogus-single/updates/.keep0
-rw-r--r--tests/t-db/db-cross-multi-update/status10
-rw-r--r--tests/t-db/db-cross-multi-update/updates/000110
-rw-r--r--tests/t-db/db-cross-multi-update/updates/000210
-rw-r--r--tests/t-db/db-cross-multi-update/updates/00039
-rw-r--r--tests/t-db/db-cross-single-update/status9
-rw-r--r--tests/t-db/db-cross-single-update/updates/000110
-rw-r--r--tests/t-db/db-cross-single-update/updates/00029
-rw-r--r--tests/t-db/db-dupe-multi/status20
-rw-r--r--tests/t-db/db-dupe-multi/updates/.keep0
-rw-r--r--tests/t-db/db-field-blank-lines-update/status13
-rw-r--r--tests/t-db/db-field-blank-lines-update/updates/.keep0
-rw-r--r--tests/t-db/db-field-blank-lines-update/updates/000113
-rw-r--r--tests/t-db/db-field-blank-lines/status27
-rw-r--r--tests/t-db/db-field-blank-lines/updates/.keep0
-rw-r--r--tests/t-deb-lfs/Makefile35
-rw-r--r--tests/t-deb-lfs/pkg-lfs/DEBIAN/control7
-rw-r--r--tests/t-deb-lfs/pkg-sfs/DEBIAN/control7
-rw-r--r--tests/t-depends/Makefile83
-rw-r--r--tests/t-depends/pkg-depends-eq/DEBIAN/control8
-rw-r--r--tests/t-depends/pkg-depends-ge/DEBIAN/control8
-rw-r--r--tests/t-depends/pkg-depends-gt/DEBIAN/control8
-rw-r--r--tests/t-depends/pkg-depends-le/DEBIAN/control8
-rw-r--r--tests/t-depends/pkg-depends-lt/DEBIAN/control8
-rw-r--r--tests/t-depends/pkg-depends/DEBIAN/control8
-rw-r--r--tests/t-depends/pkg-real/DEBIAN/control7
-rw-r--r--tests/t-depends/pkg-version-1/DEBIAN/control7
-rw-r--r--tests/t-depends/pkg-version-2/DEBIAN/control7
-rw-r--r--tests/t-depends/pkg-version-3/DEBIAN/control7
-rw-r--r--tests/t-dir-extension-check/Makefile10
-rw-r--r--tests/t-dir-extension-check/pkg-dbg-dir/DEBIAN/control9
-rw-r--r--tests/t-dir-extension-check/pkg-dbg-dir/test-dir/.keep0
-rw-r--r--tests/t-dir-extension-check/pkg-dbg-dir/test-file0
-rw-r--r--tests/t-dir-leftover-conffile/Makefile13
-rw-r--r--tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/DEBIAN/conffiles1
-rw-r--r--tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/DEBIAN/control7
-rw-r--r--tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/test-dir/test-conffile0
-rw-r--r--tests/t-dir-leftover-deadlock/Makefile17
-rw-r--r--tests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/control7
-rwxr-xr-xtests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/postinst7
-rwxr-xr-xtests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/postrm7
-rw-r--r--tests/t-dir-leftover-deadlock/pkg-dir-shared-0/test-dir/.keep00
-rw-r--r--tests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/control8
-rwxr-xr-xtests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/postinst7
-rwxr-xr-xtests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/postrm7
-rw-r--r--tests/t-dir-leftover-deadlock/pkg-dir-shared-1/test-dir/.keep10
-rw-r--r--tests/t-dir-leftover-parents/Makefile16
-rw-r--r--tests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/control7
-rwxr-xr-xtests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/postinst7
-rwxr-xr-xtests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/postrm7
-rw-r--r--tests/t-dir-leftover-parents/pkg-dir-shared-notempty/test-dir/subdir/subsubdir/.keep0
-rw-r--r--tests/t-dir-leftover-parents/pkg-dir-shared/DEBIAN/control7
-rw-r--r--tests/t-dir-leftover-parents/pkg-dir-shared/test-dir/subdir/.keep0
-rw-r--r--tests/t-dir-shared-replaces-lost/Makefile35
-rw-r--r--tests/t-dir-shared-replaces-lost/pkg-dir-original/DEBIAN/control7
-rw-r--r--tests/t-dir-shared-replaces-lost/pkg-dir-original/test-dir/test-original0
-rw-r--r--tests/t-dir-shared-replaces-lost/pkg-dir-takeover/DEBIAN/control8
-rw-r--r--tests/t-dir-shared-replaces-lost/pkg-dir-takeover/test-dir/test-takeover0
-rw-r--r--tests/t-disappear-depended/Makefile21
-rw-r--r--tests/t-disappear-depended/pkg-depend/DEBIAN/control9
-rw-r--r--tests/t-disappear-depended/pkg-disappear/DEBIAN/control8
-rw-r--r--tests/t-disappear-depended/pkg-normal/DEBIAN/control8
-rw-r--r--tests/t-disappear-depended/pkg-normal/test-dir/test-normal0
-rw-r--r--tests/t-disappear-empty/Makefile16
-rw-r--r--tests/t-disappear-empty/pkg-disappear-0/DEBIAN/control8
-rw-r--r--tests/t-disappear-empty/pkg-disappear-0/test-dir/test-disappear0
-rw-r--r--tests/t-disappear-empty/pkg-disappear-1/DEBIAN/control8
-rw-r--r--tests/t-disappear-empty/pkg-normal/DEBIAN/control10
-rw-r--r--tests/t-disappear-empty/pkg-normal/test-dir/test-normal0
-rw-r--r--tests/t-disappear/Makefile14
-rw-r--r--tests/t-disappear/pkg-disappear-0/DEBIAN/control8
-rw-r--r--tests/t-disappear/pkg-disappear-0/test-dir/test-disappear0
-rw-r--r--tests/t-disappear/pkg-disappear-1/DEBIAN/control8
-rw-r--r--tests/t-disappear/pkg-normal/DEBIAN/control8
-rw-r--r--tests/t-disappear/pkg-normal/test-dir/test-normal0
-rw-r--r--tests/t-failinst-failrm/Makefile12
-rw-r--r--tests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/control9
-rwxr-xr-xtests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/postinst15
-rwxr-xr-xtests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/prerm15
-rw-r--r--tests/t-failinst-failrm/pkg-failinst-failrm-1/DEBIAN/control7
-rw-r--r--tests/t-field-priority/Makefile12
-rw-r--r--tests/t-field-priority/pkg-priority/DEBIAN/control7
-rw-r--r--tests/t-file-conflicts/Makefile15
-rw-r--r--tests/t-file-conflicts/pkg-a/DEBIAN/control8
-rw-r--r--tests/t-file-conflicts/pkg-a/test-conflict0
-rw-r--r--tests/t-file-conflicts/pkg-b/DEBIAN/control8
-rw-r--r--tests/t-file-conflicts/pkg-b/test-conflict0
-rw-r--r--tests/t-file-replaces-disappear/Makefile65
-rw-r--r--tests/t-file-replaces-disappear/pkg-file-original/DEBIAN/control8
-rw-r--r--tests/t-file-replaces-disappear/pkg-file-original/test-file1
-rw-r--r--tests/t-file-replaces-disappear/pkg-file-original/test-other1
-rw-r--r--tests/t-file-replaces-disappear/pkg-file-takeover/DEBIAN/control9
-rw-r--r--tests/t-file-replaces-disappear/pkg-file-takeover/test-file1
-rw-r--r--tests/t-file-replaces-disappear/pkg-file-takeover/test-other1
-rw-r--r--tests/t-file-replaces-disappear/ref-file1
-rw-r--r--tests/t-file-replaces-versioned/Makefile52
-rw-r--r--tests/t-file-replaces-versioned/pkg-file-original-0/DEBIAN/control7
-rw-r--r--tests/t-file-replaces-versioned/pkg-file-original-0/test-file1
-rw-r--r--tests/t-file-replaces-versioned/pkg-file-original-0/test-original0
-rw-r--r--tests/t-file-replaces-versioned/pkg-file-original-1/DEBIAN/control7
-rw-r--r--tests/t-file-replaces-versioned/pkg-file-original-1/test-original0
-rw-r--r--tests/t-file-replaces-versioned/pkg-file-takeover-0/DEBIAN/control7
-rw-r--r--tests/t-file-replaces-versioned/pkg-file-takeover-0/test-takeover0
-rw-r--r--tests/t-file-replaces-versioned/pkg-file-takeover-1/DEBIAN/control8
-rw-r--r--tests/t-file-replaces-versioned/pkg-file-takeover-1/test-file1
-rw-r--r--tests/t-file-replaces-versioned/pkg-file-takeover-1/test-takeover0
-rw-r--r--tests/t-file-replaces-versioned/ref-file1
-rw-r--r--tests/t-file-replaces/Makefile44
-rw-r--r--tests/t-file-replaces/pkg-file-original/DEBIAN/control8
-rw-r--r--tests/t-file-replaces/pkg-file-original/test-file1
-rw-r--r--tests/t-file-replaces/pkg-file-original/test-original0
-rw-r--r--tests/t-file-replaces/pkg-file-takeover/DEBIAN/control9
-rw-r--r--tests/t-file-replaces/pkg-file-takeover/test-file1
-rw-r--r--tests/t-file-replaces/pkg-file-takeover/test-takeover0
-rw-r--r--tests/t-file-replaces/ref-file1
-rw-r--r--tests/t-filtering/Makefile166
-rw-r--r--tests/t-filtering/pkg-somefiles/DEBIAN/control8
-rw-r--r--tests/t-filtering/pkg-somefiles/test/lib/pkg-somefiles/run0
-rw-r--r--tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/README0
-rw-r--r--tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/copyright0
-rw-r--r--tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/html/index.html0
-rw-r--r--tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/html/topic1/1.html0
-rw-r--r--tests/t-filtering/pkg-somefiles/test/share/locale/ca/foo.mo0
-rw-r--r--tests/t-filtering/pkg-somefiles/test/share/locale/de/foo.mo0
-rw-r--r--tests/t-filtering/pkg-somefiles/test/share/locale/es/foo.mo0
-rw-r--r--tests/t-maintscript-leak/Makefile14
-rw-r--r--tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/control7
-rwxr-xr-xtests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/postinst16
-rwxr-xr-xtests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/postrm16
-rwxr-xr-xtests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/preinst16
-rwxr-xr-xtests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/prerm16
-rw-r--r--tests/t-multiarch/Makefile831
-rw-r--r--tests/t-multiarch/pkg-template/DEBIAN/control9
-rw-r--r--tests/t-normal/Makefile12
-rw-r--r--tests/t-normal/pkg-normal/DEBIAN/control8
-rw-r--r--tests/t-option-dry-run/Makefile32
-rw-r--r--tests/t-option-dry-run/pkg-normal/DEBIAN/control8
-rw-r--r--tests/t-option-recursive/Makefile25
-rw-r--r--tests/t-option-recursive/dir-a/pkg-a/DEBIAN/control7
-rw-r--r--tests/t-option-recursive/dir-b/dir-bb/pkg-b/DEBIAN/control7
-rw-r--r--tests/t-option-recursive/pkg-c/DEBIAN/control7
-rw-r--r--tests/t-predepends-no-triggers/Makefile28
-rw-r--r--tests/t-predepends-no-triggers/pkg-predepends/DEBIAN/control8
-rw-r--r--tests/t-predepends-no-triggers/pkg-real/DEBIAN/control8
-rw-r--r--tests/t-predepends-no-triggers/pkg-real/trigger/a-file1
-rw-r--r--tests/t-predepends-no-triggers/pkg-trigger/DEBIAN/control8
-rwxr-xr-xtests/t-predepends-no-triggers/pkg-trigger/DEBIAN/postinst3
-rw-r--r--tests/t-predepends-no-triggers/pkg-trigger/DEBIAN/triggers1
-rw-r--r--tests/t-provides-arch-implicit/Makefile24
-rw-r--r--tests/t-provides-arch-implicit/pkg-a/DEBIAN/control9
-rw-r--r--tests/t-provides-arch-implicit/pkg-b/DEBIAN/control9
-rw-r--r--tests/t-provides-arch-implicit/pkg-dep/DEBIAN/control9
-rw-r--r--tests/t-provides-arch-qualified/Makefile16
-rw-r--r--tests/t-provides-arch-qualified/pkg-a/DEBIAN/control10
-rw-r--r--tests/t-provides-arch-qualified/pkg-b/DEBIAN/control9
-rw-r--r--tests/t-provides-self/Makefile281
-rw-r--r--tests/t-provides-self/pkg-breaks-eq/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-breaks-ge/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-breaks-le/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-breaks/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-conflicts-eq/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-conflicts-ge/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-conflicts-le/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-conflicts/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-depends-eq/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-depends-ge/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-depends-le/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-depends/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-predepends-eq/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-predepends-ge/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-predepends-le/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-predepends/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-provides-10-20/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-provides-10/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-provides-20/DEBIAN/control8
-rw-r--r--tests/t-provides-self/pkg-provides/DEBIAN/control8
-rw-r--r--tests/t-provides/Makefile307
-rw-r--r--tests/t-provides/pkg-a-depends-ge-lt/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-b-provides-10/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-breaks-eq/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-breaks-ge/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-breaks-le/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-breaks/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-c-provides-20/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-conflicts-eq/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-conflicts-ge/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-conflicts-le/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-conflicts/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-depends-eq/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-depends-ge/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-depends-le/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-depends/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-predepends-eq/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-predepends-ge/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-predepends-le/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-predepends/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-provides-10-20/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-provides-10/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-provides-20/DEBIAN/control8
-rw-r--r--tests/t-provides/pkg-provides/DEBIAN/control8
-rw-r--r--tests/t-queue-process-deconf-dupe/Makefile12
-rw-r--r--tests/t-queue-process-deconf-dupe/pkg-a-0/DEBIAN/control7
-rw-r--r--tests/t-queue-process-deconf-dupe/pkg-a-0/test-a0
-rw-r--r--tests/t-queue-process-deconf-dupe/pkg-a-0/test-move0
-rw-r--r--tests/t-queue-process-deconf-dupe/pkg-a-1/DEBIAN/control7
-rw-r--r--tests/t-queue-process-deconf-dupe/pkg-a-1/test-a0
-rw-r--r--tests/t-queue-process-deconf-dupe/pkg-b/DEBIAN/control9
-rw-r--r--tests/t-queue-process-deconf-dupe/pkg-b/test-b0
-rw-r--r--tests/t-queue-process-deconf-dupe/pkg-b/test-move0
-rw-r--r--tests/t-switch-dir-to-symlink-abs/Makefile146
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/DEBIAN/conffiles1
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/DEBIAN/control7
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/test-path/file-conf0
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/control7
-rwxr-xr-xtests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/postinst5
-rwxr-xr-xtests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/postrm5
-rwxr-xr-xtests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/preinst5
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-file-moved/DEBIAN/control7
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-file-moved/test-dir/file-normal0
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-file-other/DEBIAN/control7
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-file-other/test-path/file-other0
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-0/DEBIAN/control7
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-0/test-path/file-normal0
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/control8
-rwxr-xr-xtests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/postinst5
-rwxr-xr-xtests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/postrm5
-rwxr-xr-xtests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/preinst5
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-0/DEBIAN/control7
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-0/test-path/file-normal0
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/control7
-rwxr-xr-xtests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/postinst5
-rwxr-xr-xtests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/postrm5
-rwxr-xr-xtests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/preinst5
-rw-r--r--tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/test-dir/file-other0
-rw-r--r--tests/t-switch-dir-to-symlink-rel/Makefile156
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/DEBIAN/conffiles1
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/DEBIAN/control7
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/test-path/test-subpath/file-conf0
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/control7
-rwxr-xr-xtests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/postinst6
-rwxr-xr-xtests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/postrm6
-rwxr-xr-xtests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/preinst6
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-file-moved/DEBIAN/control7
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-file-moved/test-dir/file-normal0
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-file-other/DEBIAN/control7
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-file-other/test-path/test-subpath/file-other0
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-0/DEBIAN/control7
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-0/test-path/test-subpath/file-normal0
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/control8
-rwxr-xr-xtests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/postinst6
-rwxr-xr-xtests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/postrm6
-rwxr-xr-xtests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/preinst6
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-0/DEBIAN/control7
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-0/test-path/test-subpath/file-normal0
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/control7
-rwxr-xr-xtests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/postinst6
-rwxr-xr-xtests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/postrm6
-rwxr-xr-xtests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/preinst6
-rw-r--r--tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/test-dir/file-other0
-rw-r--r--tests/t-switch-symlink-abs-to-dir/Makefile28
-rw-r--r--tests/t-switch-symlink-abs-to-dir/pkg-dir-real/DEBIAN/control7
-rw-r--r--tests/t-switch-symlink-abs-to-dir/pkg-dir-real/test-dir/file-dir0
-rw-r--r--tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-0/DEBIAN/control7
-rw-r--r--tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/control7
-rwxr-xr-xtests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/postinst5
-rwxr-xr-xtests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/postrm5
-rwxr-xr-xtests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/preinst5
-rw-r--r--tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/test-symlink/file-owned0
-rw-r--r--tests/t-switch-symlink-rel-to-dir/Makefile30
-rw-r--r--tests/t-switch-symlink-rel-to-dir/pkg-dir-real/DEBIAN/control7
-rw-r--r--tests/t-switch-symlink-rel-to-dir/pkg-dir-real/test-dir/file-dir0
-rw-r--r--tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-0/DEBIAN/control7
-rw-r--r--tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/control7
-rwxr-xr-xtests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/postinst6
-rwxr-xr-xtests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/postrm6
-rwxr-xr-xtests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/preinst6
-rw-r--r--tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/test-path/test-symlink/file-owned0
-rw-r--r--tests/t-symlink-dir/Makefile29
-rw-r--r--tests/t-symlink-dir/pkg-dir-real/DEBIAN/control8
-rw-r--r--tests/t-symlink-dir/pkg-dir-real/test-dir/file-dir0
-rw-r--r--tests/t-symlink-dir/pkg-dir-symlink-0/DEBIAN/control8
-rw-r--r--tests/t-symlink-dir/pkg-dir-symlink-0/file-symlink0
-rw-r--r--tests/t-symlink-dir/pkg-dir-symlink-1/DEBIAN/control8
-rw-r--r--tests/t-symlink-dir/pkg-dir-symlink-1/file-symlink0
-rw-r--r--tests/t-symlink-dir/pkg-file/DEBIAN/conffiles1
-rw-r--r--tests/t-symlink-dir/pkg-file/DEBIAN/control8
-rw-r--r--tests/t-symlink-dir/pkg-file/test-symlink/file-file0
-rw-r--r--tests/t-triggers-configure/Makefile22
-rw-r--r--tests/t-triggers-configure/pkg-activate/DEBIAN/control7
-rw-r--r--tests/t-triggers-configure/pkg-activate/test/trigger/test-file1
-rw-r--r--tests/t-triggers-configure/pkg-interest-0/DEBIAN/control7
-rw-r--r--tests/t-triggers-configure/pkg-interest-0/DEBIAN/triggers1
-rw-r--r--tests/t-triggers-configure/pkg-interest-1/DEBIAN/control7
-rwxr-xr-xtests/t-triggers-configure/pkg-interest-1/DEBIAN/postinst15
-rw-r--r--tests/t-triggers-configure/pkg-interest-1/DEBIAN/triggers1
-rw-r--r--tests/t-triggers-cycle/Makefile21
-rw-r--r--tests/t-triggers-cycle/pkg-depends/DEBIAN/control7
-rw-r--r--tests/t-triggers-cycle/pkg-trigger-a/DEBIAN/control8
-rwxr-xr-xtests/t-triggers-cycle/pkg-trigger-a/DEBIAN/postinst20
-rw-r--r--tests/t-triggers-cycle/pkg-trigger-a/DEBIAN/triggers1
-rw-r--r--tests/t-triggers-cycle/pkg-trigger-b/DEBIAN/control8
-rwxr-xr-xtests/t-triggers-cycle/pkg-trigger-b/DEBIAN/postinst20
-rw-r--r--tests/t-triggers-cycle/pkg-trigger-b/DEBIAN/triggers1
-rw-r--r--tests/t-triggers-depcycle/Makefile25
-rw-r--r--tests/t-triggers-depcycle/pkg-depends-0/DEBIAN/control7
-rw-r--r--tests/t-triggers-depcycle/pkg-depends-1/DEBIAN/control8
-rw-r--r--tests/t-triggers-depcycle/pkg-files-0/DEBIAN/control8
-rw-r--r--tests/t-triggers-depcycle/pkg-files-0/test/trigger/test-file1
-rw-r--r--tests/t-triggers-depcycle/pkg-files-1/DEBIAN/control8
-rw-r--r--tests/t-triggers-depcycle/pkg-files-1/test/trigger/test-file1
-rw-r--r--tests/t-triggers-depcycle/pkg-trigger/DEBIAN/control8
-rwxr-xr-xtests/t-triggers-depcycle/pkg-trigger/DEBIAN/postinst23
-rw-r--r--tests/t-triggers-depcycle/pkg-trigger/DEBIAN/triggers1
-rw-r--r--tests/t-triggers-depends/Makefile25
-rw-r--r--tests/t-triggers-depends/pkg-activate/DEBIAN/control7
-rw-r--r--tests/t-triggers-depends/pkg-activate/test/trigger/trigger-file1
-rw-r--r--tests/t-triggers-depends/pkg-depended/DEBIAN/control7
-rw-r--r--tests/t-triggers-depends/pkg-interest/DEBIAN/control8
-rwxr-xr-xtests/t-triggers-depends/pkg-interest/DEBIAN/postinst16
-rw-r--r--tests/t-triggers-depends/pkg-interest/DEBIAN/triggers1
-rw-r--r--tests/t-triggers-depfarcycle/Makefile36
-rw-r--r--tests/t-triggers-depfarcycle/pkg-depends-a/DEBIAN/control8
-rw-r--r--tests/t-triggers-depfarcycle/pkg-depends-b/DEBIAN/control8
-rw-r--r--tests/t-triggers-depfarcycle/pkg-files/DEBIAN/control8
-rw-r--r--tests/t-triggers-depfarcycle/pkg-files/test/trigger/test-file1
-rw-r--r--tests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/control8
-rwxr-xr-xtests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/postinst16
-rw-r--r--tests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/triggers1
-rw-r--r--tests/t-triggers-halt/Makefile26
-rw-r--r--tests/t-triggers-halt/pkg-depends/DEBIAN/control8
-rw-r--r--tests/t-triggers-halt/pkg-files/DEBIAN/control7
-rw-r--r--tests/t-triggers-halt/pkg-files/test/trigger/test-file1
-rw-r--r--tests/t-triggers-halt/pkg-remove/DEBIAN/control7
-rw-r--r--tests/t-triggers-halt/pkg-trigger/DEBIAN/control8
-rwxr-xr-xtests/t-triggers-halt/pkg-trigger/DEBIAN/postinst23
-rw-r--r--tests/t-triggers-halt/pkg-trigger/DEBIAN/triggers1
-rw-r--r--tests/t-triggers-path/Makefile26
-rw-r--r--tests/t-triggers-path/pkg-interest/DEBIAN/control7
-rwxr-xr-xtests/t-triggers-path/pkg-interest/DEBIAN/postinst14
-rw-r--r--tests/t-triggers-path/pkg-interest/DEBIAN/triggers1
-rw-r--r--tests/t-triggers-path/pkg-trigger-cmd/DEBIAN/control7
-rwxr-xr-xtests/t-triggers-path/pkg-trigger-cmd/DEBIAN/postinst5
-rw-r--r--tests/t-triggers-path/pkg-trigger-conffile/DEBIAN/conffiles1
-rw-r--r--tests/t-triggers-path/pkg-trigger-conffile/DEBIAN/control7
-rw-r--r--tests/t-triggers-path/pkg-trigger-conffile/test/trigger/test-file1
-rw-r--r--tests/t-triggers-selfcycle/Makefile25
-rw-r--r--tests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/control7
-rwxr-xr-xtests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/postinst10
-rw-r--r--tests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/triggers2
-rw-r--r--tests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/control7
-rwxr-xr-xtests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/postinst10
-rw-r--r--tests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/triggers1
-rw-r--r--tests/t-triggers-selfcycle/pkg-trigger-unpack/test/trigger/test-file1
-rw-r--r--tests/t-triggers/Makefile365
-rw-r--r--tests/t-triggers/pkg-trig-cmd/DEBIAN/control8
-rwxr-xr-xtests/t-triggers/pkg-trig-cmd/DEBIAN/postinst17
-rwxr-xr-xtests/t-triggers/pkg-trig-cmd/DEBIAN/postrm17
-rwxr-xr-xtests/t-triggers/pkg-trig-cmd/DEBIAN/preinst17
-rwxr-xr-xtests/t-triggers/pkg-trig-cmd/DEBIAN/prerm17
-rw-r--r--tests/t-triggers/pkg-trig-explicit/DEBIAN/control8
-rw-r--r--tests/t-triggers/pkg-trig-explicit/DEBIAN/triggers1
-rw-r--r--tests/t-triggers/pkg-trig-file/DEBIAN/control8
-rw-r--r--tests/t-triggers/pkg-trig-file/triggers/a-file1
-rw-r--r--tests/t-triggers/pkg-triggers-await/DEBIAN/control7
-rwxr-xr-xtests/t-triggers/pkg-triggers-await/DEBIAN/postinst13
-rw-r--r--tests/t-triggers/pkg-triggers-await/DEBIAN/triggers2
-rw-r--r--tests/t-triggers/pkg-triggers-noawait/DEBIAN/control8
-rwxr-xr-xtests/t-triggers/pkg-triggers-noawait/DEBIAN/postinst13
-rw-r--r--tests/t-triggers/pkg-triggers-noawait/DEBIAN/triggers2
-rw-r--r--tests/t-triggers/pkg-triggers/DEBIAN/control8
-rwxr-xr-xtests/t-triggers/pkg-triggers/DEBIAN/postinst13
-rw-r--r--tests/t-triggers/pkg-triggers/DEBIAN/triggers2
-rw-r--r--tests/t-unpack-device/Makefile26
-rw-r--r--tests/t-unpack-device/pkg-device/DEBIAN/control8
-rw-r--r--tests/t-unpack-divert-hardlink/Makefile31
-rw-r--r--tests/t-unpack-divert-hardlink/pkg-hardlink/DEBIAN/control7
-rw-r--r--tests/t-unpack-divert-hardlink/pkg-hardlink/test-file1
-rw-r--r--tests/t-unpack-divert-nowarn/Makefile10
-rw-r--r--tests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/control8
-rwxr-xr-xtests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/postrm7
-rwxr-xr-xtests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/preinst10
-rw-r--r--tests/t-unpack-divert-nowarn/pkg-divert-unpacking/test-file1
-rw-r--r--tests/t-unpack-divert-nowarn/pkg-files/DEBIAN/control7
-rw-r--r--tests/t-unpack-divert-nowarn/pkg-files/test-file1
-rw-r--r--tests/t-unpack-fifo/Makefile22
-rw-r--r--tests/t-unpack-fifo/pkg-fifo/DEBIAN/control8
-rw-r--r--tests/t-unpack-hardlink/Makefile56
-rw-r--r--tests/t-unpack-hardlink/pkg-hardlink/DEBIAN/conffiles2
-rw-r--r--tests/t-unpack-hardlink/pkg-hardlink/DEBIAN/control8
-rw-r--r--tests/t-unpack-symlink/Makefile12
-rw-r--r--tests/t-unpack-symlink/pkg-symlink/DEBIAN/control8
-rw-r--r--tests/t-unpack-symlink/pkg-symlink/test-file0
-rw-r--r--tests/t-unpack-symlink/pkg-symlink/test-symlink0
-rw-r--r--tests/t-verify/Makefile13
-rw-r--r--tests/t-verify/pkg-verify/DEBIAN/control7
-rw-r--r--tests/t-verify/pkg-verify/test-dir/test-data1
-rw-r--r--tests/t-verify/pkg-verify/test-dir/test-digits20
-rw-r--r--tests/t-verify/pkg-verify/test-file1
694 files changed, 7926 insertions, 0 deletions
diff --git a/tests/Feature.mk b/tests/Feature.mk
new file mode 100644
index 0000000..da4e8d6
--- /dev/null
+++ b/tests/Feature.mk
@@ -0,0 +1,19 @@
+#
+# Dpkg functional testsuite (kind of)
+#
+# Copyright © 2015 Guillem Jover <guillem@debian.org>
+#
+
+## Feature checks setup ##
+
+ifneq ($(DPKG_FEATURE_CHECKS),yes)
+export DPKG_FEATURE_CHECKS := yes
+
+# XXX: once apt is fixed:
+#export DPKG_HAS_CONFIGURE_WITH_IMPLICIT_TRIGGER_PENDING ?= 1
+
+ifneq (,$(filter as-root,$(DPKG_TESTSUITE_OPTIONS)))
+export DPKG_AS_ROOT = 1
+endif
+
+endif
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..3b885f0
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,155 @@
+#
+# Dpkg functional testsuite (kind of)
+#
+# Copyright © 2008-2015 Guillem Jover <guillem@debian.org>
+#
+
+
+-include .pkg-tests.conf
+
+## Feature checks setup ##
+
+include Feature.mk
+
+## Test cases ##
+
+TESTS_MANUAL :=
+TESTS_MANUAL += t-deb-lfs
+TESTS_MANUAL += t-conffile-prompt
+
+TESTS_FAIL :=
+TESTS_FAIL += t-dir-leftover-deadlock
+TESTS_FAIL += t-dir-shared-replaces-lost
+TESTS_FAIL += t-disappear-depended
+TESTS_FAIL += t-conffile-divert-conffile
+TESTS_FAIL += t-breaks-multiarch
+
+TESTS_PASS :=
+TESTS_PASS += t-db
+TESTS_PASS += t-normal
+TESTS_PASS += t-field-priority
+TESTS_PASS += t-option-dry-run
+TESTS_PASS += t-option-recursive
+TESTS_PASS += t-control-bogus
+TESTS_PASS += t-control-no-arch
+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-fifo
+ifdef DPKG_AS_ROOT
+# No permissions for devices
+TESTS_PASS += t-unpack-device
+endif
+TESTS_PASS += t-maintscript-leak
+TESTS_PASS += t-filtering
+TESTS_PASS += t-depends
+TESTS_PASS += t-dir-leftover-parents
+TESTS_PASS += t-dir-leftover-conffile
+TESTS_PASS += t-disappear
+TESTS_PASS += t-disappear-empty
+TESTS_PASS += t-provides
+TESTS_PASS += t-provides-self
+TESTS_PASS += t-provides-arch-implicit
+TESTS_PASS += t-provides-arch-qualified
+TESTS_PASS += t-breaks
+TESTS_PASS += t-breaks-protected
+TESTS_PASS += t-breaks-essential
+TESTS_PASS += t-conflicts
+TESTS_PASS += t-conflict-provide-replace-real
+TESTS_PASS += t-conflict-provide-replace-virtual
+TESTS_PASS += t-conflict-provide-replace-virtual-multiarch
+TESTS_PASS += t-conflict-provide-replace-interface
+TESTS_PASS += t-predepends-no-triggers
+TESTS_PASS += t-triggers
+TESTS_PASS += t-triggers-configure
+TESTS_PASS += t-triggers-path
+TESTS_PASS += t-triggers-depends
+TESTS_PASS += t-triggers-depcycle
+TESTS_PASS += t-triggers-depfarcycle
+TESTS_PASS += t-triggers-selfcycle
+TESTS_PASS += t-triggers-cycle
+TESTS_PASS += t-triggers-halt
+TESTS_PASS += t-file-conflicts
+TESTS_PASS += t-file-replaces
+TESTS_PASS += t-file-replaces-disappear
+TESTS_PASS += t-file-replaces-versioned
+TESTS_PASS += t-conffile-normal
+TESTS_PASS += t-conffile-obsolete
+TESTS_PASS += t-conffile-orphan
+TESTS_PASS += t-conffile-forcemiss
+TESTS_PASS += t-conffile-forcenew
+TESTS_PASS += t-conffile-forceask
+TESTS_PASS += t-conffile-root-option
+TESTS_PASS += t-conffile-divert-normal
+TESTS_PASS += t-conffile-conflict
+TESTS_PASS += t-conffile-replaces
+TESTS_PASS += t-conffile-replaces-upgrade
+TESTS_PASS += t-conffile-replaces-downgrade
+TESTS_PASS += t-conffile-replaces-existing
+TESTS_PASS += t-conffile-replaces-existing-and-upgrade
+TESTS_PASS += t-conffile-replaces-disappear
+TESTS_PASS += t-conffile-replaces-diverted
+TESTS_PASS += t-conffile-versioned-replaces-downgrade
+TESTS_PASS += t-conffile-rename
+TESTS_PASS += t-conffile-declarative-removal
+TESTS_PASS += t-queue-process-deconf-dupe
+TESTS_PASS += t-symlink-dir
+TESTS_PASS += t-switch-symlink-abs-to-dir
+TESTS_PASS += t-switch-symlink-rel-to-dir
+TESTS_PASS += t-switch-dir-to-symlink-abs
+TESTS_PASS += t-switch-dir-to-symlink-rel
+TESTS_PASS += t-failinst-failrm
+TESTS_PASS += t-dir-extension-check
+TESTS_PASS += t-multiarch
+
+ifneq (,$(filter test-all,$(DPKG_TESTSUITE_OPTIONS)))
+TESTS := $(TESTS_PASS) $(TESTS_FAIL) $(TESTS_MANUAL)
+else
+TESTS := $(TESTS_PASS)
+endif
+
+
+# By default do nothing
+all help::
+ @echo "Run 'make test' to run all the tests"
+ @echo "Run 'make <test-id>-test' to run a specifict test"
+ @echo "Run 'make clean' to remove all intermediary files"
+ @echo ""
+ @echo "The available tests are: $(TESTS)"
+
+build_targets = $(addsuffix -build,$(TESTS))
+
+build:: $(build_targets)
+$(build_targets)::
+ $(MAKE) -C $(subst -build,,$@) build
+
+.PHONY: build $(build_targets)
+
+
+test_targets = $(addsuffix -test,$(TESTS))
+
+test:: $(test_targets)
+$(test_targets)::
+ $(MAKE) -C $(subst -test,,$@) test
+
+.PHONY: test $(test_targets)
+
+
+test_clean_targets = $(addsuffix -test-clean,$(TESTS))
+
+test-clean:: $(test_clean_targets)
+$(test_clean_targets)::
+ $(MAKE) -C $(subst -test-clean,,$@) test-clean
+
+.PHONY: test-clean $(test_clean_targets)
+
+
+clean_targets = $(addsuffix -clean,$(TESTS))
+
+clean:: $(clean_targets)
+$(clean_targets)::
+ $(MAKE) -C $(subst -clean,,$@) clean
+
+.PHONY: clean $(clean_targets)
+
diff --git a/tests/README b/tests/README
new file mode 100644
index 0000000..62c8b75
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,57 @@
+dpkg functional test-suite
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+How to run
+----------
+
+After cloning the repository, you will need to run «./db-regen».
+
+There's a brief usage information when invoking “make” on the topdir.
+
+You probably want to use something like eatmydata to run the tests, it
+affects the performance significantly.
+
+To use the tools from the dpkg build-tree, set DPKG_BUILDTREE accordingly.
+
+The DPKG_TESTSUITE_OPTIONS environment/make variable can be used to change
+the behaviour of the test runs, the following options are currently
+supported:
+
+* as-root
+
+ WARNING: This runs the tests in privileged mode, and will write to your
+ current root filesystem. If you are uncertain of the consequences, run
+ it at least on a chroot, or isolated in a virtual machine.
+
+* test-all
+
+ This runs all tests, including manual and failing ones.
+
+* debug
+
+ This makes dpkg print lots of debug output.
+
+The configuration file ‘.pkg-tests.conf’ can be used to set permanent
+parameters. For example:
+
+ ,-- .pkg-tests.conf --
+ |DPKG_TESTSUITE_OPTIONS := debug
+ `--
+
+Test-suite layout
+-----------------
+
+The tests are split into logical units, testing a specific characteristic.
+To add a new test please check Test.mk and Makefile on the topdir, and some
+of the current tests. Patches welcome!
+
+Future plans
+------------
+
+There's lots of tests that are still missing, we are adding new ones when
+we stumble over regressions, when adding new functionality, and as time
+permits for existing functionality.
+
+The idea is for this to progressively be integrated into the autotools
+autotest suite under t-func/, and be run as part of “make check”. Some
+changes to dpkg would need to be implemented first.
diff --git a/tests/Test.mk b/tests/Test.mk
new file mode 100644
index 0000000..606e6f8
--- /dev/null
+++ b/tests/Test.mk
@@ -0,0 +1,124 @@
+#
+# Dpkg functional testsuite (kind of)
+#
+# Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
+#
+
+-include ../.pkg-tests.conf
+
+## Feature checks setup ##
+
+include ../Feature.mk
+
+## Test case support ##
+
+ifneq (,$(filter debug,$(DPKG_TESTSUITE_OPTIONS)))
+DPKG_MAINTSCRIPT_DEBUG = DPKG_DEBUG=1
+endif
+
+DPKG_PATH := $(PATH):/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ifdef DPKG_BUILDTREE
+DPKG_PATH := $(DPKG_BUILDTREE)/dpkg-deb:$(DPKG_BUILDTREE)/dpkg-split:$(DPKG_BUILDTREE)/src:$(DPKG_BUILDTREE)/utils:$(DPKG_BUILDTREE)/scripts:$(DPKG_PATH)
+endif
+
+DPKG_ENV = \
+ PATH=$(DPKG_PATH) \
+ $(DPKG_MAINTSCRIPT_DEBUG)
+
+ifdef DPKG_BUILDTREE
+export DPKG_DATADIR := $(DPKG_BUILDTREE)/scripts
+DPKG_ENV += \
+ DPKG_DATADIR="$(DPKG_DATADIR)"
+endif
+
+export PATH
+PATH = $(DPKG_PATH)
+
+DPKG_OPTIONS =
+DPKG_DIVERT_OPTIONS =
+
+ifdef DPKG_AS_ROOT
+DPKG_INSTDIR = /
+ifeq ($(shell id -u),0)
+BEROOT := env $(DPKG_ENV)
+else
+DPKG_ENV += \
+ LD_PRELOAD="$(LD_PRELOAD)" \
+ LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)"
+BEROOT := sudo -E env $(DPKG_ENV)
+endif
+else
+DPKG_INSTDIR = $(CURDIR)/../dpkginst
+DPKG_OPTIONS += \
+ --force-script-chrootless \
+ --force-not-root \
+ # EOL
+BEROOT := env $(DPKG_ENV)
+
+DPKG_DIVERT_OPTIONS += \
+ --instdir="$(DPKG_INSTDIR)" \
+ # EOL
+endif
+
+DPKG_OPTIONS += \
+ --force-unsafe-io \
+ --instdir="$(DPKG_INSTDIR)" \
+ --no-debsig --log=/dev/null \
+ # EOL
+
+ifneq (,$(filter debug,$(DPKG_TESTSUITE_OPTIONS)))
+DPKG_OPTIONS += -D77777
+endif
+
+# Always use a local db.
+DPKG_ADMINDIR = $(CURDIR)/../dpkgdb
+DPKG_COMMON_OPTIONS = --admindir="$(DPKG_ADMINDIR)"
+
+DPKG = dpkg $(DPKG_COMMON_OPTIONS) $(DPKG_OPTIONS)
+DPKG_INSTALL = $(BEROOT) $(DPKG) -i
+DPKG_UNPACK = $(BEROOT) $(DPKG) --unpack
+DPKG_CONFIGURE = $(BEROOT) $(DPKG) --configure
+DPKG_REMOVE = $(BEROOT) $(DPKG) -r
+DPKG_PURGE = $(BEROOT) $(DPKG) -P
+DPKG_VERIFY = $(DPKG) -V
+DPKG_DEB = dpkg-deb $(DPKG_DEB_OPTIONS)
+DPKG_DIVERT = dpkg-divert $(DPKG_COMMON_OPTIONS) $(DPKG_DIVERT_OPTIONS)
+DPKG_DIVERT_ADD = $(BEROOT) $(DPKG_DIVERT) --add
+DPKG_DIVERT_DEL = $(BEROOT) $(DPKG_DIVERT) --remove
+DPKG_SPLIT = dpkg-split $(DPKG_SPLIT_OPTIONS)
+DPKG_BUILD_DEB = $(DPKG_DEB) -b
+DPKG_QUERY = dpkg-query $(DPKG_COMMON_OPTIONS) $(DPKG_QUERY_OPTIONS)
+DPKG_TRIGGER = dpkg-trigger $(DPKG_COMMON_OPTIONS) $(DPKG_TRIGGER_OPTIONS)
+
+PKG_STATUS = $(DPKG_QUERY) -f '$${Status}' -W
+
+DEB = $(addsuffix .deb,$(TESTS_DEB))
+
+# Common test patterns to use with $(call foo,args...)
+stdout_is = test "`$(1)`" = "$(2)"
+stdout_has = $(1) | grep -qE "$(2)"
+stderr_is = test "`$(1) 2>&1 1>/dev/null`" = "$(2)"
+stderr_has = $(1) 2>&1 1>/dev/null | grep -qE "$(2)"
+pkg_is_installed = $(call stdout_is,$(PKG_STATUS) $(1),install ok installed)
+pkg_is_not_installed = $(call stdout_has,$(PKG_STATUS) $(1) 2>/dev/null, ok not-installed) || ! $(PKG_STATUS) $(1) >/dev/null 2>&1
+pkg_status_is = $(call stdout_is,$(PKG_STATUS) $(1),$(2))
+pkg_field_is = $(call stdout_is,$(DPKG_QUERY) -f '$${$(2)}' -W $(1),$(3))
+
+%.deb: %
+ $(DPKG_BUILD_DEB) $< $@
+
+TEST_CASES :=
+
+build: build-hook $(DEB)
+
+test: build test-case test-clean
+
+clean: clean-hook
+ $(RM) $(DEB)
+
+.PHONY: build-hook build test test-case test-clean clean-hook clean
+
+# Most of the tests are serial in nature, as they perform package database
+# changes, and the Makefile are written with that in mind. Avoid any
+# surprises by explicitly disallowing parallel executions.
+.NOTPARALLEL:
diff --git a/tests/db-regen b/tests/db-regen
new file mode 100755
index 0000000..f4e83f2
--- /dev/null
+++ b/tests/db-regen
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# Regenerate the local dpkg db
+#
+# Copyright © 2011-2012 Guillem Jover <guillem@debian.org>
+#
+
+dbdir=${1:-dpkgdb}
+instdir=${2:-dpkginst}
+
+mkdir -p $instdir
+
+rm -f $dbdir/arch
+rm -f $dbdir/status*
+rm -f $dbdir/available*
+rm -f $dbdir/diversions*
+rm -f $dbdir/statoverride*
+rm -f $dbdir/info/format
+rm -rf $dbdir/parts
+rm -rf $dbdir/updates
+rm -rf $dbdir/triggers
+
+mkdir -p $dbdir
+touch $dbdir/lock
+touch $dbdir/status
+touch $dbdir/available
+touch $dbdir/diversions
+touch $dbdir/statoverride
+mkdir -p $dbdir/info
+mkdir $dbdir/parts
+mkdir $dbdir/updates
+mkdir $dbdir/triggers
+touch $dbdir/triggers/Lock
+touch $dbdir/triggers/Unincorp
diff --git a/tests/dpkgdb/available b/tests/dpkgdb/available
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/dpkgdb/available
diff --git a/tests/dpkgdb/diversions b/tests/dpkgdb/diversions
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/dpkgdb/diversions
diff --git a/tests/dpkgdb/lock b/tests/dpkgdb/lock
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/dpkgdb/lock
diff --git a/tests/dpkgdb/lock-frontend b/tests/dpkgdb/lock-frontend
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/dpkgdb/lock-frontend
diff --git a/tests/dpkgdb/statoverride b/tests/dpkgdb/statoverride
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/dpkgdb/statoverride
diff --git a/tests/dpkgdb/status b/tests/dpkgdb/status
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/dpkgdb/status
diff --git a/tests/dpkgdb/triggers/Lock b/tests/dpkgdb/triggers/Lock
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/dpkgdb/triggers/Lock
diff --git a/tests/dpkgdb/triggers/Unincorp b/tests/dpkgdb/triggers/Unincorp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/dpkgdb/triggers/Unincorp
diff --git a/tests/t-breaks-essential/Makefile b/tests/t-breaks-essential/Makefile
new file mode 100644
index 0000000..ace63f0
--- /dev/null
+++ b/tests/t-breaks-essential/Makefile
@@ -0,0 +1,13 @@
+TESTS_DEB := lib-a-0 lib-a-1 pkg-b
+
+include ../Test.mk
+
+DPKG_OPTIONS += --auto-deconfigure
+
+test-case:
+ $(DPKG_INSTALL) lib-a-0.deb
+ $(DPKG_INSTALL) pkg-b.deb lib-a-1.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-b
+ $(DPKG_PURGE) --force-remove-essential lib-a
diff --git a/tests/t-breaks-essential/lib-a-0/DEBIAN/control b/tests/t-breaks-essential/lib-a-0/DEBIAN/control
new file mode 100644
index 0000000..7643fd8
--- /dev/null
+++ b/tests/t-breaks-essential/lib-a-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Essential: yes
+Description: test package - broken package
diff --git a/tests/t-breaks-essential/lib-a-1/DEBIAN/control b/tests/t-breaks-essential/lib-a-1/DEBIAN/control
new file mode 100644
index 0000000..5c37c03
--- /dev/null
+++ b/tests/t-breaks-essential/lib-a-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-a
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Essential: yes
+Description: test package - broken package
diff --git a/tests/t-breaks-essential/pkg-b/DEBIAN/control b/tests/t-breaks-essential/pkg-b/DEBIAN/control
new file mode 100644
index 0000000..c0da700
--- /dev/null
+++ b/tests/t-breaks-essential/pkg-b/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: lib-a (<< 1)
+Description: test package - breaking package
diff --git a/tests/t-breaks-multiarch/Makefile b/tests/t-breaks-multiarch/Makefile
new file mode 100644
index 0000000..344e05a
--- /dev/null
+++ b/tests/t-breaks-multiarch/Makefile
@@ -0,0 +1,22 @@
+TESTS_DEB := lib-a-0-amd64 lib-a-0-i386 \
+ lib-a-1-amd64 lib-a-1-i386 \
+ lib-b-0-amd64 lib-b-0-i386 \
+ lib-b-1-amd64 lib-b-1-i386 \
+ pkg-c
+
+include ../Test.mk
+
+DPKG_OPTIONS += --auto-deconfigure
+
+test-case:
+ $(DPKG) --add-architecture i386
+ $(DPKG_INSTALL) lib-a-0-amd64.deb lib-a-0-i386.deb
+ $(DPKG_INSTALL) lib-b-0-amd64.deb lib-b-0-i386.deb
+ $(DPKG_INSTALL) pkg-c.deb \
+ lib-a-1-amd64.deb lib-a-1-i386.deb \
+ lib-b-1-amd64.deb lib-b-1-i386.deb
+
+test-clean:
+ $(DPKG_PURGE) lib-a:amd64 lib-a:i386 lib-b:amd64 lib-b:i386 pkg-c
+ $(DPKG) --remove-architecture i386
+ rm -f $(DPKG_ADMINDIR)/arch
diff --git a/tests/t-breaks-multiarch/lib-a-0-amd64/DEBIAN/control b/tests/t-breaks-multiarch/lib-a-0-amd64/DEBIAN/control
new file mode 100644
index 0000000..8f91a57
--- /dev/null
+++ b/tests/t-breaks-multiarch/lib-a-0-amd64/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Description: test package - broken package
diff --git a/tests/t-breaks-multiarch/lib-a-0-i386/DEBIAN/control b/tests/t-breaks-multiarch/lib-a-0-i386/DEBIAN/control
new file mode 100644
index 0000000..0a8db71
--- /dev/null
+++ b/tests/t-breaks-multiarch/lib-a-0-i386/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: same
+Description: test package - broken package
diff --git a/tests/t-breaks-multiarch/lib-a-1-amd64/DEBIAN/control b/tests/t-breaks-multiarch/lib-a-1-amd64/DEBIAN/control
new file mode 100644
index 0000000..dca3d18
--- /dev/null
+++ b/tests/t-breaks-multiarch/lib-a-1-amd64/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-a
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Description: test package - broken package
diff --git a/tests/t-breaks-multiarch/lib-a-1-i386/DEBIAN/control b/tests/t-breaks-multiarch/lib-a-1-i386/DEBIAN/control
new file mode 100644
index 0000000..2af8f28
--- /dev/null
+++ b/tests/t-breaks-multiarch/lib-a-1-i386/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-a
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: same
+Description: test package - broken package
diff --git a/tests/t-breaks-multiarch/lib-b-0-amd64/DEBIAN/control b/tests/t-breaks-multiarch/lib-b-0-amd64/DEBIAN/control
new file mode 100644
index 0000000..ebfcac3
--- /dev/null
+++ b/tests/t-breaks-multiarch/lib-b-0-amd64/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Description: test package - broken package
diff --git a/tests/t-breaks-multiarch/lib-b-0-i386/DEBIAN/control b/tests/t-breaks-multiarch/lib-b-0-i386/DEBIAN/control
new file mode 100644
index 0000000..52dd252
--- /dev/null
+++ b/tests/t-breaks-multiarch/lib-b-0-i386/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: same
+Description: test package - broken package
diff --git a/tests/t-breaks-multiarch/lib-b-1-amd64/DEBIAN/control b/tests/t-breaks-multiarch/lib-b-1-amd64/DEBIAN/control
new file mode 100644
index 0000000..970a873
--- /dev/null
+++ b/tests/t-breaks-multiarch/lib-b-1-amd64/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-b
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Description: test package - broken package
diff --git a/tests/t-breaks-multiarch/lib-b-1-i386/DEBIAN/control b/tests/t-breaks-multiarch/lib-b-1-i386/DEBIAN/control
new file mode 100644
index 0000000..7ceb7d4
--- /dev/null
+++ b/tests/t-breaks-multiarch/lib-b-1-i386/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-b
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: same
+Description: test package - broken package
diff --git a/tests/t-breaks-multiarch/pkg-c/DEBIAN/control b/tests/t-breaks-multiarch/pkg-c/DEBIAN/control
new file mode 100644
index 0000000..95ebbac
--- /dev/null
+++ b/tests/t-breaks-multiarch/pkg-c/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-c
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: lib-b (<< 1)
+Description: test package - breaking package
diff --git a/tests/t-breaks-protected/Makefile b/tests/t-breaks-protected/Makefile
new file mode 100644
index 0000000..3f85436
--- /dev/null
+++ b/tests/t-breaks-protected/Makefile
@@ -0,0 +1,13 @@
+TESTS_DEB := lib-a-0 lib-a-1 pkg-b
+
+include ../Test.mk
+
+DPKG_OPTIONS += --auto-deconfigure
+
+test-case:
+ $(DPKG_INSTALL) lib-a-0.deb
+ $(DPKG_INSTALL) pkg-b.deb lib-a-1.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-b
+ $(DPKG_PURGE) --force-remove-protected lib-a
diff --git a/tests/t-breaks-protected/lib-a-0/DEBIAN/control b/tests/t-breaks-protected/lib-a-0/DEBIAN/control
new file mode 100644
index 0000000..7ca516e
--- /dev/null
+++ b/tests/t-breaks-protected/lib-a-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Protected: yes
+Description: test package - broken package
diff --git a/tests/t-breaks-protected/lib-a-1/DEBIAN/control b/tests/t-breaks-protected/lib-a-1/DEBIAN/control
new file mode 100644
index 0000000..1320318
--- /dev/null
+++ b/tests/t-breaks-protected/lib-a-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: lib-a
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Protected: yes
+Description: test package - broken package
diff --git a/tests/t-breaks-protected/pkg-b/DEBIAN/control b/tests/t-breaks-protected/pkg-b/DEBIAN/control
new file mode 100644
index 0000000..c0da700
--- /dev/null
+++ b/tests/t-breaks-protected/pkg-b/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: lib-a (<< 1)
+Description: test package - breaking package
diff --git a/tests/t-breaks/Makefile b/tests/t-breaks/Makefile
new file mode 100644
index 0000000..9ffd02c
--- /dev/null
+++ b/tests/t-breaks/Makefile
@@ -0,0 +1,12 @@
+TESTS_DEB := lib-a-0 lib-a-1 lib-b-0 lib-b-1 pkg-c
+
+include ../Test.mk
+
+DPKG_OPTIONS += --auto-deconfigure
+
+test-case:
+ $(DPKG_INSTALL) lib-a-0.deb lib-b-0.deb
+ $(DPKG_INSTALL) pkg-c.deb lib-a-1.deb lib-b-1.deb
+
+test-clean:
+ $(DPKG_PURGE) lib-a lib-b pkg-c
diff --git a/tests/t-breaks/lib-a-0/DEBIAN/control b/tests/t-breaks/lib-a-0/DEBIAN/control
new file mode 100644
index 0000000..241a6fc
--- /dev/null
+++ b/tests/t-breaks/lib-a-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: lib-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - broken package
diff --git a/tests/t-breaks/lib-a-1/DEBIAN/control b/tests/t-breaks/lib-a-1/DEBIAN/control
new file mode 100644
index 0000000..e0f19ec
--- /dev/null
+++ b/tests/t-breaks/lib-a-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: lib-a
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - broken package
diff --git a/tests/t-breaks/lib-b-0/DEBIAN/control b/tests/t-breaks/lib-b-0/DEBIAN/control
new file mode 100644
index 0000000..2b34688
--- /dev/null
+++ b/tests/t-breaks/lib-b-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: lib-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - broken package
diff --git a/tests/t-breaks/lib-b-1/DEBIAN/control b/tests/t-breaks/lib-b-1/DEBIAN/control
new file mode 100644
index 0000000..7c423ca
--- /dev/null
+++ b/tests/t-breaks/lib-b-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: lib-b
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - broken package
diff --git a/tests/t-breaks/pkg-c/DEBIAN/control b/tests/t-breaks/pkg-c/DEBIAN/control
new file mode 100644
index 0000000..95ebbac
--- /dev/null
+++ b/tests/t-breaks/pkg-c/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-c
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: lib-b (<< 1)
+Description: test package - breaking package
diff --git a/tests/t-buildinfo/Makefile b/tests/t-buildinfo/Makefile
new file mode 100644
index 0000000..019d850
--- /dev/null
+++ b/tests/t-buildinfo/Makefile
@@ -0,0 +1,11 @@
+OPTS = --admindir=$(CURDIR)/db-buildinfo
+
+test:
+ touch test-binary-a_1.0_amd64.deb
+ dpkg-source -b pkg-source
+ cd pkg-source && DEB_HOST_ARCH=amd64 dpkg-checkbuilddeps $(OPTS)
+ cd pkg-source && DEB_HOST_ARCH=amd64 dpkg-genbuildinfo $(OPTS)
+
+test-clean:
+ rm -f *.dsc *.deb *.buildinfo
+ rm -f *.tar.xz
diff --git a/tests/t-buildinfo/db-buildinfo/status b/tests/t-buildinfo/db-buildinfo/status
new file mode 100644
index 0000000..96c0e2a
--- /dev/null
+++ b/tests/t-buildinfo/db-buildinfo/status
@@ -0,0 +1,28 @@
+Package: pkg-depender
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Version: 1.0
+Depends: pkg-virtual
+Description: test package
+
+Package: pkg-provider
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Version: 2.0
+Provides: pkg-virtual
+Description: test package
+
+Package: build-essential
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Version: 10.0
+Description: fake package
diff --git a/tests/t-buildinfo/db-buildinfo/updates/.keep b/tests/t-buildinfo/db-buildinfo/updates/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-buildinfo/db-buildinfo/updates/.keep
diff --git a/tests/t-buildinfo/pkg-source/debian/changelog b/tests/t-buildinfo/pkg-source/debian/changelog
new file mode 100644
index 0000000..104fb70
--- /dev/null
+++ b/tests/t-buildinfo/pkg-source/debian/changelog
@@ -0,0 +1,5 @@
+test-source (1.0) UNRELEASED; urgency=medium
+
+ * Initial release.
+
+ -- Dpkg Developers <debian-dpkg@lists.debian.org> Fri, 09 Dec 2016 18:48:32 +0100
diff --git a/tests/t-buildinfo/pkg-source/debian/control b/tests/t-buildinfo/pkg-source/debian/control
new file mode 100644
index 0000000..e2ff1e1
--- /dev/null
+++ b/tests/t-buildinfo/pkg-source/debian/control
@@ -0,0 +1,13 @@
+Source: test-source
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Build-Depends:
+ pkg-depender:i386,
+ pkg-virtual:i386,
+Standards-Version: 3.9.8
+
+Package: pkg-binary-a
+Architecture: amd64
+Multi-Arch: foreign
+Description: test binary a
diff --git a/tests/t-buildinfo/pkg-source/debian/source/format b/tests/t-buildinfo/pkg-source/debian/source/format
new file mode 100644
index 0000000..89ae9db
--- /dev/null
+++ b/tests/t-buildinfo/pkg-source/debian/source/format
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/tests/t-conffile-conflict/Makefile b/tests/t-conffile-conflict/Makefile
new file mode 100644
index 0000000..c7af965
--- /dev/null
+++ b/tests/t-conffile-conflict/Makefile
@@ -0,0 +1,44 @@
+TESTS_DEB := pkg-conff-a pkg-conff-b pkg-conff-c
+
+include ../Test.mk
+
+TEST_CASES += test-conflict-installed-implicit
+TEST_CASES += test-conflict-removed-implicit
+TEST_CASES += test-conflict-removed-explicit
+
+test-case: $(TEST_CASES)
+
+test-conflict-installed-implicit:
+ # test if packages fail on install due to conflicting conffile
+ $(DPKG_INSTALL) pkg-conff-a.deb
+ ! $(DPKG_INSTALL) pkg-conff-b.deb
+ -$(DPKG_PURGE) pkg-conff-b
+ $(DPKG_PURGE) pkg-conff-a
+
+test-conflict-removed-implicit:
+ # test that conffile of removed package can be taken over
+ $(DPKG_INSTALL) pkg-conff-a.deb
+ $(DPKG_REMOVE) pkg-conff-a
+ $(DPKG_INSTALL) pkg-conff-b.deb
+ # Verify the new conffile has been installed
+ grep -q pkg-conff-b "$(DPKG_INSTDIR)/test-conffile"
+ # Verify it's kept after purge of old package
+ $(DPKG_PURGE) pkg-conff-a
+ test -e "$(DPKG_INSTDIR)/test-conffile"
+ $(DPKG_PURGE) pkg-conff-b
+
+test-conflict-removed-explicit:
+ # test that conffile of removed package can be taken over even if
+ # the new package is conflicting with the old one
+ $(DPKG_INSTALL) pkg-conff-a.deb
+ $(DPKG_REMOVE) pkg-conff-a
+ $(DPKG_INSTALL) pkg-conff-c.deb
+ # Verify the new conffile has been installed
+ grep -q pkg-conff-c "$(DPKG_INSTDIR)/test-conffile"
+ # Verify it's kept after purge of old package
+ $(DPKG_PURGE) pkg-conff-a
+ test -e "$(DPKG_INSTDIR)/test-conffile"
+ $(DPKG_PURGE) pkg-conff-c
+
+test-clean:
+ -$(DPKG_PURGE) pkg-conff-a pkg-conff-b pkg-conff-c
diff --git a/tests/t-conffile-conflict/pkg-conff-a/DEBIAN/conffiles b/tests/t-conffile-conflict/pkg-conff-a/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-conflict/pkg-conff-a/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-conflict/pkg-conff-a/DEBIAN/control b/tests/t-conffile-conflict/pkg-conff-a/DEBIAN/control
new file mode 100644
index 0000000..a346bae
--- /dev/null
+++ b/tests/t-conffile-conflict/pkg-conff-a/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conflicting conffile
+
diff --git a/tests/t-conffile-conflict/pkg-conff-a/test-conffile b/tests/t-conffile-conflict/pkg-conff-a/test-conffile
new file mode 100644
index 0000000..024da49
--- /dev/null
+++ b/tests/t-conffile-conflict/pkg-conff-a/test-conffile
@@ -0,0 +1 @@
+pkg-conff-a
diff --git a/tests/t-conffile-conflict/pkg-conff-b/DEBIAN/conffiles b/tests/t-conffile-conflict/pkg-conff-b/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-conflict/pkg-conff-b/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-conflict/pkg-conff-b/DEBIAN/control b/tests/t-conffile-conflict/pkg-conff-b/DEBIAN/control
new file mode 100644
index 0000000..e3f6951
--- /dev/null
+++ b/tests/t-conffile-conflict/pkg-conff-b/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conflicting conffile
+
diff --git a/tests/t-conffile-conflict/pkg-conff-b/test-conffile b/tests/t-conffile-conflict/pkg-conff-b/test-conffile
new file mode 100644
index 0000000..006fbc7
--- /dev/null
+++ b/tests/t-conffile-conflict/pkg-conff-b/test-conffile
@@ -0,0 +1 @@
+pkg-conff-b
diff --git a/tests/t-conffile-conflict/pkg-conff-c/DEBIAN/conffiles b/tests/t-conffile-conflict/pkg-conff-c/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-conflict/pkg-conff-c/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-conflict/pkg-conff-c/DEBIAN/control b/tests/t-conffile-conflict/pkg-conff-c/DEBIAN/control
new file mode 100644
index 0000000..a94ef2e
--- /dev/null
+++ b/tests/t-conffile-conflict/pkg-conff-c/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-c
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-conff-a
+Description: test package - conflicting conffile
+
diff --git a/tests/t-conffile-conflict/pkg-conff-c/test-conffile b/tests/t-conffile-conflict/pkg-conff-c/test-conffile
new file mode 100644
index 0000000..a6cfe38
--- /dev/null
+++ b/tests/t-conffile-conflict/pkg-conff-c/test-conffile
@@ -0,0 +1 @@
+pkg-conff-c
diff --git a/tests/t-conffile-declarative-removal/Makefile b/tests/t-conffile-declarative-removal/Makefile
new file mode 100644
index 0000000..0d0e77b
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/Makefile
@@ -0,0 +1,101 @@
+TESTS_DEB := pkg-conffile-v1 pkg-conffile-v2 \
+ pkg-conffile-owns-filename pkg-conffile-owns-symlink
+
+include ../Test.mk
+
+build-hook:
+ ln -sf test-conffile-owned \
+ pkg-conffile-owns-symlink/test-dir/test-conffile-to-be-removed
+
+clean-hook:
+ $(RM) pkg-conffile-owns-symlink/test-dir/test-conffile-to-be-removed
+ $(RM) pkg-conffile-removal-present.deb
+
+test-case:
+ # Conffile marked for removal but present, cannot be installed.
+ $(DPKG_BUILD_DEB) --nocheck pkg-conffile-removal-present
+ ! $(DPKG_INSTALL) pkg-conffile-removal-present.deb
+ $(call pkg_is_not_installed,pkg-conffile-removal-present)
+ $(DPKG_PURGE) pkg-conffile-removal-present
+
+ # Unmodified case, one invocation.
+ $(DPKG_INSTALL) pkg-conffile-v1.deb
+ test -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+ $(DPKG_INSTALL) pkg-conffile-v2.deb
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+
+ # Reset.
+ $(DPKG_PURGE) pkg-conffile
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+
+ # Unmodified case; but force it to happen via two invocations.
+ $(DPKG_INSTALL) pkg-conffile-v1.deb
+ test -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+ $(DPKG_UNPACK) pkg-conffile-v2.deb
+ # The old conffile is removed during unpack.
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+ # After configure, the file is still removed.
+ $(DPKG_CONFIGURE) pkg-conffile
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+
+ # Reset.
+ $(DPKG_PURGE) pkg-conffile
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+
+ # Modified; should store .dpkg-old.
+ $(DPKG_INSTALL) pkg-conffile-v1.deb
+ test -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ echo "modify this" >"$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ $(DPKG_INSTALL) pkg-conffile-v2.deb
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ test -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+
+ # Reset.
+ $(DPKG_PURGE) pkg-conffile
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ $(RM) "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+
+ # Queue a remove on upgrade, and move ownership.
+ $(DPKG_INSTALL) pkg-conffile-v1.deb
+ test -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ $(DPKG_INSTALL) pkg-conffile-v2.deb
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ $(DPKG_INSTALL) pkg-conffile-owns-filename.deb
+ test -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ # Upgrade the package again, should not remove unowned conffile.
+ $(DPKG_INSTALL) pkg-conffile-v2.deb
+ test -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+
+ # Reset.
+ $(DPKG_PURGE) pkg-conffile
+ $(DPKG_PURGE) pkg-conffile-owns
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+
+ # Queue a remove on upgrade, and move ownership via symlink.
+ $(DPKG_INSTALL) pkg-conffile-v1.deb
+ test -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ $(DPKG_INSTALL) pkg-conffile-v2.deb
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed.dpkg-old"
+ $(DPKG_INSTALL) pkg-conffile-owns-symlink.deb
+ test -f "$(DPKG_INSTDIR)/test-dir/test-conffile-owned"
+ test -L "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+ # Upgrade the package again, should not remove unowned conffile.
+ $(DPKG_INSTALL) pkg-conffile-v2.deb
+ test -f "$(DPKG_INSTDIR)/test-dir/test-conffile-owned"
+ test -L "$(DPKG_INSTDIR)/test-dir/test-conffile-to-be-removed"
+
+test-clean:
+ $(DPKG_PURGE) pkg-conffile-removal-present
+ $(DPKG_PURGE) pkg-conffile-owns
+ $(DPKG_PURGE) pkg-conffile
+ $(BEROOT) $(RM) -rf "$(DPKG_INSTDIR)/test-dir"
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/DEBIAN/conffiles b/tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/DEBIAN/conffiles
new file mode 100644
index 0000000..c4138c4
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-dir/test-conffile-to-be-removed
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/DEBIAN/control b/tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/DEBIAN/control
new file mode 100644
index 0000000..1f5b771
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conffile-owns
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - owns conffile to be removed
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/test-dir/test-conffile-to-be-removed b/tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/test-dir/test-conffile-to-be-removed
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-owns-filename/test-dir/test-conffile-to-be-removed
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/DEBIAN/conffiles b/tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/DEBIAN/conffiles
new file mode 100644
index 0000000..298a4dc
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-dir/test-conffile-owned
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/DEBIAN/control b/tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/DEBIAN/control
new file mode 100644
index 0000000..53862ca
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conffile-owns
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - owns conffile to be removed via symlink
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/test-dir/test-conffile-owned b/tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/test-dir/test-conffile-owned
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-owns-symlink/test-dir/test-conffile-owned
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-removal-present/DEBIAN/conffiles b/tests/t-conffile-declarative-removal/pkg-conffile-removal-present/DEBIAN/conffiles
new file mode 100644
index 0000000..587753b
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-removal-present/DEBIAN/conffiles
@@ -0,0 +1 @@
+remove-on-upgrade /test-dir/test-conffile-to-be-removed
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-removal-present/DEBIAN/control b/tests/t-conffile-declarative-removal/pkg-conffile-removal-present/DEBIAN/control
new file mode 100644
index 0000000..78d5ee4
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-removal-present/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conffile-removal-present
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile to be removed but present
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-removal-present/test-dir/test-conffile-to-be-removed b/tests/t-conffile-declarative-removal/pkg-conffile-removal-present/test-dir/test-conffile-to-be-removed
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-removal-present/test-dir/test-conffile-to-be-removed
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-v1/DEBIAN/conffiles b/tests/t-conffile-declarative-removal/pkg-conffile-v1/DEBIAN/conffiles
new file mode 100644
index 0000000..c4138c4
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-v1/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-dir/test-conffile-to-be-removed
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-v1/DEBIAN/control b/tests/t-conffile-declarative-removal/pkg-conffile-v1/DEBIAN/control
new file mode 100644
index 0000000..5626d2a
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-v1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conffile
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile to be removed v1
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-v1/test-dir/test-conffile-to-be-removed b/tests/t-conffile-declarative-removal/pkg-conffile-v1/test-dir/test-conffile-to-be-removed
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-v1/test-dir/test-conffile-to-be-removed
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-v2/DEBIAN/conffiles b/tests/t-conffile-declarative-removal/pkg-conffile-v2/DEBIAN/conffiles
new file mode 100644
index 0000000..587753b
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-v2/DEBIAN/conffiles
@@ -0,0 +1 @@
+remove-on-upgrade /test-dir/test-conffile-to-be-removed
diff --git a/tests/t-conffile-declarative-removal/pkg-conffile-v2/DEBIAN/control b/tests/t-conffile-declarative-removal/pkg-conffile-v2/DEBIAN/control
new file mode 100644
index 0000000..7057432
--- /dev/null
+++ b/tests/t-conffile-declarative-removal/pkg-conffile-v2/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conffile
+Version: 2
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile to be removed v2
diff --git a/tests/t-conffile-divert-conffile/Makefile b/tests/t-conffile-divert-conffile/Makefile
new file mode 100644
index 0000000..8cb88e4
--- /dev/null
+++ b/tests/t-conffile-divert-conffile/Makefile
@@ -0,0 +1,13 @@
+TESTS_DEB := pkg-conff pkg-conff-divert
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-conff.deb
+ # test if the other package can divert the conffile w/o prompt
+ $(DPKG_INSTALL) pkg-conff-divert.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-conff-divert
+ $(DPKG_PURGE) pkg-conff
+
diff --git a/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/conffiles b/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/control b/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/control
new file mode 100644
index 0000000..4e72fc0
--- /dev/null
+++ b/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-divert
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - divert a conffile
+
diff --git a/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/postrm b/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/postrm
new file mode 100755
index 0000000..adf47cb
--- /dev/null
+++ b/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/postrm
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "purge" ]; then
+ dpkg-divert --remove --rename /test-conffile
+fi
+
diff --git a/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/preinst b/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/preinst
new file mode 100755
index 0000000..bd85329
--- /dev/null
+++ b/tests/t-conffile-divert-conffile/pkg-conff-divert/DEBIAN/preinst
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "install" ] || [ "$1" = "upgrade" ]; then
+ dpkg-divert --package pkg-conff-divert --rename \
+ --divert /test-conffile.diverted --add /test-conffile
+fi
+
diff --git a/tests/t-conffile-divert-conffile/pkg-conff-divert/test-conffile b/tests/t-conffile-divert-conffile/pkg-conff-divert/test-conffile
new file mode 100644
index 0000000..94e47d3
--- /dev/null
+++ b/tests/t-conffile-divert-conffile/pkg-conff-divert/test-conffile
@@ -0,0 +1 @@
+test diverted
diff --git a/tests/t-conffile-divert-conffile/pkg-conff/DEBIAN/conffiles b/tests/t-conffile-divert-conffile/pkg-conff/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-divert-conffile/pkg-conff/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-divert-conffile/pkg-conff/DEBIAN/control b/tests/t-conffile-divert-conffile/pkg-conff/DEBIAN/control
new file mode 100644
index 0000000..8a3a6f5
--- /dev/null
+++ b/tests/t-conffile-divert-conffile/pkg-conff/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
+
diff --git a/tests/t-conffile-divert-conffile/pkg-conff/test-conffile b/tests/t-conffile-divert-conffile/pkg-conff/test-conffile
new file mode 100644
index 0000000..6fbc8b5
--- /dev/null
+++ b/tests/t-conffile-divert-conffile/pkg-conff/test-conffile
@@ -0,0 +1 @@
+test init
diff --git a/tests/t-conffile-divert-normal/Makefile b/tests/t-conffile-divert-normal/Makefile
new file mode 100644
index 0000000..8cb88e4
--- /dev/null
+++ b/tests/t-conffile-divert-normal/Makefile
@@ -0,0 +1,13 @@
+TESTS_DEB := pkg-conff pkg-conff-divert
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-conff.deb
+ # test if the other package can divert the conffile w/o prompt
+ $(DPKG_INSTALL) pkg-conff-divert.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-conff-divert
+ $(DPKG_PURGE) pkg-conff
+
diff --git a/tests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/control b/tests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/control
new file mode 100644
index 0000000..570b396
--- /dev/null
+++ b/tests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-divert
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - divert a conffile with a normal file
+
diff --git a/tests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/postrm b/tests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/postrm
new file mode 100755
index 0000000..adf47cb
--- /dev/null
+++ b/tests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/postrm
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "purge" ]; then
+ dpkg-divert --remove --rename /test-conffile
+fi
+
diff --git a/tests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/preinst b/tests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/preinst
new file mode 100755
index 0000000..bd85329
--- /dev/null
+++ b/tests/t-conffile-divert-normal/pkg-conff-divert/DEBIAN/preinst
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "install" ] || [ "$1" = "upgrade" ]; then
+ dpkg-divert --package pkg-conff-divert --rename \
+ --divert /test-conffile.diverted --add /test-conffile
+fi
+
diff --git a/tests/t-conffile-divert-normal/pkg-conff-divert/test-conffile b/tests/t-conffile-divert-normal/pkg-conff-divert/test-conffile
new file mode 100644
index 0000000..94e47d3
--- /dev/null
+++ b/tests/t-conffile-divert-normal/pkg-conff-divert/test-conffile
@@ -0,0 +1 @@
+test diverted
diff --git a/tests/t-conffile-divert-normal/pkg-conff/DEBIAN/conffiles b/tests/t-conffile-divert-normal/pkg-conff/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-divert-normal/pkg-conff/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-divert-normal/pkg-conff/DEBIAN/control b/tests/t-conffile-divert-normal/pkg-conff/DEBIAN/control
new file mode 100644
index 0000000..8a3a6f5
--- /dev/null
+++ b/tests/t-conffile-divert-normal/pkg-conff/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
+
diff --git a/tests/t-conffile-divert-normal/pkg-conff/test-conffile b/tests/t-conffile-divert-normal/pkg-conff/test-conffile
new file mode 100644
index 0000000..6fbc8b5
--- /dev/null
+++ b/tests/t-conffile-divert-normal/pkg-conff/test-conffile
@@ -0,0 +1 @@
+test init
diff --git a/tests/t-conffile-forceask/Makefile b/tests/t-conffile-forceask/Makefile
new file mode 100644
index 0000000..c40e2fe
--- /dev/null
+++ b/tests/t-conffile-forceask/Makefile
@@ -0,0 +1,16 @@
+TESTS_DEB := pkg-conff-forceask-0 pkg-conff-forceask-1
+
+include ../Test.mk
+
+test-case:
+
+ # Test that we get the new conffile after a modified one.
+ $(DPKG_INSTALL) pkg-conff-forceask-0.deb
+ $(BEROOT) cp mod-conffile "$(DPKG_INSTDIR)/test-conffile"
+ $(DPKG_INSTALL) --force-confask --force-confnew pkg-conff-forceask-1.deb
+ cmp mod-conffile "$(DPKG_INSTDIR)/test-conffile.dpkg-old"
+ cmp ref-conffile "$(DPKG_INSTDIR)/test-conffile"
+ $(DPKG_PURGE) pkg-conff-forceask
+
+test-clean:
+ $(DPKG_PURGE) pkg-conff-forceask
diff --git a/tests/t-conffile-forceask/mod-conffile b/tests/t-conffile-forceask/mod-conffile
new file mode 100644
index 0000000..73f8903
--- /dev/null
+++ b/tests/t-conffile-forceask/mod-conffile
@@ -0,0 +1 @@
+test modified
diff --git a/tests/t-conffile-forceask/pkg-conff-forceask-0/DEBIAN/conffiles b/tests/t-conffile-forceask/pkg-conff-forceask-0/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-forceask/pkg-conff-forceask-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-forceask/pkg-conff-forceask-0/DEBIAN/control b/tests/t-conffile-forceask/pkg-conff-forceask-0/DEBIAN/control
new file mode 100644
index 0000000..e817b0b
--- /dev/null
+++ b/tests/t-conffile-forceask/pkg-conff-forceask-0/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-forceask
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - force-confask behaviour
+ Debbug: ??
+
diff --git a/tests/t-conffile-forceask/pkg-conff-forceask-0/test-conffile b/tests/t-conffile-forceask/pkg-conff-forceask-0/test-conffile
new file mode 100644
index 0000000..ee5a694
--- /dev/null
+++ b/tests/t-conffile-forceask/pkg-conff-forceask-0/test-conffile
@@ -0,0 +1 @@
+test ref
diff --git a/tests/t-conffile-forceask/pkg-conff-forceask-1/DEBIAN/conffiles b/tests/t-conffile-forceask/pkg-conff-forceask-1/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-forceask/pkg-conff-forceask-1/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-forceask/pkg-conff-forceask-1/DEBIAN/control b/tests/t-conffile-forceask/pkg-conff-forceask-1/DEBIAN/control
new file mode 100644
index 0000000..be39ec8
--- /dev/null
+++ b/tests/t-conffile-forceask/pkg-conff-forceask-1/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-forceask
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - force-confask behaviour
+ Debbug: ??
+
diff --git a/tests/t-conffile-forceask/pkg-conff-forceask-1/test-conffile b/tests/t-conffile-forceask/pkg-conff-forceask-1/test-conffile
new file mode 100644
index 0000000..ee5a694
--- /dev/null
+++ b/tests/t-conffile-forceask/pkg-conff-forceask-1/test-conffile
@@ -0,0 +1 @@
+test ref
diff --git a/tests/t-conffile-forceask/ref-conffile b/tests/t-conffile-forceask/ref-conffile
new file mode 100644
index 0000000..ee5a694
--- /dev/null
+++ b/tests/t-conffile-forceask/ref-conffile
@@ -0,0 +1 @@
+test ref
diff --git a/tests/t-conffile-forcemiss/Makefile b/tests/t-conffile-forcemiss/Makefile
new file mode 100644
index 0000000..ab36890
--- /dev/null
+++ b/tests/t-conffile-forcemiss/Makefile
@@ -0,0 +1,16 @@
+TESTS_DEB := pkg-conff-forcemiss-0 pkg-conff-forcemiss-1
+
+include ../Test.mk
+
+test-case:
+ # Test if we get the new conffile after a missing one.
+ $(DPKG_INSTALL) pkg-conff-forcemiss-0.deb
+ $(BEROOT) rm "$(DPKG_INSTDIR)/test-conffile"
+ $(DPKG_INSTALL) pkg-conff-forcemiss-1.deb
+ ! test -f "$(DPKG_INSTDIR)/test-conffile"
+ $(DPKG_INSTALL) --force-confmiss pkg-conff-forcemiss-1.deb
+ cmp ref-conffile "$(DPKG_INSTDIR)/test-conffile"
+ $(DPKG_PURGE) pkg-conff-forcemiss
+
+test-clean:
+ $(DPKG_PURGE) pkg-conff-forcemiss
diff --git a/tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/DEBIAN/conffiles b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/DEBIAN/control b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/DEBIAN/control
new file mode 100644
index 0000000..becabd9
--- /dev/null
+++ b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conff-forcemiss
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - force-confmiss behaviour
diff --git a/tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/test-conffile b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/test-conffile
new file mode 100644
index 0000000..ee5a694
--- /dev/null
+++ b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-0/test-conffile
@@ -0,0 +1 @@
+test ref
diff --git a/tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/DEBIAN/conffiles b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/DEBIAN/control b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/DEBIAN/control
new file mode 100644
index 0000000..63e8ae3
--- /dev/null
+++ b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conff-forcemiss
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - force-confmiss behaviour
diff --git a/tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/test-conffile b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/test-conffile
new file mode 100644
index 0000000..ee5a694
--- /dev/null
+++ b/tests/t-conffile-forcemiss/pkg-conff-forcemiss-1/test-conffile
@@ -0,0 +1 @@
+test ref
diff --git a/tests/t-conffile-forcemiss/ref-conffile b/tests/t-conffile-forcemiss/ref-conffile
new file mode 100644
index 0000000..ee5a694
--- /dev/null
+++ b/tests/t-conffile-forcemiss/ref-conffile
@@ -0,0 +1 @@
+test ref
diff --git a/tests/t-conffile-forcenew/Makefile b/tests/t-conffile-forcenew/Makefile
new file mode 100644
index 0000000..c492c6c
--- /dev/null
+++ b/tests/t-conffile-forcenew/Makefile
@@ -0,0 +1,17 @@
+TESTS_DEB := pkg-conff-forcenew-0 pkg-conff-forcenew-1
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-conff-forcenew-0.deb
+ # Modify the conffile.
+ $(BEROOT) cp mod-conffile "$(DPKG_INSTDIR)/test-conffile"
+ # Test that we do not get the new conffile.
+ $(DPKG_INSTALL) pkg-conff-forcenew-0.deb
+ cmp mod-conffile "$(DPKG_INSTDIR)/test-conffile"
+ # Test that we get the new conffile.
+ $(DPKG_INSTALL) --force-confnew pkg-conff-forcenew-1.deb
+ cmp ref-conffile "$(DPKG_INSTDIR)/test-conffile"
+
+test-clean:
+ $(DPKG_PURGE) pkg-conff-forcenew
diff --git a/tests/t-conffile-forcenew/mod-conffile b/tests/t-conffile-forcenew/mod-conffile
new file mode 100644
index 0000000..73f8903
--- /dev/null
+++ b/tests/t-conffile-forcenew/mod-conffile
@@ -0,0 +1 @@
+test modified
diff --git a/tests/t-conffile-forcenew/pkg-conff-forcenew-0/DEBIAN/conffiles b/tests/t-conffile-forcenew/pkg-conff-forcenew-0/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-forcenew/pkg-conff-forcenew-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-forcenew/pkg-conff-forcenew-0/DEBIAN/control b/tests/t-conffile-forcenew/pkg-conff-forcenew-0/DEBIAN/control
new file mode 100644
index 0000000..02d528e
--- /dev/null
+++ b/tests/t-conffile-forcenew/pkg-conff-forcenew-0/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-forcenew
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - force-confnew behaviour
+ Debbug: 391818
+
diff --git a/tests/t-conffile-forcenew/pkg-conff-forcenew-0/test-conffile b/tests/t-conffile-forcenew/pkg-conff-forcenew-0/test-conffile
new file mode 100644
index 0000000..6fbc8b5
--- /dev/null
+++ b/tests/t-conffile-forcenew/pkg-conff-forcenew-0/test-conffile
@@ -0,0 +1 @@
+test init
diff --git a/tests/t-conffile-forcenew/pkg-conff-forcenew-1/DEBIAN/conffiles b/tests/t-conffile-forcenew/pkg-conff-forcenew-1/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-forcenew/pkg-conff-forcenew-1/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-forcenew/pkg-conff-forcenew-1/DEBIAN/control b/tests/t-conffile-forcenew/pkg-conff-forcenew-1/DEBIAN/control
new file mode 100644
index 0000000..fcc03d9
--- /dev/null
+++ b/tests/t-conffile-forcenew/pkg-conff-forcenew-1/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-forcenew
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - force-confnew behaviour
+ Debbug: 391818
+
diff --git a/tests/t-conffile-forcenew/pkg-conff-forcenew-1/test-conffile b/tests/t-conffile-forcenew/pkg-conff-forcenew-1/test-conffile
new file mode 100644
index 0000000..35f4da8
--- /dev/null
+++ b/tests/t-conffile-forcenew/pkg-conff-forcenew-1/test-conffile
@@ -0,0 +1 @@
+test end
diff --git a/tests/t-conffile-forcenew/ref-conffile b/tests/t-conffile-forcenew/ref-conffile
new file mode 100644
index 0000000..35f4da8
--- /dev/null
+++ b/tests/t-conffile-forcenew/ref-conffile
@@ -0,0 +1 @@
+test end
diff --git a/tests/t-conffile-normal/Makefile b/tests/t-conffile-normal/Makefile
new file mode 100644
index 0000000..52f29c7
--- /dev/null
+++ b/tests/t-conffile-normal/Makefile
@@ -0,0 +1,15 @@
+TESTS_DEB := pkg-conffile
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-conffile.deb
+ test -f "$(DPKG_INSTDIR)/test-dir/test-conffile"
+ $(DPKG_REMOVE) pkg-conffile
+ $(DPKG_PURGE) pkg-conffile
+ test ! -f "$(DPKG_INSTDIR)/test-dir/test-conffile"
+ test ! -d "$(DPKG_INSTDIR)/test-dir"
+
+test-clean:
+ $(DPKG_PURGE) pkg-conffile
+ $(BEROOT) $(RM) -rf "$(DPKG_INSTDIR)/test-dir"
diff --git a/tests/t-conffile-normal/pkg-conffile/DEBIAN/conffiles b/tests/t-conffile-normal/pkg-conffile/DEBIAN/conffiles
new file mode 100644
index 0000000..6d57c35
--- /dev/null
+++ b/tests/t-conffile-normal/pkg-conffile/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-dir/test-conffile
diff --git a/tests/t-conffile-normal/pkg-conffile/DEBIAN/control b/tests/t-conffile-normal/pkg-conffile/DEBIAN/control
new file mode 100644
index 0000000..6dcdeb8
--- /dev/null
+++ b/tests/t-conffile-normal/pkg-conffile/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conffile
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile inside directory
diff --git a/tests/t-conffile-normal/pkg-conffile/test-dir/test-conffile b/tests/t-conffile-normal/pkg-conffile/test-dir/test-conffile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-normal/pkg-conffile/test-dir/test-conffile
diff --git a/tests/t-conffile-obsolete/Makefile b/tests/t-conffile-obsolete/Makefile
new file mode 100644
index 0000000..55d9477
--- /dev/null
+++ b/tests/t-conffile-obsolete/Makefile
@@ -0,0 +1,42 @@
+TESTS_DEB := pkg-conff-obsolete-0 pkg-conff-obsolete-1 pkg-conff-obsolete-2
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-conff-obsolete-0.deb
+ $(DPKG_INSTALL) pkg-conff-obsolete-1.deb
+ test -f '$(DPKG_INSTDIR)/test-conffile'
+ $(DPKG_PURGE) pkg-conff-obsolete
+ test ! -f '$(DPKG_INSTDIR)/test-conffile'
+ # Unmodified conffile is autoremoved for the user
+ $(DPKG_INSTALL) pkg-conff-obsolete-0.deb
+ $(DPKG_UNPACK) pkg-conff-obsolete-2.deb
+ test -f '$(DPKG_INSTDIR)/test-conffile.dpkg-remove'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile.dpkg-backup'
+ $(DPKG_CONFIGURE) pkg-conff-obsolete
+ test ! -f '$(DPKG_INSTDIR)/test-conffile'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile.dpkg-bak'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile.dpkg-backup'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile.dpkg-remove'
+ $(DPKG_PURGE) pkg-conff-obsolete
+ # Modified conffile is moved away in .dpkg-bak for the user
+ $(DPKG_INSTALL) pkg-conff-obsolete-0.deb
+ $(BEROOT) sh -c "echo foo >>'$(DPKG_INSTDIR)/test-conffile'"
+ $(DPKG_INSTALL) pkg-conff-obsolete-2.deb
+ test ! -f '$(DPKG_INSTDIR)/test-conffile'
+ test -f '$(DPKG_INSTDIR)/test-conffile.dpkg-bak'
+ $(DPKG_PURGE) pkg-conff-obsolete
+ test ! -f '$(DPKG_INSTDIR)/test-conffile.dpkg-bak'
+ # Abort-upgrade restores the to-be-removed conffile
+ $(DPKG_INSTALL) pkg-conff-obsolete-0.deb
+ $(BEROOT) touch '$(DPKG_INSTDIR)/fail-preinst'
+ $(DPKG_INSTALL) pkg-conff-obsolete-2.deb || true
+ $(BEROOT) rm -f '$(DPKG_INSTDIR)/fail-preinst'
+ test -f '$(DPKG_INSTDIR)/test-conffile'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile.dpkg-remove'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile.dpkg-bak'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile.dpkg-backup'
+
+test-clean:
+ $(DPKG_PURGE) pkg-conff-obsolete
+
diff --git a/tests/t-conffile-obsolete/pkg-conff-obsolete-0/DEBIAN/conffiles b/tests/t-conffile-obsolete/pkg-conff-obsolete-0/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-obsolete/pkg-conff-obsolete-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-obsolete/pkg-conff-obsolete-0/DEBIAN/control b/tests/t-conffile-obsolete/pkg-conff-obsolete-0/DEBIAN/control
new file mode 100644
index 0000000..664592c
--- /dev/null
+++ b/tests/t-conffile-obsolete/pkg-conff-obsolete-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-obsolete
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile obsolete
+
diff --git a/tests/t-conffile-obsolete/pkg-conff-obsolete-0/test-conffile b/tests/t-conffile-obsolete/pkg-conff-obsolete-0/test-conffile
new file mode 100644
index 0000000..6fbc8b5
--- /dev/null
+++ b/tests/t-conffile-obsolete/pkg-conff-obsolete-0/test-conffile
@@ -0,0 +1 @@
+test init
diff --git a/tests/t-conffile-obsolete/pkg-conff-obsolete-1/DEBIAN/control b/tests/t-conffile-obsolete/pkg-conff-obsolete-1/DEBIAN/control
new file mode 100644
index 0000000..b7e111e
--- /dev/null
+++ b/tests/t-conffile-obsolete/pkg-conff-obsolete-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-obsolete
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile obsolete
+
diff --git a/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/control b/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/control
new file mode 100644
index 0000000..b7e111e
--- /dev/null
+++ b/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-obsolete
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile obsolete
+
diff --git a/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/postinst b/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/postinst
new file mode 100755
index 0000000..c6b0782
--- /dev/null
+++ b/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/postinst
@@ -0,0 +1,4 @@
+#!/bin/sh
+if dpkg-maintscript-helper supports rm_conffile; then
+ dpkg-maintscript-helper rm_conffile /test-conffile 0 -- "$@"
+fi
diff --git a/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/postrm b/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/postrm
new file mode 100755
index 0000000..c6b0782
--- /dev/null
+++ b/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/postrm
@@ -0,0 +1,4 @@
+#!/bin/sh
+if dpkg-maintscript-helper supports rm_conffile; then
+ dpkg-maintscript-helper rm_conffile /test-conffile 0 -- "$@"
+fi
diff --git a/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/preinst b/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/preinst
new file mode 100755
index 0000000..c0e592b
--- /dev/null
+++ b/tests/t-conffile-obsolete/pkg-conff-obsolete-2/DEBIAN/preinst
@@ -0,0 +1,9 @@
+#!/bin/sh
+if dpkg-maintscript-helper supports rm_conffile; then
+ dpkg-maintscript-helper rm_conffile /test-conffile 0 -- "$@"
+fi
+
+if [ -e "$DPKG_ROOT/fail-preinst" ]; then
+ exit 1
+fi
+
diff --git a/tests/t-conffile-orphan/Makefile b/tests/t-conffile-orphan/Makefile
new file mode 100644
index 0000000..1f51ccb
--- /dev/null
+++ b/tests/t-conffile-orphan/Makefile
@@ -0,0 +1,14 @@
+TESTS_DEB := pkg-conff-orphan-0 pkg-conff-orphan-1 pkg-conff-takeover
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-conff-orphan-0.deb
+ $(DPKG_INSTALL) pkg-conff-orphan-1.deb
+ # test if the other package can takeover the orphan conffile
+ $(DPKG_INSTALL) pkg-conff-takeover.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-conff-orphan
+ $(DPKG_PURGE) pkg-conff-takeover
+
diff --git a/tests/t-conffile-orphan/pkg-conff-orphan-0/DEBIAN/conffiles b/tests/t-conffile-orphan/pkg-conff-orphan-0/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-orphan/pkg-conff-orphan-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-orphan/pkg-conff-orphan-0/DEBIAN/control b/tests/t-conffile-orphan/pkg-conff-orphan-0/DEBIAN/control
new file mode 100644
index 0000000..e147450
--- /dev/null
+++ b/tests/t-conffile-orphan/pkg-conff-orphan-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-orphan
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile oprhan
+
diff --git a/tests/t-conffile-orphan/pkg-conff-orphan-0/test-conffile b/tests/t-conffile-orphan/pkg-conff-orphan-0/test-conffile
new file mode 100644
index 0000000..6fbc8b5
--- /dev/null
+++ b/tests/t-conffile-orphan/pkg-conff-orphan-0/test-conffile
@@ -0,0 +1 @@
+test init
diff --git a/tests/t-conffile-orphan/pkg-conff-orphan-1/DEBIAN/control b/tests/t-conffile-orphan/pkg-conff-orphan-1/DEBIAN/control
new file mode 100644
index 0000000..691051b
--- /dev/null
+++ b/tests/t-conffile-orphan/pkg-conff-orphan-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-orphan
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile orphan
+
diff --git a/tests/t-conffile-orphan/pkg-conff-takeover/DEBIAN/conffiles b/tests/t-conffile-orphan/pkg-conff-takeover/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-orphan/pkg-conff-takeover/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-orphan/pkg-conff-takeover/DEBIAN/control b/tests/t-conffile-orphan/pkg-conff-takeover/DEBIAN/control
new file mode 100644
index 0000000..d5dd7f1
--- /dev/null
+++ b/tests/t-conffile-orphan/pkg-conff-takeover/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-takeover
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile oprhan takeover
+
diff --git a/tests/t-conffile-orphan/pkg-conff-takeover/test-conffile b/tests/t-conffile-orphan/pkg-conff-takeover/test-conffile
new file mode 100644
index 0000000..35f4da8
--- /dev/null
+++ b/tests/t-conffile-orphan/pkg-conff-takeover/test-conffile
@@ -0,0 +1 @@
+test end
diff --git a/tests/t-conffile-prompt/Makefile b/tests/t-conffile-prompt/Makefile
new file mode 100644
index 0000000..1f413bb
--- /dev/null
+++ b/tests/t-conffile-prompt/Makefile
@@ -0,0 +1,20 @@
+TESTS_DEB := pkg-conff-prompt-0 pkg-conff-prompt-1
+
+include ../Test.mk
+
+build-hook:
+ touch "pkg-conff-prompt-0/test-conffile with spaces"
+ touch "pkg-conff-prompt-1/test-conffile with spaces"
+
+clean-hook:
+ $(RM) "pkg-conff-prompt-0/test-conffile with spaces"
+ $(RM) "pkg-conff-prompt-1/test-conffile with spaces"
+
+test-case:
+ $(DPKG_INSTALL) pkg-conff-prompt-0.deb
+ # test if package prompts on install
+ $(DPKG_INSTALL) pkg-conff-prompt-1.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-conff-prompt
+
diff --git a/tests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/conffiles b/tests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/conffiles
new file mode 100644
index 0000000..ef41b42
--- /dev/null
+++ b/tests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/conffiles
@@ -0,0 +1,2 @@
+/test-conffile
+/test-conffile with spaces
diff --git a/tests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/control b/tests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/control
new file mode 100644
index 0000000..3aeb1b2
--- /dev/null
+++ b/tests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-prompt
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile prompt
+
diff --git a/tests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/postinst b/tests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/postinst
new file mode 100755
index 0000000..27be638
--- /dev/null
+++ b/tests/t-conffile-prompt/pkg-conff-prompt-0/DEBIAN/postinst
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "test modified" >"$DPKG_ROOT/test-conffile"
+echo "test modified spaces" >"$DPKG_ROOT/test-conffile with spaces"
diff --git a/tests/t-conffile-prompt/pkg-conff-prompt-0/test-conffile b/tests/t-conffile-prompt/pkg-conff-prompt-0/test-conffile
new file mode 100644
index 0000000..6fbc8b5
--- /dev/null
+++ b/tests/t-conffile-prompt/pkg-conff-prompt-0/test-conffile
@@ -0,0 +1 @@
+test init
diff --git a/tests/t-conffile-prompt/pkg-conff-prompt-1/DEBIAN/conffiles b/tests/t-conffile-prompt/pkg-conff-prompt-1/DEBIAN/conffiles
new file mode 100644
index 0000000..ef41b42
--- /dev/null
+++ b/tests/t-conffile-prompt/pkg-conff-prompt-1/DEBIAN/conffiles
@@ -0,0 +1,2 @@
+/test-conffile
+/test-conffile with spaces
diff --git a/tests/t-conffile-prompt/pkg-conff-prompt-1/DEBIAN/control b/tests/t-conffile-prompt/pkg-conff-prompt-1/DEBIAN/control
new file mode 100644
index 0000000..8bd3f1e
--- /dev/null
+++ b/tests/t-conffile-prompt/pkg-conff-prompt-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-prompt
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile prompt
+
diff --git a/tests/t-conffile-prompt/pkg-conff-prompt-1/test-conffile b/tests/t-conffile-prompt/pkg-conff-prompt-1/test-conffile
new file mode 100644
index 0000000..35f4da8
--- /dev/null
+++ b/tests/t-conffile-prompt/pkg-conff-prompt-1/test-conffile
@@ -0,0 +1 @@
+test end
diff --git a/tests/t-conffile-rename/Makefile b/tests/t-conffile-rename/Makefile
new file mode 100644
index 0000000..a8d0272
--- /dev/null
+++ b/tests/t-conffile-rename/Makefile
@@ -0,0 +1,34 @@
+TESTS_DEB := pkg-conff-rename-0 pkg-conff-rename-1
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-conff-rename-0.deb
+ $(DPKG_INSTALL) pkg-conff-rename-1.deb
+ test -f '$(DPKG_INSTDIR)/test-conffile-new'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile-old'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile-old.dpkg-remove'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile-old.dpkg-bak'
+ $(DPKG_PURGE) pkg-conff-rename
+ # Same upgrade but with modified conffile, should still not prompt
+ $(DPKG_INSTALL) pkg-conff-rename-0.deb
+ $(BEROOT) sh -c "echo foo >>'$(DPKG_INSTDIR)/test-conffile-old'"
+ $(DPKG_INSTALL) pkg-conff-rename-1.deb
+ test -f '$(DPKG_INSTDIR)/test-conffile-new'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile-old'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile-old.dpkg-remove'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile-old.dpkg-bak'
+ $(DPKG_PURGE) pkg-conff-rename
+ # Abort-upgrade restores the to-be-renamed conffile
+ $(DPKG_INSTALL) pkg-conff-rename-0.deb
+ $(BEROOT) touch '$(DPKG_INSTDIR)/fail-preinst'
+ $(DPKG_INSTALL) pkg-conff-rename-1.deb || true
+ $(BEROOT) rm -f '$(DPKG_INSTDIR)/fail-preinst'
+ test -f '$(DPKG_INSTDIR)/test-conffile-old'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile-new'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile-old.dpkg-remove'
+ test ! -f '$(DPKG_INSTDIR)/test-conffile-old.dpkg-bak'
+ $(DPKG_PURGE) pkg-conff-rename
+
+test-clean:
+
diff --git a/tests/t-conffile-rename/pkg-conff-rename-0/DEBIAN/conffiles b/tests/t-conffile-rename/pkg-conff-rename-0/DEBIAN/conffiles
new file mode 100644
index 0000000..3ba6940
--- /dev/null
+++ b/tests/t-conffile-rename/pkg-conff-rename-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile-old
diff --git a/tests/t-conffile-rename/pkg-conff-rename-0/DEBIAN/control b/tests/t-conffile-rename/pkg-conff-rename-0/DEBIAN/control
new file mode 100644
index 0000000..b38b9b7
--- /dev/null
+++ b/tests/t-conffile-rename/pkg-conff-rename-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-rename
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile rename
+
diff --git a/tests/t-conffile-rename/pkg-conff-rename-0/test-conffile-old b/tests/t-conffile-rename/pkg-conff-rename-0/test-conffile-old
new file mode 100644
index 0000000..6fbc8b5
--- /dev/null
+++ b/tests/t-conffile-rename/pkg-conff-rename-0/test-conffile-old
@@ -0,0 +1 @@
+test init
diff --git a/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/conffiles b/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/conffiles
new file mode 100644
index 0000000..e3d713a
--- /dev/null
+++ b/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile-new
diff --git a/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/control b/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/control
new file mode 100644
index 0000000..ffd083c
--- /dev/null
+++ b/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-rename
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conffile rename
+
diff --git a/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/postinst b/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/postinst
new file mode 100755
index 0000000..89c1f0b
--- /dev/null
+++ b/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/postinst
@@ -0,0 +1,4 @@
+#!/bin/sh
+if dpkg-maintscript-helper supports mv_conffile; then
+ dpkg-maintscript-helper mv_conffile /test-conffile-old /test-conffile-new 0 -- "$@"
+fi
diff --git a/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/postrm b/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/postrm
new file mode 100755
index 0000000..89c1f0b
--- /dev/null
+++ b/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/postrm
@@ -0,0 +1,4 @@
+#!/bin/sh
+if dpkg-maintscript-helper supports mv_conffile; then
+ dpkg-maintscript-helper mv_conffile /test-conffile-old /test-conffile-new 0 -- "$@"
+fi
diff --git a/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/preinst b/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/preinst
new file mode 100755
index 0000000..775093f
--- /dev/null
+++ b/tests/t-conffile-rename/pkg-conff-rename-1/DEBIAN/preinst
@@ -0,0 +1,9 @@
+#!/bin/sh
+if dpkg-maintscript-helper supports mv_conffile; then
+ dpkg-maintscript-helper mv_conffile /test-conffile-old /test-conffile-new 0 -- "$@"
+fi
+
+if [ -e "$DPKG_ROOT/fail-preinst" ]; then
+ exit 1
+fi
+
diff --git a/tests/t-conffile-rename/pkg-conff-rename-1/test-conffile-new b/tests/t-conffile-rename/pkg-conff-rename-1/test-conffile-new
new file mode 100644
index 0000000..39c0014
--- /dev/null
+++ b/tests/t-conffile-rename/pkg-conff-rename-1/test-conffile-new
@@ -0,0 +1 @@
+this is the new conffile
diff --git a/tests/t-conffile-replaces-disappear/Makefile b/tests/t-conffile-replaces-disappear/Makefile
new file mode 100644
index 0000000..f5bc087
--- /dev/null
+++ b/tests/t-conffile-replaces-disappear/Makefile
@@ -0,0 +1,51 @@
+TESTS_DEB := pkg-conff-original pkg-conff-takeover
+
+include ../Test.mk
+
+TEST_CASES += test-two-run-ordered
+TEST_CASES += test-one-run-ordered
+TEST_CASES += test-two-run-reverse
+TEST_CASES += test-one-run-reverse
+
+test-case: $(TEST_CASES)
+
+define VERIFY
+$(call pkg_is_installed,pkg-conff-takeover)
+test "`$(DPKG_QUERY) -S /test-conffile`" = "pkg-conff-takeover: /test-conffile"
+cmp ref-conffile "$(DPKG_INSTDIR)/test-conffile"
+endef
+
+test-two-run-ordered:
+ # test-two-run-ordered
+ $(DPKG_INSTALL) pkg-conff-original.deb
+ $(DPKG_INSTALL) pkg-conff-takeover.deb
+ $(call pkg_is_not_installed,pkg-conff-original)
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+ test ! -f "$(DPKG_INSTDIR)/test-conffile"
+
+test-one-run-ordered:
+ # test-one-run-ordered
+ $(DPKG_INSTALL) pkg-conff-original.deb pkg-conff-takeover.deb
+ $(call pkg_is_not_installed,pkg-conff-original)
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+ test ! -f "$(DPKG_INSTDIR)/test-conffile"
+
+test-two-run-reverse:
+ # test-two-run-reverse
+ $(DPKG_INSTALL) pkg-conff-takeover.deb
+ $(DPKG_INSTALL) pkg-conff-original.deb
+ $(call pkg_is_installed,pkg-conff-original)
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+ test ! -f "$(DPKG_INSTDIR)/test-conffile"
+
+test-one-run-reverse:
+ # test-one-run-reverse
+ $(DPKG_INSTALL) pkg-conff-takeover.deb pkg-conff-original.deb
+ $(call pkg_is_installed,pkg-conff-original)
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+ test ! -f "$(DPKG_INSTDIR)/test-conffile"
+
diff --git a/tests/t-conffile-replaces-disappear/pkg-conff-original/DEBIAN/conffiles b/tests/t-conffile-replaces-disappear/pkg-conff-original/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces-disappear/pkg-conff-original/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces-disappear/pkg-conff-original/DEBIAN/control b/tests/t-conffile-replaces-disappear/pkg-conff-original/DEBIAN/control
new file mode 100644
index 0000000..523e417
--- /dev/null
+++ b/tests/t-conffile-replaces-disappear/pkg-conff-original/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-original
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
+
diff --git a/tests/t-conffile-replaces-disappear/pkg-conff-original/test-conffile b/tests/t-conffile-replaces-disappear/pkg-conff-original/test-conffile
new file mode 100644
index 0000000..7e3c47b
--- /dev/null
+++ b/tests/t-conffile-replaces-disappear/pkg-conff-original/test-conffile
@@ -0,0 +1 @@
+test original
diff --git a/tests/t-conffile-replaces-disappear/pkg-conff-takeover/DEBIAN/conffiles b/tests/t-conffile-replaces-disappear/pkg-conff-takeover/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces-disappear/pkg-conff-takeover/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces-disappear/pkg-conff-takeover/DEBIAN/control b/tests/t-conffile-replaces-disappear/pkg-conff-takeover/DEBIAN/control
new file mode 100644
index 0000000..1f1e038
--- /dev/null
+++ b/tests/t-conffile-replaces-disappear/pkg-conff-takeover/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-takeover
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-conff-original
+Description: test package - conffile replaces takeover
+
diff --git a/tests/t-conffile-replaces-disappear/pkg-conff-takeover/test-conffile b/tests/t-conffile-replaces-disappear/pkg-conff-takeover/test-conffile
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-conffile-replaces-disappear/pkg-conff-takeover/test-conffile
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-conffile-replaces-disappear/ref-conffile b/tests/t-conffile-replaces-disappear/ref-conffile
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-conffile-replaces-disappear/ref-conffile
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-conffile-replaces-diverted/Makefile b/tests/t-conffile-replaces-diverted/Makefile
new file mode 100644
index 0000000..5e9b176
--- /dev/null
+++ b/tests/t-conffile-replaces-diverted/Makefile
@@ -0,0 +1,18 @@
+TESTS_DEB := pkg-conff-0 pkg-conff-1 pkg-conff-move
+
+include ../Test.mk
+
+DPKG_DIVERT_OPTIONS += --local --rename --divert /test/conffile.moved
+
+test-case:
+ $(DPKG_INSTALL) pkg-conff-0.deb
+ $(DPKG_DIVERT_ADD) /test/conffile
+ test -f '$(DPKG_INSTDIR)/test/conffile.moved'
+ # Test if the other package can takeover a diverted conffile w/o error.
+ $(DPKG_INSTALL) pkg-conff-1.deb
+ $(DPKG_INSTALL) pkg-conff-move.deb
+
+test-clean:
+ $(DPKG_DIVERT_DEL) /test/conffile
+ $(DPKG_PURGE) pkg-conff
+ $(DPKG_PURGE) pkg-conff-move
diff --git a/tests/t-conffile-replaces-diverted/pkg-conff-0/DEBIAN/conffiles b/tests/t-conffile-replaces-diverted/pkg-conff-0/DEBIAN/conffiles
new file mode 100644
index 0000000..e2b8681
--- /dev/null
+++ b/tests/t-conffile-replaces-diverted/pkg-conff-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test/conffile
diff --git a/tests/t-conffile-replaces-diverted/pkg-conff-0/DEBIAN/control b/tests/t-conffile-replaces-diverted/pkg-conff-0/DEBIAN/control
new file mode 100644
index 0000000..13bd5aa
--- /dev/null
+++ b/tests/t-conffile-replaces-diverted/pkg-conff-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conff
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
diff --git a/tests/t-conffile-replaces-diverted/pkg-conff-0/test/conffile b/tests/t-conffile-replaces-diverted/pkg-conff-0/test/conffile
new file mode 100644
index 0000000..08db759
--- /dev/null
+++ b/tests/t-conffile-replaces-diverted/pkg-conff-0/test/conffile
@@ -0,0 +1 @@
+This is a conffile.
diff --git a/tests/t-conffile-replaces-diverted/pkg-conff-1/DEBIAN/control b/tests/t-conffile-replaces-diverted/pkg-conff-1/DEBIAN/control
new file mode 100644
index 0000000..bd499f5
--- /dev/null
+++ b/tests/t-conffile-replaces-diverted/pkg-conff-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conff
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provided a conffile, not anymore
diff --git a/tests/t-conffile-replaces-diverted/pkg-conff-move/DEBIAN/conffiles b/tests/t-conffile-replaces-diverted/pkg-conff-move/DEBIAN/conffiles
new file mode 100644
index 0000000..e2b8681
--- /dev/null
+++ b/tests/t-conffile-replaces-diverted/pkg-conff-move/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test/conffile
diff --git a/tests/t-conffile-replaces-diverted/pkg-conff-move/DEBIAN/control b/tests/t-conffile-replaces-diverted/pkg-conff-move/DEBIAN/control
new file mode 100644
index 0000000..bcbdffa
--- /dev/null
+++ b/tests/t-conffile-replaces-diverted/pkg-conff-move/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-move
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-conff (<< 1)
+Description: test package - takeover a conffile
diff --git a/tests/t-conffile-replaces-diverted/pkg-conff-move/test/conffile b/tests/t-conffile-replaces-diverted/pkg-conff-move/test/conffile
new file mode 100644
index 0000000..08db759
--- /dev/null
+++ b/tests/t-conffile-replaces-diverted/pkg-conff-move/test/conffile
@@ -0,0 +1 @@
+This is a conffile.
diff --git a/tests/t-conffile-replaces-downgrade/Makefile b/tests/t-conffile-replaces-downgrade/Makefile
new file mode 100644
index 0000000..df08bd6
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/Makefile
@@ -0,0 +1,20 @@
+TESTS_DEB := pkg-conff-original-0 pkg-conff-original-1 pkg-conff-takeover
+
+include ../Test.mk
+
+define VERIFY
+$(call pkg_is_installed,pkg-conff-original)
+$(call pkg_is_installed,pkg-conff-takeover)
+test "`$(DPKG_QUERY) -S /test-conffile`" = "pkg-conff-takeover: /test-conffile"
+cmp ref-conffile "$(DPKG_INSTDIR)/test-conffile"
+endef
+
+test-case:
+ # Install packages
+ $(DPKG_INSTALL) pkg-conff-original-1.deb
+ $(DPKG_INSTALL) pkg-conff-takeover.deb
+ # Downgrade to test versioned Replaces
+ $(DPKG_INSTALL) pkg-conff-original-0.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
diff --git a/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/DEBIAN/conffiles b/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/DEBIAN/control b/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/DEBIAN/control
new file mode 100644
index 0000000..523e417
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-original
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
+
diff --git a/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/test-conffile b/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/test-conffile
new file mode 100644
index 0000000..995e78d
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/test-conffile
@@ -0,0 +1 @@
+test original 0
diff --git a/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/test-original b/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/pkg-conff-original-0/test-original
diff --git a/tests/t-conffile-replaces-downgrade/pkg-conff-original-1/DEBIAN/control b/tests/t-conffile-replaces-downgrade/pkg-conff-original-1/DEBIAN/control
new file mode 100644
index 0000000..6cb5a69
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/pkg-conff-original-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-original
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - stop provinding a conffile
+
diff --git a/tests/t-conffile-replaces-downgrade/pkg-conff-original-1/test-original b/tests/t-conffile-replaces-downgrade/pkg-conff-original-1/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/pkg-conff-original-1/test-original
diff --git a/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/DEBIAN/conffiles b/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/DEBIAN/control b/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/DEBIAN/control
new file mode 100644
index 0000000..f323304
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-takeover
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-conff-original
+Description: test package - conffile replaces takeover
+
diff --git a/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/test-conffile b/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/test-conffile
new file mode 100644
index 0000000..1bc4643
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/test-conffile
@@ -0,0 +1 @@
+test takeover 1
diff --git a/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/test-takeover b/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/pkg-conff-takeover/test-takeover
diff --git a/tests/t-conffile-replaces-downgrade/ref-conffile b/tests/t-conffile-replaces-downgrade/ref-conffile
new file mode 100644
index 0000000..1bc4643
--- /dev/null
+++ b/tests/t-conffile-replaces-downgrade/ref-conffile
@@ -0,0 +1 @@
+test takeover 1
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/Makefile b/tests/t-conffile-replaces-existing-and-upgrade/Makefile
new file mode 100644
index 0000000..18ff9dd
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/Makefile
@@ -0,0 +1,61 @@
+TESTS_DEB := pkg-conff-original-0 pkg-conff-original-1 \
+ pkg-conff-takeover-0 pkg-conff-takeover-1
+
+include ../Test.mk
+
+TEST_CASES += test-two-run-ordered
+TEST_CASES += test-one-run-ordered
+TEST_CASES += test-two-run-reverse
+TEST_CASES += test-one-run-reverse
+
+test-case: $(TEST_CASES)
+
+define CONFFILES
+$(DPKG_QUERY) -f '$${Package} @ $${Conffiles}\n'
+endef
+
+define VERIFY
+$(call pkg_is_installed,pkg-conff-original)
+$(call pkg_is_installed,pkg-conff-takeover)
+test "`$(DPKG_QUERY) -S /test-conffile`" = "pkg-conff-takeover: /test-conffile"
+test "`$(CONFFILES) -W pkg-conff-original | grep obsolete | wc -l`" = "1"
+test "`$(CONFFILES) -W pkg-conff-takeover | grep -v obsolete | wc -l`" = "1"
+cmp ref-conffile "$(DPKG_INSTDIR)/test-conffile"
+endef
+
+test-two-run-ordered:
+ # test-two-run-ordered
+ $(DPKG_INSTALL) pkg-conff-original-0.deb
+ $(DPKG_INSTALL) pkg-conff-original-1.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-0.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-one-run-ordered:
+ # test-one-run-ordered
+ $(DPKG_INSTALL) pkg-conff-original-0.deb
+ $(DPKG_INSTALL) pkg-conff-original-1.deb pkg-conff-takeover-0.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-two-run-reverse:
+ # test-two-run-reverse
+ $(DPKG_INSTALL) pkg-conff-original-0.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-0.deb
+ $(DPKG_INSTALL) pkg-conff-original-1.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-one-run-reverse:
+ # test-one-run-reverse
+ $(DPKG_INSTALL) pkg-conff-original-0.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-0.deb pkg-conff-original-1.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-clean:
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/DEBIAN/conffiles b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/DEBIAN/control b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/DEBIAN/control
new file mode 100644
index 0000000..523e417
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-original
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
+
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/test-conffile b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/test-conffile
new file mode 100644
index 0000000..995e78d
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/test-conffile
@@ -0,0 +1 @@
+test original 0
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/test-original b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-0/test-original
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/DEBIAN/conffiles b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/DEBIAN/control b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/DEBIAN/control
new file mode 100644
index 0000000..aebf74d
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-original
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
+
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/test-conffile b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/test-conffile
new file mode 100644
index 0000000..326ec44
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/test-conffile
@@ -0,0 +1 @@
+test original 1
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/test-original b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-original-1/test-original
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/DEBIAN/conffiles b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/DEBIAN/control b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/DEBIAN/control
new file mode 100644
index 0000000..1f1e038
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-takeover
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-conff-original
+Description: test package - conffile replaces takeover
+
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/test-conffile b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/test-conffile
new file mode 100644
index 0000000..01c117f
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/test-conffile
@@ -0,0 +1 @@
+test takeover 0
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/test-takeover b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-0/test-takeover
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/DEBIAN/conffiles b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/DEBIAN/control b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/DEBIAN/control
new file mode 100644
index 0000000..f323304
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-takeover
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-conff-original
+Description: test package - conffile replaces takeover
+
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/test-conffile b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/test-conffile
new file mode 100644
index 0000000..1bc4643
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/test-conffile
@@ -0,0 +1 @@
+test takeover 1
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/test-takeover b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/pkg-conff-takeover-1/test-takeover
diff --git a/tests/t-conffile-replaces-existing-and-upgrade/ref-conffile b/tests/t-conffile-replaces-existing-and-upgrade/ref-conffile
new file mode 100644
index 0000000..1bc4643
--- /dev/null
+++ b/tests/t-conffile-replaces-existing-and-upgrade/ref-conffile
@@ -0,0 +1 @@
+test takeover 1
diff --git a/tests/t-conffile-replaces-existing/Makefile b/tests/t-conffile-replaces-existing/Makefile
new file mode 100644
index 0000000..6c3d617
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/Makefile
@@ -0,0 +1,48 @@
+TESTS_DEB := pkg-conff-original-0 pkg-conff-original-1 pkg-conff-takeover
+
+include ../Test.mk
+
+TEST_CASES += test-two-run-ordered
+TEST_CASES += test-one-run-ordered
+TEST_CASES += test-two-run-reverse
+TEST_CASES += test-one-run-reverse
+
+test-case: $(TEST_CASES)
+
+define VERIFY
+$(call pkg_is_installed,pkg-conff-original)
+$(call pkg_is_installed,pkg-conff-takeover)
+test "`$(DPKG_QUERY) -S /test-conffile`" = "pkg-conff-takeover: /test-conffile"
+cmp ref-conffile "$(DPKG_INSTDIR)/test-conffile"
+endef
+
+test-two-run-ordered:
+ # test-two-run-ordered
+ $(DPKG_INSTALL) pkg-conff-original-0.deb
+ $(DPKG_INSTALL) pkg-conff-original-1.deb
+ $(DPKG_INSTALL) pkg-conff-takeover.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-one-run-ordered:
+ # test-one-run-ordered
+ $(DPKG_INSTALL) pkg-conff-original-0.deb
+ $(DPKG_INSTALL) pkg-conff-original-1.deb pkg-conff-takeover.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-two-run-reverse:
+ # test-two-run-reverse
+ $(DPKG_INSTALL) pkg-conff-original-0.deb
+ $(DPKG_INSTALL) pkg-conff-takeover.deb
+ $(DPKG_INSTALL) pkg-conff-original-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-one-run-reverse:
+ # test-one-run-reverse
+ $(DPKG_INSTALL) pkg-conff-original-0.deb
+ $(DPKG_INSTALL) pkg-conff-takeover.deb pkg-conff-original-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-original-0/DEBIAN/conffiles b/tests/t-conffile-replaces-existing/pkg-conff-original-0/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-original-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-original-0/DEBIAN/control b/tests/t-conffile-replaces-existing/pkg-conff-original-0/DEBIAN/control
new file mode 100644
index 0000000..523e417
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-original-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-original
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
+
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-original-0/test-conffile b/tests/t-conffile-replaces-existing/pkg-conff-original-0/test-conffile
new file mode 100644
index 0000000..995e78d
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-original-0/test-conffile
@@ -0,0 +1 @@
+test original 0
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-original-0/test-original b/tests/t-conffile-replaces-existing/pkg-conff-original-0/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-original-0/test-original
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-original-1/DEBIAN/conffiles b/tests/t-conffile-replaces-existing/pkg-conff-original-1/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-original-1/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-original-1/DEBIAN/control b/tests/t-conffile-replaces-existing/pkg-conff-original-1/DEBIAN/control
new file mode 100644
index 0000000..aebf74d
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-original-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-original
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
+
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-original-1/test-conffile b/tests/t-conffile-replaces-existing/pkg-conff-original-1/test-conffile
new file mode 100644
index 0000000..326ec44
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-original-1/test-conffile
@@ -0,0 +1 @@
+test original 1
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-original-1/test-original b/tests/t-conffile-replaces-existing/pkg-conff-original-1/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-original-1/test-original
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-takeover/DEBIAN/conffiles b/tests/t-conffile-replaces-existing/pkg-conff-takeover/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-takeover/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-takeover/DEBIAN/control b/tests/t-conffile-replaces-existing/pkg-conff-takeover/DEBIAN/control
new file mode 100644
index 0000000..1f1e038
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-takeover/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-takeover
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-conff-original
+Description: test package - conffile replaces takeover
+
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-takeover/test-conffile b/tests/t-conffile-replaces-existing/pkg-conff-takeover/test-conffile
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-takeover/test-conffile
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-conffile-replaces-existing/pkg-conff-takeover/test-takeover b/tests/t-conffile-replaces-existing/pkg-conff-takeover/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/pkg-conff-takeover/test-takeover
diff --git a/tests/t-conffile-replaces-existing/ref-conffile b/tests/t-conffile-replaces-existing/ref-conffile
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-conffile-replaces-existing/ref-conffile
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-conffile-replaces-upgrade/Makefile b/tests/t-conffile-replaces-upgrade/Makefile
new file mode 100644
index 0000000..88298b3
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/Makefile
@@ -0,0 +1,58 @@
+TESTS_DEB := pkg-conff-original pkg-conff-takeover-0 pkg-conff-takeover-1
+
+include ../Test.mk
+
+TEST_CASES += test-two-run-ordered
+TEST_CASES += test-one-run-ordered
+TEST_CASES += test-two-run-reverse
+TEST_CASES += test-one-run-reverse
+
+test-case: $(TEST_CASES)
+
+define CONFFILES
+$(DPKG_QUERY) -f '$${Package} @ $${Conffiles}\n'
+endef
+
+define VERIFY
+$(call pkg_is_installed,pkg-conff-original)
+$(call pkg_is_installed,pkg-conff-takeover)
+test "`$(DPKG_QUERY) -S /test-conffile`" = "pkg-conff-takeover: /test-conffile"
+test "`$(DPKG_QUERY) -S /test-confpath`" = "pkg-conff-takeover: /test-confpath"
+test "`$(CONFFILES) -W pkg-conff-original | grep obsolete | wc -l`" = "2"
+test "`$(CONFFILES) -W pkg-conff-takeover | grep -v obsolete | wc -l`" = "2"
+cmp ref-conffile "$(DPKG_INSTDIR)/test-conffile"
+cmp ref-conffile "$(DPKG_INSTDIR)/test-confpath"
+endef
+
+test-two-run-ordered:
+ # test-two-run-ordered
+ $(DPKG_INSTALL) pkg-conff-original.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-0.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-one-run-ordered:
+ # test-one-run-ordered
+ $(DPKG_INSTALL) pkg-conff-original.deb pkg-conff-takeover-0.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-two-run-reverse:
+ # test-two-run-reverse
+ $(DPKG_INSTALL) pkg-conff-takeover-0.deb
+ $(DPKG_INSTALL) pkg-conff-original.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-one-run-reverse:
+ # test-one-run-reverse
+ $(DPKG_INSTALL) pkg-conff-takeover-0.deb pkg-conff-original.deb
+ $(DPKG_INSTALL) pkg-conff-takeover-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-clean:
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-original/DEBIAN/conffiles b/tests/t-conffile-replaces-upgrade/pkg-conff-original/DEBIAN/conffiles
new file mode 100644
index 0000000..da14206
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-original/DEBIAN/conffiles
@@ -0,0 +1,2 @@
+/test-conffile
+/test-confpath
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-original/DEBIAN/control b/tests/t-conffile-replaces-upgrade/pkg-conff-original/DEBIAN/control
new file mode 100644
index 0000000..523e417
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-original/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-original
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
+
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-original/test-conffile b/tests/t-conffile-replaces-upgrade/pkg-conff-original/test-conffile
new file mode 100644
index 0000000..995e78d
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-original/test-conffile
@@ -0,0 +1 @@
+test original 0
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-original/test-confpath b/tests/t-conffile-replaces-upgrade/pkg-conff-original/test-confpath
new file mode 100644
index 0000000..995e78d
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-original/test-confpath
@@ -0,0 +1 @@
+test original 0
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-original/test-original b/tests/t-conffile-replaces-upgrade/pkg-conff-original/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-original/test-original
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/DEBIAN/conffiles b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/DEBIAN/conffiles
new file mode 100644
index 0000000..da14206
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/DEBIAN/conffiles
@@ -0,0 +1,2 @@
+/test-conffile
+/test-confpath
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/DEBIAN/control b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/DEBIAN/control
new file mode 100644
index 0000000..1f1e038
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-takeover
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-conff-original
+Description: test package - conffile replaces takeover
+
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-conffile b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-conffile
new file mode 100644
index 0000000..01c117f
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-conffile
@@ -0,0 +1 @@
+test takeover 0
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-confpath b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-confpath
new file mode 100644
index 0000000..01c117f
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-confpath
@@ -0,0 +1 @@
+test takeover 0
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-takeover b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-0/test-takeover
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/DEBIAN/conffiles b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/DEBIAN/conffiles
new file mode 100644
index 0000000..da14206
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/DEBIAN/conffiles
@@ -0,0 +1,2 @@
+/test-conffile
+/test-confpath
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/DEBIAN/control b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/DEBIAN/control
new file mode 100644
index 0000000..f323304
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-takeover
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-conff-original
+Description: test package - conffile replaces takeover
+
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-conffile b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-conffile
new file mode 100644
index 0000000..1bc4643
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-conffile
@@ -0,0 +1 @@
+test takeover 1
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-confpath b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-confpath
new file mode 100644
index 0000000..1bc4643
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-confpath
@@ -0,0 +1 @@
+test takeover 1
diff --git a/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-takeover b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/pkg-conff-takeover-1/test-takeover
diff --git a/tests/t-conffile-replaces-upgrade/ref-conffile b/tests/t-conffile-replaces-upgrade/ref-conffile
new file mode 100644
index 0000000..1bc4643
--- /dev/null
+++ b/tests/t-conffile-replaces-upgrade/ref-conffile
@@ -0,0 +1 @@
+test takeover 1
diff --git a/tests/t-conffile-replaces/Makefile b/tests/t-conffile-replaces/Makefile
new file mode 100644
index 0000000..27d934f
--- /dev/null
+++ b/tests/t-conffile-replaces/Makefile
@@ -0,0 +1,44 @@
+TESTS_DEB := pkg-conff-original pkg-conff-takeover
+
+include ../Test.mk
+
+TEST_CASES += test-two-run-ordered
+TEST_CASES += test-one-run-ordered
+TEST_CASES += test-two-run-reverse
+TEST_CASES += test-one-run-reverse
+
+test-case: $(TEST_CASES)
+
+define VERIFY
+$(call pkg_is_installed,pkg-conff-original)
+$(call pkg_is_installed,pkg-conff-takeover)
+test "`$(DPKG_QUERY) -S /test-conffile`" = "pkg-conff-takeover: /test-conffile"
+cmp ref-conffile "$(DPKG_INSTDIR)/test-conffile"
+endef
+
+test-two-run-ordered:
+ # test-two-run-ordered
+ $(DPKG_INSTALL) pkg-conff-original.deb
+ $(DPKG_INSTALL) pkg-conff-takeover.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-one-run-ordered:
+ # test-one-run-ordered
+ $(DPKG_INSTALL) pkg-conff-original.deb pkg-conff-takeover.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-two-run-reverse:
+ # test-two-run-reverse
+ $(DPKG_INSTALL) pkg-conff-takeover.deb
+ $(DPKG_INSTALL) pkg-conff-original.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
+test-one-run-reverse:
+ # test-one-run-reverse
+ $(DPKG_INSTALL) pkg-conff-takeover.deb pkg-conff-original.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
diff --git a/tests/t-conffile-replaces/pkg-conff-original/DEBIAN/conffiles b/tests/t-conffile-replaces/pkg-conff-original/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces/pkg-conff-original/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces/pkg-conff-original/DEBIAN/control b/tests/t-conffile-replaces/pkg-conff-original/DEBIAN/control
new file mode 100644
index 0000000..523e417
--- /dev/null
+++ b/tests/t-conffile-replaces/pkg-conff-original/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-original
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
+
diff --git a/tests/t-conffile-replaces/pkg-conff-original/test-conffile b/tests/t-conffile-replaces/pkg-conff-original/test-conffile
new file mode 100644
index 0000000..7e3c47b
--- /dev/null
+++ b/tests/t-conffile-replaces/pkg-conff-original/test-conffile
@@ -0,0 +1 @@
+test original
diff --git a/tests/t-conffile-replaces/pkg-conff-original/test-original b/tests/t-conffile-replaces/pkg-conff-original/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces/pkg-conff-original/test-original
diff --git a/tests/t-conffile-replaces/pkg-conff-takeover/DEBIAN/conffiles b/tests/t-conffile-replaces/pkg-conff-takeover/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-replaces/pkg-conff-takeover/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-replaces/pkg-conff-takeover/DEBIAN/control b/tests/t-conffile-replaces/pkg-conff-takeover/DEBIAN/control
new file mode 100644
index 0000000..1f1e038
--- /dev/null
+++ b/tests/t-conffile-replaces/pkg-conff-takeover/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-takeover
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-conff-original
+Description: test package - conffile replaces takeover
+
diff --git a/tests/t-conffile-replaces/pkg-conff-takeover/test-conffile b/tests/t-conffile-replaces/pkg-conff-takeover/test-conffile
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-conffile-replaces/pkg-conff-takeover/test-conffile
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-conffile-replaces/pkg-conff-takeover/test-takeover b/tests/t-conffile-replaces/pkg-conff-takeover/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-replaces/pkg-conff-takeover/test-takeover
diff --git a/tests/t-conffile-replaces/ref-conffile b/tests/t-conffile-replaces/ref-conffile
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-conffile-replaces/ref-conffile
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-conffile-root-option/Makefile b/tests/t-conffile-root-option/Makefile
new file mode 100644
index 0000000..bd98cc7
--- /dev/null
+++ b/tests/t-conffile-root-option/Makefile
@@ -0,0 +1,39 @@
+TESTS_DEB := pkg-conff-a-1 pkg-conff-a-2 pkg-conff-b-1 pkg-conff-b-2
+
+include ../Test.mk
+
+TEST_CASES += test-conffile-move-packages-no-rootdir
+TEST_CASES += test-conffile-move-packages-rootdir
+
+test-case: $(TEST_CASES)
+
+test-conffile-move-packages-no-rootdir:
+ # Install base versions.
+ $(DPKG_INSTALL) pkg-conff-a-1.deb pkg-conff-b-1.deb
+ # Install update, conffile moves from a to b.
+ $(DPKG_INSTALL) pkg-conff-a-2.deb pkg-conff-b-2.deb
+ # Cleanup.
+ -$(DPKG_PURGE) pkg-conff-b
+ -$(DPKG_PURGE) pkg-conff-a
+
+TEST_ROOT := $(CURDIR)/target
+
+test-conffile-move-packages-rootdir: override DPKG_ADMINDIR = $(TEST_ROOT)/var/lib/dpkg
+test-conffile-move-packages-rootdir: override DPKG_INSTDIR = $(TEST_ROOT)
+test-conffile-move-packages-rootdir:
+ # Create template root dir.
+ mkdir -p $(DPKG_ADMINDIR)/info
+ mkdir -p $(DPKG_ADMINDIR)/updates
+ mkdir -p $(DPKG_ADMINDIR)/triggers
+ touch $(DPKG_ADMINDIR)/status
+ # Install base versions.
+ $(DPKG_INSTALL) pkg-conff-a-1.deb pkg-conff-b-1.deb
+ # Install update, conffile moves from a to b.
+ $(DPKG_INSTALL) pkg-conff-a-2.deb pkg-conff-b-2.deb
+ # Cleanup.
+ -$(DPKG_PURGE) pkg-conff-b
+ -$(DPKG_PURGE) pkg-conff-a
+
+test-clean:
+ -$(DPKG_PURGE) pkg-conff-a pkg-conff-b
+ -$(BEROOT) rm -rf $(TEST_ROOT)
diff --git a/tests/t-conffile-root-option/pkg-conff-a-1/DEBIAN/conffiles b/tests/t-conffile-root-option/pkg-conff-a-1/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-root-option/pkg-conff-a-1/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-root-option/pkg-conff-a-1/DEBIAN/control b/tests/t-conffile-root-option/pkg-conff-a-1/DEBIAN/control
new file mode 100644
index 0000000..a2578e4
--- /dev/null
+++ b/tests/t-conffile-root-option/pkg-conff-a-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conff-a
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conflicting conffile
diff --git a/tests/t-conffile-root-option/pkg-conff-a-1/test-conffile b/tests/t-conffile-root-option/pkg-conff-a-1/test-conffile
new file mode 100644
index 0000000..024da49
--- /dev/null
+++ b/tests/t-conffile-root-option/pkg-conff-a-1/test-conffile
@@ -0,0 +1 @@
+pkg-conff-a
diff --git a/tests/t-conffile-root-option/pkg-conff-a-2/DEBIAN/control b/tests/t-conffile-root-option/pkg-conff-a-2/DEBIAN/control
new file mode 100644
index 0000000..21eb309
--- /dev/null
+++ b/tests/t-conffile-root-option/pkg-conff-a-2/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conff-a
+Version: 2
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conflicting conffile
diff --git a/tests/t-conffile-root-option/pkg-conff-b-1/DEBIAN/control b/tests/t-conffile-root-option/pkg-conff-b-1/DEBIAN/control
new file mode 100644
index 0000000..0f87276
--- /dev/null
+++ b/tests/t-conffile-root-option/pkg-conff-b-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conff-b
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conflicting conffile
diff --git a/tests/t-conffile-root-option/pkg-conff-b-2/DEBIAN/conffiles b/tests/t-conffile-root-option/pkg-conff-b-2/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-root-option/pkg-conff-b-2/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-root-option/pkg-conff-b-2/DEBIAN/control b/tests/t-conffile-root-option/pkg-conff-b-2/DEBIAN/control
new file mode 100644
index 0000000..57b18ee
--- /dev/null
+++ b/tests/t-conffile-root-option/pkg-conff-b-2/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-conff-b
+Version: 2
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conflicting conffile
diff --git a/tests/t-conffile-root-option/pkg-conff-b-2/test-conffile b/tests/t-conffile-root-option/pkg-conff-b-2/test-conffile
new file mode 100644
index 0000000..006fbc7
--- /dev/null
+++ b/tests/t-conffile-root-option/pkg-conff-b-2/test-conffile
@@ -0,0 +1 @@
+pkg-conff-b
diff --git a/tests/t-conffile-versioned-replaces-downgrade/Makefile b/tests/t-conffile-versioned-replaces-downgrade/Makefile
new file mode 100644
index 0000000..df08bd6
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/Makefile
@@ -0,0 +1,20 @@
+TESTS_DEB := pkg-conff-original-0 pkg-conff-original-1 pkg-conff-takeover
+
+include ../Test.mk
+
+define VERIFY
+$(call pkg_is_installed,pkg-conff-original)
+$(call pkg_is_installed,pkg-conff-takeover)
+test "`$(DPKG_QUERY) -S /test-conffile`" = "pkg-conff-takeover: /test-conffile"
+cmp ref-conffile "$(DPKG_INSTDIR)/test-conffile"
+endef
+
+test-case:
+ # Install packages
+ $(DPKG_INSTALL) pkg-conff-original-1.deb
+ $(DPKG_INSTALL) pkg-conff-takeover.deb
+ # Downgrade to test versioned Replaces
+ $(DPKG_INSTALL) pkg-conff-original-0.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-conff-original pkg-conff-takeover
+
diff --git a/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/DEBIAN/conffiles b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/DEBIAN/control b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/DEBIAN/control
new file mode 100644
index 0000000..523e417
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-original
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a conffile
+
diff --git a/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/test-conffile b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/test-conffile
new file mode 100644
index 0000000..995e78d
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/test-conffile
@@ -0,0 +1 @@
+test original 0
diff --git a/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/test-original b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-0/test-original
diff --git a/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-1/DEBIAN/control b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-1/DEBIAN/control
new file mode 100644
index 0000000..6cb5a69
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conff-original
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - stop provinding a conffile
+
diff --git a/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-1/test-original b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-1/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-original-1/test-original
diff --git a/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/DEBIAN/conffiles b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/DEBIAN/conffiles
new file mode 100644
index 0000000..4fad7e9
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-conffile
diff --git a/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/DEBIAN/control b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/DEBIAN/control
new file mode 100644
index 0000000..22ae20f
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-conff-takeover
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-conff-original (<= 0)
+Description: test package - conffile replaces takeover
+
diff --git a/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/test-conffile b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/test-conffile
new file mode 100644
index 0000000..1bc4643
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/test-conffile
@@ -0,0 +1 @@
+test takeover 1
diff --git a/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/test-takeover b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/pkg-conff-takeover/test-takeover
diff --git a/tests/t-conffile-versioned-replaces-downgrade/ref-conffile b/tests/t-conffile-versioned-replaces-downgrade/ref-conffile
new file mode 100644
index 0000000..1bc4643
--- /dev/null
+++ b/tests/t-conffile-versioned-replaces-downgrade/ref-conffile
@@ -0,0 +1 @@
+test takeover 1
diff --git a/tests/t-conflict-provide-replace-interface/Makefile b/tests/t-conflict-provide-replace-interface/Makefile
new file mode 100644
index 0000000..6aefafb
--- /dev/null
+++ b/tests/t-conflict-provide-replace-interface/Makefile
@@ -0,0 +1,18 @@
+TESTS_DEB := pkg-a pkg-b
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-a.deb
+ # The user was not explicit in the request, fail
+ ! $(DPKG_INSTALL) pkg-b.deb
+ # Even if requesting auto-deconfigure the request is not explicit
+ # enough, fail
+ ! $(DPKG_INSTALL) -B pkg-b.deb
+ # Set up the desired transaction
+ echo pkg-a deinstall | $(BEROOT) $(DPKG) --set-selections
+ $(DPKG_INSTALL) pkg-b.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-b
+ -$(DPKG_PURGE) pkg-a
diff --git a/tests/t-conflict-provide-replace-interface/pkg-a/DEBIAN/control b/tests/t-conflict-provide-replace-interface/pkg-a/DEBIAN/control
new file mode 100644
index 0000000..3e079f1
--- /dev/null
+++ b/tests/t-conflict-provide-replace-interface/pkg-a/DEBIAN/control
@@ -0,0 +1,10 @@
+Package: pkg-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-iface
+Replaces: pkg-iface
+Provides: pkg-iface
+Description: test package - package providing an interface
diff --git a/tests/t-conflict-provide-replace-interface/pkg-b/DEBIAN/control b/tests/t-conflict-provide-replace-interface/pkg-b/DEBIAN/control
new file mode 100644
index 0000000..80b99d7
--- /dev/null
+++ b/tests/t-conflict-provide-replace-interface/pkg-b/DEBIAN/control
@@ -0,0 +1,11 @@
+Package: pkg-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-iface
+Replaces: pkg-iface
+Provides: pkg-iface
+Description: test package - package providing an interface
+
diff --git a/tests/t-conflict-provide-replace-real/Makefile b/tests/t-conflict-provide-replace-real/Makefile
new file mode 100644
index 0000000..84334ce
--- /dev/null
+++ b/tests/t-conflict-provide-replace-real/Makefile
@@ -0,0 +1,13 @@
+TESTS_DEB := pkg-a pkg-b
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-a.deb
+ # test if the replacing package takes over on install
+ $(DPKG_INSTALL) pkg-b.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-b
+ -$(DPKG_PURGE) pkg-a
+
diff --git a/tests/t-conflict-provide-replace-real/pkg-a/DEBIAN/control b/tests/t-conflict-provide-replace-real/pkg-a/DEBIAN/control
new file mode 100644
index 0000000..0d7fa10
--- /dev/null
+++ b/tests/t-conflict-provide-replace-real/pkg-a/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package to be replaced
+
diff --git a/tests/t-conflict-provide-replace-real/pkg-a/test-conflict b/tests/t-conflict-provide-replace-real/pkg-a/test-conflict
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conflict-provide-replace-real/pkg-a/test-conflict
diff --git a/tests/t-conflict-provide-replace-real/pkg-b/DEBIAN/control b/tests/t-conflict-provide-replace-real/pkg-b/DEBIAN/control
new file mode 100644
index 0000000..8b292a6
--- /dev/null
+++ b/tests/t-conflict-provide-replace-real/pkg-b/DEBIAN/control
@@ -0,0 +1,11 @@
+Package: pkg-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-a
+Provides: pkg-a
+Replaces: pkg-a
+Description: test package - replacing package
+
diff --git a/tests/t-conflict-provide-replace-real/pkg-b/test-conflict b/tests/t-conflict-provide-replace-real/pkg-b/test-conflict
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-conflict-provide-replace-real/pkg-b/test-conflict
diff --git a/tests/t-conflict-provide-replace-virtual-multiarch/Makefile b/tests/t-conflict-provide-replace-virtual-multiarch/Makefile
new file mode 100644
index 0000000..22176a3
--- /dev/null
+++ b/tests/t-conflict-provide-replace-virtual-multiarch/Makefile
@@ -0,0 +1,23 @@
+TESTS_DEB := pkg-virt-i386 pkg-virt-amd64 pkg-real-i386 pkg-real-amd64
+
+include ../Test.mk
+
+test-case:
+ $(DPKG) --add-architecture amd64
+ $(DPKG) --add-architecture i386
+ $(DPKG_INSTALL) pkg-virt-i386.deb
+ # Configuring pkg-real:amd64 should not be allowed
+ ! $(DPKG_INSTALL) pkg-real-amd64.deb
+ $(DPKG_INSTALL) pkg-real-i386.deb
+ $(DPKG_INSTALL) pkg-virt-amd64.deb
+ $(DPKG_INSTALL) pkg-real-i386.deb
+ # Purging should not be allowed
+ ! $(DPKG_PURGE) pkg-virt:i386
+
+test-clean:
+ $(DPKG_PURGE) pkg-real:i386
+ $(DPKG_PURGE) pkg-real:amd64
+ $(DPKG_PURGE) pkg-virt:i386
+ $(DPKG_PURGE) pkg-virt:amd64
+ $(DPKG) --remove-architecture amd64
+ $(DPKG) --remove-architecture i386
diff --git a/tests/t-conflict-provide-replace-virtual-multiarch/pkg-real-amd64/DEBIAN/control b/tests/t-conflict-provide-replace-virtual-multiarch/pkg-real-amd64/DEBIAN/control
new file mode 100644
index 0000000..b0d033c
--- /dev/null
+++ b/tests/t-conflict-provide-replace-virtual-multiarch/pkg-real-amd64/DEBIAN/control
@@ -0,0 +1,10 @@
+Package: pkg-real
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Depends: pkg-v
+Description: test package - depending on virtual
+
diff --git a/tests/t-conflict-provide-replace-virtual-multiarch/pkg-real-i386/DEBIAN/control b/tests/t-conflict-provide-replace-virtual-multiarch/pkg-real-i386/DEBIAN/control
new file mode 100644
index 0000000..e248c73
--- /dev/null
+++ b/tests/t-conflict-provide-replace-virtual-multiarch/pkg-real-i386/DEBIAN/control
@@ -0,0 +1,10 @@
+Package: pkg-real
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: same
+Depends: pkg-v
+Description: test package - depending on virtual
+
diff --git a/tests/t-conflict-provide-replace-virtual-multiarch/pkg-virt-amd64/DEBIAN/control b/tests/t-conflict-provide-replace-virtual-multiarch/pkg-virt-amd64/DEBIAN/control
new file mode 100644
index 0000000..312fafd
--- /dev/null
+++ b/tests/t-conflict-provide-replace-virtual-multiarch/pkg-virt-amd64/DEBIAN/control
@@ -0,0 +1,12 @@
+Package: pkg-virt
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Conflicts: pkg-v
+Provides: pkg-v
+Replaces: pkg-v
+Description: test package - conflicting virtual
+
diff --git a/tests/t-conflict-provide-replace-virtual-multiarch/pkg-virt-i386/DEBIAN/control b/tests/t-conflict-provide-replace-virtual-multiarch/pkg-virt-i386/DEBIAN/control
new file mode 100644
index 0000000..f1b171f
--- /dev/null
+++ b/tests/t-conflict-provide-replace-virtual-multiarch/pkg-virt-i386/DEBIAN/control
@@ -0,0 +1,12 @@
+Package: pkg-virt
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: same
+Conflicts: pkg-v
+Provides: pkg-v
+Replaces: pkg-v
+Description: test package - conflicting virtual
+
diff --git a/tests/t-conflict-provide-replace-virtual/Makefile b/tests/t-conflict-provide-replace-virtual/Makefile
new file mode 100644
index 0000000..e0ed06e
--- /dev/null
+++ b/tests/t-conflict-provide-replace-virtual/Makefile
@@ -0,0 +1,13 @@
+TESTS_DEB := pkg-a pkg-b
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-a.deb
+ # test if the conflicting package fails on install
+ ! $(DPKG_INSTALL) pkg-b.deb
+
+test-clean:
+ -$(DPKG_PURGE) pkg-b
+ $(DPKG_PURGE) pkg-a
+
diff --git a/tests/t-conflict-provide-replace-virtual/pkg-a/DEBIAN/control b/tests/t-conflict-provide-replace-virtual/pkg-a/DEBIAN/control
new file mode 100644
index 0000000..1dba668
--- /dev/null
+++ b/tests/t-conflict-provide-replace-virtual/pkg-a/DEBIAN/control
@@ -0,0 +1,11 @@
+Package: pkg-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-v
+Provides: pkg-v
+Replaces: pkg-v
+Description: test package - conflicting virtual
+
diff --git a/tests/t-conflict-provide-replace-virtual/pkg-b/DEBIAN/control b/tests/t-conflict-provide-replace-virtual/pkg-b/DEBIAN/control
new file mode 100644
index 0000000..8bee1c4
--- /dev/null
+++ b/tests/t-conflict-provide-replace-virtual/pkg-b/DEBIAN/control
@@ -0,0 +1,11 @@
+Package: pkg-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-v
+Provides: pkg-v
+Replaces: pkg-v
+Description: test package - conflicting virtual
+
diff --git a/tests/t-conflicts/Makefile b/tests/t-conflicts/Makefile
new file mode 100644
index 0000000..396d71d
--- /dev/null
+++ b/tests/t-conflicts/Makefile
@@ -0,0 +1,15 @@
+TESTS_DEB := pkg-a pkg-b
+
+include ../Test.mk
+
+test-case:
+ # test if the conflicting packages fail on install
+ ! $(DPKG_INSTALL) pkg-b.deb pkg-a.deb
+ $(call pkg_is_not_installed,pkg-a)
+ -$(DPKG_PURGE) pkg-a pkg-b
+ ! $(DPKG_INSTALL) pkg-a.deb pkg-b.deb
+ $(call pkg_is_not_installed,pkg-b)
+ -$(DPKG_PURGE) pkg-a pkg-b
+
+test-clean:
+ -$(DPKG_PURGE) pkg-a pkg-b
diff --git a/tests/t-conflicts/pkg-a/DEBIAN/control b/tests/t-conflicts/pkg-a/DEBIAN/control
new file mode 100644
index 0000000..ca34e72
--- /dev/null
+++ b/tests/t-conflicts/pkg-a/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-b
+Description: test package - conflicting against pkg-b
diff --git a/tests/t-conflicts/pkg-b/DEBIAN/control b/tests/t-conflicts/pkg-b/DEBIAN/control
new file mode 100644
index 0000000..f723a59
--- /dev/null
+++ b/tests/t-conflicts/pkg-b/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conflicting package
diff --git a/tests/t-control-bogus/Makefile b/tests/t-control-bogus/Makefile
new file mode 100644
index 0000000..ec042dd
--- /dev/null
+++ b/tests/t-control-bogus/Makefile
@@ -0,0 +1,32 @@
+include ../Test.mk
+
+test-case:
+ # test building package with bogus control files
+ ! $(DPKG_BUILD_DEB) pkg-bogus-colon
+ ! $(DPKG_BUILD_DEB) pkg-bogus-blank
+ ! $(DPKG_BUILD_DEB) pkg-bogus-fieldname-empty
+ ! $(DPKG_BUILD_DEB) pkg-bogus-fieldname-partial
+ ! $(DPKG_BUILD_DEB) pkg-bogus-format-string
+
+ # build bogus packages
+ $(DPKG_BUILD_DEB) --nocheck pkg-bogus-colon
+ $(DPKG_BUILD_DEB) --nocheck pkg-bogus-blank
+ $(DPKG_BUILD_DEB) --nocheck pkg-bogus-fieldname-empty
+ $(DPKG_BUILD_DEB) --nocheck pkg-bogus-fieldname-partial
+ $(DPKG_BUILD_DEB) --nocheck pkg-bogus-format-string
+
+ # test installing packages with bogus control files
+ ! $(DPKG_INSTALL) pkg-bogus-colon.deb
+ $(call pkg_is_not_installed,pkg-bogus-colon)
+ ! $(DPKG_INSTALL) pkg-bogus-blank.deb
+ $(call pkg_is_not_installed,pkg-bogus-blank)
+ ! $(DPKG_INSTALL) pkg-bogus-fieldname-empty.deb
+ $(call pkg_is_not_installed,pkg-bogus-fieldname-empty)
+ ! $(DPKG_INSTALL) pkg-bogus-fieldname-partial.deb
+ $(call pkg_is_not_installed,pkg-bogus-fieldname-partial)
+ ! $(DPKG_INSTALL) pkg-bogus-format-string.deb
+ $(call pkg_is_not_installed,pkg-bogus-format-string)
+
+test-clean:
+ rm -f pkg-bogus-colon.deb
+ rm -f pkg-bogus-blank.deb
diff --git a/tests/t-control-bogus/pkg-bogus-blank/DEBIAN/control b/tests/t-control-bogus/pkg-bogus-blank/DEBIAN/control
new file mode 100644
index 0000000..7904382
--- /dev/null
+++ b/tests/t-control-bogus/pkg-bogus-blank/DEBIAN/control
@@ -0,0 +1,18 @@
+Package: pkg-bogus-blank
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - bogus control file w/ blank lines in fields
+ This is an invalid description, containing lines with one space:
+
+ or two:
+
+ or even more:
+
+ Instead of the correct blank line using a dot as delimiter:
+ .
+ Or valid lines with multiple spaces with content:
+ line 1
+ line 2
diff --git a/tests/t-control-bogus/pkg-bogus-colon/DEBIAN/control b/tests/t-control-bogus/pkg-bogus-colon/DEBIAN/control
new file mode 100644
index 0000000..3b32476
--- /dev/null
+++ b/tests/t-control-bogus/pkg-bogus-colon/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-bogus
+BOGUS-LINE
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - bogus control file
diff --git a/tests/t-control-bogus/pkg-bogus-fieldname-empty/DEBIAN/control b/tests/t-control-bogus/pkg-bogus-fieldname-empty/DEBIAN/control
new file mode 100644
index 0000000..ad433ca
--- /dev/null
+++ b/tests/t-control-bogus/pkg-bogus-fieldname-empty/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-bogus-fieldname-empty
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+: value
+Description: test package - bogus control file w/ empty field name
diff --git a/tests/t-control-bogus/pkg-bogus-fieldname-partial/DEBIAN/control b/tests/t-control-bogus/pkg-bogus-fieldname-partial/DEBIAN/control
new file mode 100644
index 0000000..dd28c0b
--- /dev/null
+++ b/tests/t-control-bogus/pkg-bogus-fieldname-partial/DEBIAN/control
@@ -0,0 +1,7 @@
+Pack: pkg-bogus-fieldname-partial
+Vers: 0.0-1
+Sect: test
+Prio: extra
+Main: Dpkg Developers <debian-dpkg@lists.debian.org>
+Arch: all
+Desc: test package - bogus control file w/ partial field names
diff --git a/tests/t-control-bogus/pkg-bogus-format-string/DEBIAN/control b/tests/t-control-bogus/pkg-bogus-format-string/DEBIAN/control
new file mode 100644
index 0000000..bbb181a
--- /dev/null
+++ b/tests/t-control-bogus/pkg-bogus-format-string/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: %s
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: %s
+Description: test package - bogus control file w/ format string in values
diff --git a/tests/t-control-no-arch/Makefile b/tests/t-control-no-arch/Makefile
new file mode 100644
index 0000000..48b79fd
--- /dev/null
+++ b/tests/t-control-no-arch/Makefile
@@ -0,0 +1,22 @@
+include ../Test.mk
+
+test-case:
+ # test building package with missing Architecture field.
+ ! $(DPKG_BUILD_DEB) pkg-no-arch
+
+ # build bogus packages
+ $(DPKG_BUILD_DEB) --nocheck pkg-no-arch
+
+ # test handling of package without the Architecture field
+ ! $(DPKG_INSTALL) pkg-no-arch.deb
+ $(call pkg_is_not_installed,pkg-no-arch)
+ # these ancient/bogus packages need to be forced now
+ $(DPKG_INSTALL) --force-architecture pkg-no-arch.deb
+ $(call pkg_is_installed,pkg-no-arch)
+ ! $(call stdout_has,$(DPKG_QUERY) --status pkg-no-arch,^Architecture:)
+ $(DPKG_PURGE) pkg-no-arch
+ # Clear the available file to avoid missing Architecture warnings
+ $(BEROOT) $(DPKG) --clear-avail
+
+test-clean:
+ rm -f pkg-no-arch.deb
diff --git a/tests/t-control-no-arch/pkg-no-arch/DEBIAN/control b/tests/t-control-no-arch/pkg-no-arch/DEBIAN/control
new file mode 100644
index 0000000..8871216
--- /dev/null
+++ b/tests/t-control-no-arch/pkg-no-arch/DEBIAN/control
@@ -0,0 +1,6 @@
+Package: pkg-no-arch
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Description: test package - without Architecture field
diff --git a/tests/t-db/Makefile b/tests/t-db/Makefile
new file mode 100644
index 0000000..2e5b621
--- /dev/null
+++ b/tests/t-db/Makefile
@@ -0,0 +1,60 @@
+# Copyright © 2012 Guillem Jover <guillem@debian.org>
+
+TESTS_DEB :=
+
+include ../Test.mk
+
+PKG_TUPLE = LC_ALL=C $(DPKG_QUERY) -f '$${Package}:$${Architecture}:$${Version}' -W
+
+TEST_CASES += test-field-blank-lines
+TEST_CASES += test-field-blank-lines-update
+TEST_CASES += test-dupe-multi
+TEST_CASES += test-cross-single-update
+TEST_CASES += test-cross-multi-update
+TEST_CASES += test-bogus-single
+TEST_CASES += test-bogus-dupe-same-single
+TEST_CASES += test-bogus-dupe-diff-single
+TEST_CASES += test-bogus-multi
+TEST_CASES += test-bogus-multi-update
+
+test-case: $(TEST_CASES)
+
+test-field-blank-lines: override DPKG_ADMINDIR = db-field-blank-lines
+test-field-blank-lines:
+ $(call stderr_has,$(PKG_TUPLE),warning)
+
+test-field-blank-lines-update: override DPKG_ADMINDIR = db-field-blank-lines-update
+test-field-blank-lines-update:
+ $(call stderr_has,$(PKG_TUPLE),warning)
+
+test-dupe-multi: override DPKG_ADMINDIR = db-dupe-multi
+test-dupe-multi:
+ $(call stdout_is,$(PKG_TUPLE),pkg-multi:amd64:1.0)
+
+test-cross-single-update: override DPKG_ADMINDIR = db-cross-single-update
+test-cross-single-update:
+ $(call stdout_is,$(PKG_TUPLE),pkg-single:armel:3.0)
+
+test-cross-multi-update: override DPKG_ADMINDIR = db-cross-multi-update
+test-cross-multi-update:
+ $(call stdout_is,$(PKG_TUPLE),pkg-multi:armel:4.0)
+
+test-bogus-dupe-same-single: override DPKG_ADMINDIR = db-bogus-dupe-same-single
+test-bogus-dupe-same-single:
+ $(call stderr_has,$(PKG_TUPLE),error)
+
+test-bogus-dupe-diff-single: override DPKG_ADMINDIR = db-bogus-dupe-diff-single
+test-bogus-dupe-diff-single:
+ $(call stderr_has,$(PKG_TUPLE),error)
+
+test-bogus-single: override DPKG_ADMINDIR = db-bogus-single
+test-bogus-single:
+ $(call stderr_has,$(PKG_TUPLE),error)
+
+test-bogus-multi: override DPKG_ADMINDIR = db-bogus-multi
+test-bogus-multi:
+ $(call stderr_has,$(PKG_TUPLE),error)
+
+test-bogus-multi-update: override DPKG_ADMINDIR = db-bogus-multi-update
+test-bogus-multi-update:
+ $(call stderr_has,$(PKG_TUPLE),error)
diff --git a/tests/t-db/db-bogus-dupe-diff-single/status b/tests/t-db/db-bogus-dupe-diff-single/status
new file mode 100644
index 0000000..0274528
--- /dev/null
+++ b/tests/t-db/db-bogus-dupe-diff-single/status
@@ -0,0 +1,18 @@
+Package: pkg-single
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Version: 1.0
+Description: test package
+
+Package: pkg-single
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Version: 2.0
+Description: test package
+
diff --git a/tests/t-db/db-bogus-dupe-diff-single/updates/.keep b/tests/t-db/db-bogus-dupe-diff-single/updates/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-db/db-bogus-dupe-diff-single/updates/.keep
diff --git a/tests/t-db/db-bogus-dupe-same-single/status b/tests/t-db/db-bogus-dupe-same-single/status
new file mode 100644
index 0000000..b336494
--- /dev/null
+++ b/tests/t-db/db-bogus-dupe-same-single/status
@@ -0,0 +1,18 @@
+Package: pkg-single
+Status: install ok config-files
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Version: 1.0
+Description: test package
+
+Package: pkg-single
+Status: install ok half-installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Version: 2.0
+Description: test package
+
diff --git a/tests/t-db/db-bogus-dupe-same-single/updates/.keep b/tests/t-db/db-bogus-dupe-same-single/updates/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-db/db-bogus-dupe-same-single/updates/.keep
diff --git a/tests/t-db/db-bogus-multi-update/status b/tests/t-db/db-bogus-multi-update/status
new file mode 100644
index 0000000..d605d4b
--- /dev/null
+++ b/tests/t-db/db-bogus-multi-update/status
@@ -0,0 +1,16 @@
+Package: pkg-multi
+Status: install ok config-files
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Version: 1.0
+Description: test package
+
+Package: pkg-multi
+Status: install ok not-installed
+Priority: extra
+Section: test
+Architecture: armel
+
diff --git a/tests/t-db/db-bogus-multi-update/updates/0001 b/tests/t-db/db-bogus-multi-update/updates/0001
new file mode 100644
index 0000000..4c00629
--- /dev/null
+++ b/tests/t-db/db-bogus-multi-update/updates/0001
@@ -0,0 +1,10 @@
+Package: pkg-multi
+Status: install ok half-installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: same
+Version: 1.0
+Description: test package
+
diff --git a/tests/t-db/db-bogus-multi-update/updates/0002 b/tests/t-db/db-bogus-multi-update/updates/0002
new file mode 100644
index 0000000..468518a
--- /dev/null
+++ b/tests/t-db/db-bogus-multi-update/updates/0002
@@ -0,0 +1,9 @@
+Package: pkg-multi
+Status: install ok unpacked
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: armel
+Version: 1.0
+Description: test package
+
diff --git a/tests/t-db/db-bogus-multi/status b/tests/t-db/db-bogus-multi/status
new file mode 100644
index 0000000..c79b950
--- /dev/null
+++ b/tests/t-db/db-bogus-multi/status
@@ -0,0 +1,29 @@
+Package: pkg-multi
+Status: install ok config-files
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Version: 1.0
+Description: test package
+
+Package: pkg-multi
+Status: install ok half-installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: armel
+Version: 1.0
+Description: test package
+
+Package: pkg-multi
+Status: install ok unpacked
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: same
+Version: 1.0
+Description: test package
+
diff --git a/tests/t-db/db-bogus-multi/updates/.keep b/tests/t-db/db-bogus-multi/updates/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-db/db-bogus-multi/updates/.keep
diff --git a/tests/t-db/db-bogus-single/status b/tests/t-db/db-bogus-single/status
new file mode 100644
index 0000000..87eed5d
--- /dev/null
+++ b/tests/t-db/db-bogus-single/status
@@ -0,0 +1,19 @@
+Package: pkg-single
+Status: install ok config-files
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Version: 1.0
+Description: test package
+
+Package: pkg-single
+Status: install ok half-configured
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Version: 1.0
+Description: test package
+
diff --git a/tests/t-db/db-bogus-single/updates/.keep b/tests/t-db/db-bogus-single/updates/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-db/db-bogus-single/updates/.keep
diff --git a/tests/t-db/db-cross-multi-update/status b/tests/t-db/db-cross-multi-update/status
new file mode 100644
index 0000000..cfa1c04
--- /dev/null
+++ b/tests/t-db/db-cross-multi-update/status
@@ -0,0 +1,10 @@
+Package: pkg-multi
+Status: install ok config-files
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Version: 1.0
+Description: test package
+
diff --git a/tests/t-db/db-cross-multi-update/updates/0001 b/tests/t-db/db-cross-multi-update/updates/0001
new file mode 100644
index 0000000..a0fea54
--- /dev/null
+++ b/tests/t-db/db-cross-multi-update/updates/0001
@@ -0,0 +1,10 @@
+Package: pkg-multi
+Status: install ok half-installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: same
+Version: 2.0
+Description: test package
+
diff --git a/tests/t-db/db-cross-multi-update/updates/0002 b/tests/t-db/db-cross-multi-update/updates/0002
new file mode 100644
index 0000000..7850eef
--- /dev/null
+++ b/tests/t-db/db-cross-multi-update/updates/0002
@@ -0,0 +1,10 @@
+Package: pkg-multi
+Status: install ok not-installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: same
+Version: 2.0
+Description: test package
+
diff --git a/tests/t-db/db-cross-multi-update/updates/0003 b/tests/t-db/db-cross-multi-update/updates/0003
new file mode 100644
index 0000000..3759577
--- /dev/null
+++ b/tests/t-db/db-cross-multi-update/updates/0003
@@ -0,0 +1,9 @@
+Package: pkg-multi
+Status: install ok unpacked
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: armel
+Version: 4.0
+Description: test package
+
diff --git a/tests/t-db/db-cross-single-update/status b/tests/t-db/db-cross-single-update/status
new file mode 100644
index 0000000..10c934b
--- /dev/null
+++ b/tests/t-db/db-cross-single-update/status
@@ -0,0 +1,9 @@
+Package: pkg-single
+Status: install ok config-files
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Version: 1.0
+Description: test package
+
diff --git a/tests/t-db/db-cross-single-update/updates/0001 b/tests/t-db/db-cross-single-update/updates/0001
new file mode 100644
index 0000000..ae9d517
--- /dev/null
+++ b/tests/t-db/db-cross-single-update/updates/0001
@@ -0,0 +1,10 @@
+Package: pkg-single
+Status: install ok half-installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: same
+Version: 2.0
+Description: test package
+
diff --git a/tests/t-db/db-cross-single-update/updates/0002 b/tests/t-db/db-cross-single-update/updates/0002
new file mode 100644
index 0000000..11be9c5
--- /dev/null
+++ b/tests/t-db/db-cross-single-update/updates/0002
@@ -0,0 +1,9 @@
+Package: pkg-single
+Status: install ok unpacked
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: armel
+Version: 3.0
+Description: test package
+
diff --git a/tests/t-db/db-dupe-multi/status b/tests/t-db/db-dupe-multi/status
new file mode 100644
index 0000000..e2e1a7d
--- /dev/null
+++ b/tests/t-db/db-dupe-multi/status
@@ -0,0 +1,20 @@
+Package: pkg-multi
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Version: 1.0
+Description: test package
+
+Package: pkg-multi
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Version: 1.0
+Description: test package
+
diff --git a/tests/t-db/db-dupe-multi/updates/.keep b/tests/t-db/db-dupe-multi/updates/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-db/db-dupe-multi/updates/.keep
diff --git a/tests/t-db/db-field-blank-lines-update/status b/tests/t-db/db-field-blank-lines-update/status
new file mode 100644
index 0000000..7b58a81
--- /dev/null
+++ b/tests/t-db/db-field-blank-lines-update/status
@@ -0,0 +1,13 @@
+Package: pkg-correct
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Version: 1.0
+Description: test package
+ This description splits
+ .
+ lines correctly
+ .
+ with dots.
diff --git a/tests/t-db/db-field-blank-lines-update/updates/.keep b/tests/t-db/db-field-blank-lines-update/updates/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-db/db-field-blank-lines-update/updates/.keep
diff --git a/tests/t-db/db-field-blank-lines-update/updates/0001 b/tests/t-db/db-field-blank-lines-update/updates/0001
new file mode 100644
index 0000000..6d9c599
--- /dev/null
+++ b/tests/t-db/db-field-blank-lines-update/updates/0001
@@ -0,0 +1,13 @@
+Package: pkg-blank-lines
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Version: 1.0
+Description: test package
+ This description splits
+
+ lines incorrectly
+
+ with blank lines, but is still tolerated.
diff --git a/tests/t-db/db-field-blank-lines/status b/tests/t-db/db-field-blank-lines/status
new file mode 100644
index 0000000..a9759da
--- /dev/null
+++ b/tests/t-db/db-field-blank-lines/status
@@ -0,0 +1,27 @@
+Package: pkg-blank-lines
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Version: 1.0
+Description: test package
+ This description splits
+
+ lines incorrectly
+
+ with blank lines, but is still tolerated.
+
+Package: pkg-correct
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Version: 1.0
+Description: test package
+ This description splits
+ .
+ lines correctly
+ .
+ with dots.
diff --git a/tests/t-db/db-field-blank-lines/updates/.keep b/tests/t-db/db-field-blank-lines/updates/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-db/db-field-blank-lines/updates/.keep
diff --git a/tests/t-deb-lfs/Makefile b/tests/t-deb-lfs/Makefile
new file mode 100644
index 0000000..4e45e1f
--- /dev/null
+++ b/tests/t-deb-lfs/Makefile
@@ -0,0 +1,35 @@
+PKG_SFS := pkg-sfs
+PKG_LFS := pkg-lfs
+
+TESTS_DEB := $(PKG_LFS) $(PKG_SFS)
+
+# This will test both the ar archive and the tar LFS support.
+DPKG_DEB_OPTIONS = -Znone
+
+include ../Test.mk
+
+$(PKG_LFS)/large-file:
+ dd if=/dev/zero of=$@ bs=1K count=5M
+
+$(PKG_SFS)/small-file:
+ yes | dd of=$@ bs=1K count=4
+
+build-hook: $(PKG_LFS)/large-file $(PKG_SFS)/small-file
+
+clean-hook:
+ $(RM) $(PKG_LFS)/large-file $(PKG_SFS)/small-file
+
+test-case:
+ # test Small File Support packages
+ $(DPKG_INSTALL) pkg-sfs.deb
+ $(call pkg_is_installed,pkg-sfs)
+ test "`stat -c%s '$(DPKG_INSTDIR)/small-file'`" = "4096"
+
+ # test Large File Support packages
+ $(DPKG_INSTALL) pkg-lfs.deb
+ $(call pkg_is_installed,pkg-lfs)
+ test "`stat -c%s '$(DPKG_INSTDIR)/large-file'`" = "5368709120"
+
+test-clean:
+ $(DPKG_PURGE) pkg-sfs
+ $(DPKG_PURGE) pkg-lfs
diff --git a/tests/t-deb-lfs/pkg-lfs/DEBIAN/control b/tests/t-deb-lfs/pkg-lfs/DEBIAN/control
new file mode 100644
index 0000000..8982f07
--- /dev/null
+++ b/tests/t-deb-lfs/pkg-lfs/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-lfs
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - large file support
diff --git a/tests/t-deb-lfs/pkg-sfs/DEBIAN/control b/tests/t-deb-lfs/pkg-sfs/DEBIAN/control
new file mode 100644
index 0000000..2ccee74
--- /dev/null
+++ b/tests/t-deb-lfs/pkg-sfs/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-sfs
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - small file support
diff --git a/tests/t-depends/Makefile b/tests/t-depends/Makefile
new file mode 100644
index 0000000..73c10ea
--- /dev/null
+++ b/tests/t-depends/Makefile
@@ -0,0 +1,83 @@
+TESTS_DEB := \
+ pkg-real pkg-depends \
+ pkg-version-1 pkg-version-2 pkg-version-3 pkg-depends-eq \
+ pkg-depends-lt pkg-depends-le pkg-depends-ge pkg-depends-gt
+
+include ../Test.mk
+
+test-depends:
+ # The dependency is not present, fail
+ ! $(DPKG_INSTALL) pkg-depends.deb
+ # Install the real package
+ $(DPKG_INSTALL) pkg-real.deb
+ # The dependency is present, pass
+ $(DPKG_INSTALL) pkg-depends.deb
+ # The dependency is removed, fail
+ ! $(DPKG_PURGE) pkg-real
+ # The depending package is removed, pass
+ $(DPKG_PURGE) pkg-depends
+ # The dependency is removed, pass
+ $(DPKG_PURGE) pkg-real
+ # Now try with --force-depends
+ $(DPKG_INSTALL) --force-depends pkg-depends.deb
+ $(DPKG_PURGE) pkg-depends
+
+define PURGE_DEPENDS
+$(DPKG_PURGE) pkg-depends-lt
+$(DPKG_PURGE) pkg-depends-le
+$(DPKG_PURGE) pkg-depends-eq
+$(DPKG_PURGE) pkg-depends-ge
+$(DPKG_PURGE) pkg-depends-gt
+endef
+
+test-depends-versioned:
+ $(PURGE_DEPENDS)
+
+ # The dependency is not present, fail
+ ! $(DPKG_INSTALL) pkg-depends-lt.deb
+ ! $(DPKG_INSTALL) pkg-depends-le.deb
+ ! $(DPKG_INSTALL) pkg-depends-eq.deb
+ ! $(DPKG_INSTALL) pkg-depends-ge.deb
+ ! $(DPKG_INSTALL) pkg-depends-gt.deb
+
+ # Install the package v1
+ $(DPKG_INSTALL) pkg-version-1.deb
+ $(DPKG_INSTALL) pkg-depends-lt.deb
+ $(DPKG_INSTALL) pkg-depends-le.deb
+ ! $(DPKG_INSTALL) pkg-depends-eq.deb
+ ! $(DPKG_INSTALL) pkg-depends-ge.deb
+ ! $(DPKG_INSTALL) pkg-depends-gt.deb
+
+ $(PURGE_DEPENDS)
+
+ # Install the package v2
+ $(DPKG_INSTALL) pkg-version-2.deb
+ ! $(DPKG_INSTALL) pkg-depends-lt.deb
+ $(DPKG_INSTALL) pkg-depends-le.deb
+ $(DPKG_INSTALL) pkg-depends-eq.deb
+ $(DPKG_INSTALL) pkg-depends-ge.deb
+ ! $(DPKG_INSTALL) pkg-depends-gt.deb
+
+ $(PURGE_DEPENDS)
+
+ # Install the package v3
+ $(DPKG_INSTALL) pkg-version-3.deb
+ ! $(DPKG_INSTALL) pkg-depends-lt.deb
+ ! $(DPKG_INSTALL) pkg-depends-le.deb
+ ! $(DPKG_INSTALL) pkg-depends-eq.deb
+ $(DPKG_INSTALL) pkg-depends-ge.deb
+ $(DPKG_INSTALL) pkg-depends-gt.deb
+
+ $(PURGE_DEPENDS)
+
+test-case: test-depends test-depends-versioned
+
+test-clean:
+ -$(DPKG_PURGE) pkg-depends
+ -$(DPKG_PURGE) pkg-real
+ -$(DPKG_PURGE) pkg-depends-lt
+ -$(DPKG_PURGE) pkg-depends-le
+ -$(DPKG_PURGE) pkg-depends-eq
+ -$(DPKG_PURGE) pkg-depends-ge
+ -$(DPKG_PURGE) pkg-depends-gt
+ -$(DPKG_PURGE) pkg-version
diff --git a/tests/t-depends/pkg-depends-eq/DEBIAN/control b/tests/t-depends/pkg-depends-eq/DEBIAN/control
new file mode 100644
index 0000000..87e1603
--- /dev/null
+++ b/tests/t-depends/pkg-depends-eq/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-eq
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-version (= 2)
+Description: test package - package depending on an exact version
diff --git a/tests/t-depends/pkg-depends-ge/DEBIAN/control b/tests/t-depends/pkg-depends-ge/DEBIAN/control
new file mode 100644
index 0000000..7ba7567
--- /dev/null
+++ b/tests/t-depends/pkg-depends-ge/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-ge
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-version (>= 2)
+Description: test package - package depending on a greater or equal version
diff --git a/tests/t-depends/pkg-depends-gt/DEBIAN/control b/tests/t-depends/pkg-depends-gt/DEBIAN/control
new file mode 100644
index 0000000..41cb041
--- /dev/null
+++ b/tests/t-depends/pkg-depends-gt/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-gt
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-version (>> 2)
+Description: test package - package depending on a greater than version
diff --git a/tests/t-depends/pkg-depends-le/DEBIAN/control b/tests/t-depends/pkg-depends-le/DEBIAN/control
new file mode 100644
index 0000000..b620960
--- /dev/null
+++ b/tests/t-depends/pkg-depends-le/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-le
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-version (<= 2)
+Description: test package - package depending on an earlier or equal version
diff --git a/tests/t-depends/pkg-depends-lt/DEBIAN/control b/tests/t-depends/pkg-depends-lt/DEBIAN/control
new file mode 100644
index 0000000..ffbb9ba
--- /dev/null
+++ b/tests/t-depends/pkg-depends-lt/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-lt
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-version (<< 2)
+Description: test package - package depending on an earlier than version
diff --git a/tests/t-depends/pkg-depends/DEBIAN/control b/tests/t-depends/pkg-depends/DEBIAN/control
new file mode 100644
index 0000000..eeefbe4
--- /dev/null
+++ b/tests/t-depends/pkg-depends/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-real
+Description: test package - package depending on a real package
diff --git a/tests/t-depends/pkg-real/DEBIAN/control b/tests/t-depends/pkg-real/DEBIAN/control
new file mode 100644
index 0000000..bbd53c2
--- /dev/null
+++ b/tests/t-depends/pkg-real/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-real
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - real package to depend on
diff --git a/tests/t-depends/pkg-version-1/DEBIAN/control b/tests/t-depends/pkg-version-1/DEBIAN/control
new file mode 100644
index 0000000..3ec97d1
--- /dev/null
+++ b/tests/t-depends/pkg-version-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-version
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - real package to depend on a specific version
diff --git a/tests/t-depends/pkg-version-2/DEBIAN/control b/tests/t-depends/pkg-version-2/DEBIAN/control
new file mode 100644
index 0000000..1aff119
--- /dev/null
+++ b/tests/t-depends/pkg-version-2/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-version
+Version: 2
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - real package to depend on a specific version
diff --git a/tests/t-depends/pkg-version-3/DEBIAN/control b/tests/t-depends/pkg-version-3/DEBIAN/control
new file mode 100644
index 0000000..322945a
--- /dev/null
+++ b/tests/t-depends/pkg-version-3/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-version
+Version: 3
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - real package to depend on a specific version
diff --git a/tests/t-dir-extension-check/Makefile b/tests/t-dir-extension-check/Makefile
new file mode 100644
index 0000000..2cbc250
--- /dev/null
+++ b/tests/t-dir-extension-check/Makefile
@@ -0,0 +1,10 @@
+TESTS_DEB := pkg-dbg-dir
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) -D10 pkg-dbg-dir.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-dbg-dir
+
diff --git a/tests/t-dir-extension-check/pkg-dbg-dir/DEBIAN/control b/tests/t-dir-extension-check/pkg-dbg-dir/DEBIAN/control
new file mode 100644
index 0000000..743b4c2
--- /dev/null
+++ b/tests/t-dir-extension-check/pkg-dbg-dir/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-dbg-dir
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - weird dbg output with dir
+ bug 80416
+
diff --git a/tests/t-dir-extension-check/pkg-dbg-dir/test-dir/.keep b/tests/t-dir-extension-check/pkg-dbg-dir/test-dir/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-dir-extension-check/pkg-dbg-dir/test-dir/.keep
diff --git a/tests/t-dir-extension-check/pkg-dbg-dir/test-file b/tests/t-dir-extension-check/pkg-dbg-dir/test-file
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-dir-extension-check/pkg-dbg-dir/test-file
diff --git a/tests/t-dir-leftover-conffile/Makefile b/tests/t-dir-leftover-conffile/Makefile
new file mode 100644
index 0000000..28ac9e9
--- /dev/null
+++ b/tests/t-dir-leftover-conffile/Makefile
@@ -0,0 +1,13 @@
+TESTS_DEB := pkg-dir-leftover-conffile
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-dir-leftover-conffile.deb
+ $(DPKG_REMOVE) pkg-dir-leftover-conffile
+ $(DPKG_PURGE) pkg-dir-leftover-conffile
+ test ! -d '$(DPKG_INSTDIR)/test-dir'
+
+test-clean:
+ $(DPKG_PURGE) pkg-dir-leftover-conffile
+ $(BEROOT) rm -rf '$(DPKG_INSTDIR)/test-dir'
diff --git a/tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/DEBIAN/conffiles b/tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/DEBIAN/conffiles
new file mode 100644
index 0000000..6d57c35
--- /dev/null
+++ b/tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-dir/test-conffile
diff --git a/tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/DEBIAN/control b/tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/DEBIAN/control
new file mode 100644
index 0000000..74e2a00
--- /dev/null
+++ b/tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-leftover-conffile
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - shared directory with configuration file
diff --git a/tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/test-dir/test-conffile b/tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/test-dir/test-conffile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-dir-leftover-conffile/pkg-dir-leftover-conffile/test-dir/test-conffile
diff --git a/tests/t-dir-leftover-deadlock/Makefile b/tests/t-dir-leftover-deadlock/Makefile
new file mode 100644
index 0000000..e0f381f
--- /dev/null
+++ b/tests/t-dir-leftover-deadlock/Makefile
@@ -0,0 +1,17 @@
+TESTS_DEB := pkg-dir-shared-0 pkg-dir-shared-1
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-dir-shared-0.deb
+ $(DPKG_INSTALL) pkg-dir-shared-1.deb
+ $(DPKG_REMOVE) pkg-dir-shared-1
+ $(DPKG_REMOVE) pkg-dir-shared-0
+ $(DPKG_PURGE) pkg-dir-shared-0
+ $(DPKG_PURGE) pkg-dir-shared-1
+ test ! -d '$(DPKG_INSTDIR)/test-dir'
+
+test-clean:
+ $(DPKG_PURGE) pkg-dir-shared-0
+ $(DPKG_PURGE) pkg-dir-shared-1
+ $(BEROOT) rm -rf '$(DPKG_INSTDIR)/test-dir'
diff --git a/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/control b/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/control
new file mode 100644
index 0000000..90e43b9
--- /dev/null
+++ b/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-shared-0
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - shared directory with configuration file
diff --git a/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/postinst b/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/postinst
new file mode 100755
index 0000000..328e575
--- /dev/null
+++ b/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/postinst
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+case "$1" in
+configure)
+ touch "$DPKG_ROOT/test-dir/test-config-0"
+ ;;
+esac
diff --git a/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/postrm b/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/postrm
new file mode 100755
index 0000000..1a1e745
--- /dev/null
+++ b/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/DEBIAN/postrm
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+case "$1" in
+purge)
+ rm "$DPKG_ROOT/test-dir/test-config-0"
+ ;;
+esac
diff --git a/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/test-dir/.keep0 b/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/test-dir/.keep0
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-dir-leftover-deadlock/pkg-dir-shared-0/test-dir/.keep0
diff --git a/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/control b/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/control
new file mode 100644
index 0000000..2d6750e
--- /dev/null
+++ b/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-dir-shared-1
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-dir-shared-0
+Description: test package - shared directory with configuration file
diff --git a/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/postinst b/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/postinst
new file mode 100755
index 0000000..ba38c67
--- /dev/null
+++ b/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/postinst
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+case "$1" in
+configure)
+ touch "$DPKG_ROOT/test-dir/test-config-1"
+ ;;
+esac
diff --git a/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/postrm b/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/postrm
new file mode 100755
index 0000000..3358b37
--- /dev/null
+++ b/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/DEBIAN/postrm
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+case "$1" in
+purge)
+ rm "$DPKG_ROOT/test-dir/test-config-1"
+ ;;
+esac
diff --git a/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/test-dir/.keep1 b/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/test-dir/.keep1
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-dir-leftover-deadlock/pkg-dir-shared-1/test-dir/.keep1
diff --git a/tests/t-dir-leftover-parents/Makefile b/tests/t-dir-leftover-parents/Makefile
new file mode 100644
index 0000000..35e2718
--- /dev/null
+++ b/tests/t-dir-leftover-parents/Makefile
@@ -0,0 +1,16 @@
+TESTS_DEB := pkg-dir-shared pkg-dir-shared-notempty
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-dir-shared.deb
+ $(DPKG_INSTALL) pkg-dir-shared-notempty.deb
+ $(DPKG_REMOVE) pkg-dir-shared-notempty
+ $(DPKG_PURGE) pkg-dir-shared
+ $(DPKG_PURGE) pkg-dir-shared-notempty
+ test ! -d "$(DPKG_INSTDIR)/test-dir"
+
+test-clean:
+ $(DPKG_PURGE) pkg-dir-shared
+ $(DPKG_PURGE) pkg-dir-shared-notempty
+ $(BEROOT) rm -rf "$(DPKG_INSTDIR)/test-dir"
diff --git a/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/control b/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/control
new file mode 100644
index 0000000..e904178
--- /dev/null
+++ b/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-shared-notempty
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - shared directory with a config file
diff --git a/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/postinst b/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/postinst
new file mode 100755
index 0000000..d3cc9ef
--- /dev/null
+++ b/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/postinst
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+case "$1" in
+configure)
+ touch "$DPKG_ROOT/test-dir/subdir/subsubdir/file"
+ ;;
+esac
diff --git a/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/postrm b/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/postrm
new file mode 100755
index 0000000..7906c69
--- /dev/null
+++ b/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/DEBIAN/postrm
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+case "$1" in
+purge)
+ rm "$DPKG_ROOT/test-dir/subdir/subsubdir/file"
+ ;;
+esac
diff --git a/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/test-dir/subdir/subsubdir/.keep b/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/test-dir/subdir/subsubdir/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-dir-leftover-parents/pkg-dir-shared-notempty/test-dir/subdir/subsubdir/.keep
diff --git a/tests/t-dir-leftover-parents/pkg-dir-shared/DEBIAN/control b/tests/t-dir-leftover-parents/pkg-dir-shared/DEBIAN/control
new file mode 100644
index 0000000..03b3029
--- /dev/null
+++ b/tests/t-dir-leftover-parents/pkg-dir-shared/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-shared
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - shared directory
diff --git a/tests/t-dir-leftover-parents/pkg-dir-shared/test-dir/subdir/.keep b/tests/t-dir-leftover-parents/pkg-dir-shared/test-dir/subdir/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-dir-leftover-parents/pkg-dir-shared/test-dir/subdir/.keep
diff --git a/tests/t-dir-shared-replaces-lost/Makefile b/tests/t-dir-shared-replaces-lost/Makefile
new file mode 100644
index 0000000..17b2b26
--- /dev/null
+++ b/tests/t-dir-shared-replaces-lost/Makefile
@@ -0,0 +1,35 @@
+TESTS_DEB := pkg-dir-original pkg-dir-takeover
+
+include ../Test.mk
+
+TEST_CASES += test-ordered
+TEST_CASES += test-reverse
+
+test-case: $(TEST_CASES)
+
+define VERIFY
+$(call pkg_is_installed,pkg-dir-original)
+$(call pkg_is_installed,pkg-dir-takeover)
+test -d '$(DPKG_INSTDIR)/test-dir'
+test "`$(DPKG_QUERY) -S /test-dir/test-original`" = "pkg-dir-original: /test-dir/test-original"
+test "`$(DPKG_QUERY) -S /test-dir/test-takeover`" = "pkg-dir-takeover: /test-dir/test-takeover"
+endef
+
+test-ordered:
+ # test-ordered
+ $(DPKG_INSTALL) pkg-dir-original.deb
+ $(BEROOT) rm -rf '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_INSTALL) pkg-dir-takeover.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-dir-original pkg-dir-takeover
+
+test-reverse:
+ # test-reverse
+ $(DPKG_INSTALL) pkg-dir-takeover.deb
+ $(BEROOT) rm -rf '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_INSTALL) pkg-dir-original.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-dir-original pkg-dir-takeover
+
+test-clean:
+ -$(DPKG_PURGE) pkg-dir-original pkg-dir-takeover
diff --git a/tests/t-dir-shared-replaces-lost/pkg-dir-original/DEBIAN/control b/tests/t-dir-shared-replaces-lost/pkg-dir-original/DEBIAN/control
new file mode 100644
index 0000000..9bb5a2e
--- /dev/null
+++ b/tests/t-dir-shared-replaces-lost/pkg-dir-original/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-original
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide a shared directory
diff --git a/tests/t-dir-shared-replaces-lost/pkg-dir-original/test-dir/test-original b/tests/t-dir-shared-replaces-lost/pkg-dir-original/test-dir/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-dir-shared-replaces-lost/pkg-dir-original/test-dir/test-original
diff --git a/tests/t-dir-shared-replaces-lost/pkg-dir-takeover/DEBIAN/control b/tests/t-dir-shared-replaces-lost/pkg-dir-takeover/DEBIAN/control
new file mode 100644
index 0000000..a9a2a34
--- /dev/null
+++ b/tests/t-dir-shared-replaces-lost/pkg-dir-takeover/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-dir-takeover
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-dir-original
+Description: test package - dir replaces takeover
diff --git a/tests/t-dir-shared-replaces-lost/pkg-dir-takeover/test-dir/test-takeover b/tests/t-dir-shared-replaces-lost/pkg-dir-takeover/test-dir/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-dir-shared-replaces-lost/pkg-dir-takeover/test-dir/test-takeover
diff --git a/tests/t-disappear-depended/Makefile b/tests/t-disappear-depended/Makefile
new file mode 100644
index 0000000..f7b8362
--- /dev/null
+++ b/tests/t-disappear-depended/Makefile
@@ -0,0 +1,21 @@
+TESTS_DEB := pkg-normal pkg-depend pkg-disappear
+
+include ../Test.mk
+
+test-case:
+ # test disappearing depended package
+ $(DPKG_INSTALL) pkg-disappear.deb
+ $(DPKG_INSTALL) pkg-depend.deb
+ $(DPKG_INSTALL) pkg-normal.deb
+ # should not disappear while it's being depended on
+ $(call pkg_is_installed,pkg-disappear)
+ $(DPKG_PURGE) pkg-depend
+ $(DPKG_INSTALL) pkg-normal.deb
+ # should have been disappered now
+ $(call pkg_is_not_installed,pkg-disappear)
+
+test-clean:
+ -$(DPKG_PURGE) pkg-depend
+ -$(DPKG_PURGE) pkg-disappear
+ $(DPKG_PURGE) pkg-normal
+
diff --git a/tests/t-disappear-depended/pkg-depend/DEBIAN/control b/tests/t-disappear-depended/pkg-depend/DEBIAN/control
new file mode 100644
index 0000000..d39c783
--- /dev/null
+++ b/tests/t-disappear-depended/pkg-depend/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-depend
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-disappear
+Description: test package - depend on disappearing package
+
diff --git a/tests/t-disappear-depended/pkg-disappear/DEBIAN/control b/tests/t-disappear-depended/pkg-disappear/DEBIAN/control
new file mode 100644
index 0000000..78c2a17
--- /dev/null
+++ b/tests/t-disappear-depended/pkg-disappear/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-disappear
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - disappear
+
diff --git a/tests/t-disappear-depended/pkg-normal/DEBIAN/control b/tests/t-disappear-depended/pkg-normal/DEBIAN/control
new file mode 100644
index 0000000..09e51b2
--- /dev/null
+++ b/tests/t-disappear-depended/pkg-normal/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-normal
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - normal
+
diff --git a/tests/t-disappear-depended/pkg-normal/test-dir/test-normal b/tests/t-disappear-depended/pkg-normal/test-dir/test-normal
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-disappear-depended/pkg-normal/test-dir/test-normal
diff --git a/tests/t-disappear-empty/Makefile b/tests/t-disappear-empty/Makefile
new file mode 100644
index 0000000..66d5c3f
--- /dev/null
+++ b/tests/t-disappear-empty/Makefile
@@ -0,0 +1,16 @@
+TESTS_DEB := pkg-normal pkg-disappear-0 pkg-disappear-1
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-disappear-0.deb
+ # test that an upgraded empty package does not get disappeared
+ $(DPKG_INSTALL) pkg-disappear-1.deb
+ $(call pkg_is_installed,pkg-disappear)
+ $(DPKG_INSTALL) pkg-normal.deb
+ $(call pkg_is_installed,pkg-normal)
+
+test-clean:
+ $(DPKG_PURGE) pkg-disappear
+ $(DPKG_PURGE) pkg-normal
+
diff --git a/tests/t-disappear-empty/pkg-disappear-0/DEBIAN/control b/tests/t-disappear-empty/pkg-disappear-0/DEBIAN/control
new file mode 100644
index 0000000..78c2a17
--- /dev/null
+++ b/tests/t-disappear-empty/pkg-disappear-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-disappear
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - disappear
+
diff --git a/tests/t-disappear-empty/pkg-disappear-0/test-dir/test-disappear b/tests/t-disappear-empty/pkg-disappear-0/test-dir/test-disappear
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-disappear-empty/pkg-disappear-0/test-dir/test-disappear
diff --git a/tests/t-disappear-empty/pkg-disappear-1/DEBIAN/control b/tests/t-disappear-empty/pkg-disappear-1/DEBIAN/control
new file mode 100644
index 0000000..7949c6e
--- /dev/null
+++ b/tests/t-disappear-empty/pkg-disappear-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-disappear
+Version: 0.0-2
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - disappear
+
diff --git a/tests/t-disappear-empty/pkg-normal/DEBIAN/control b/tests/t-disappear-empty/pkg-normal/DEBIAN/control
new file mode 100644
index 0000000..4e2f9a3
--- /dev/null
+++ b/tests/t-disappear-empty/pkg-normal/DEBIAN/control
@@ -0,0 +1,10 @@
+Package: pkg-normal
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-disappear
+Provides: pkg-disappear
+Description: test package - normal
+
diff --git a/tests/t-disappear-empty/pkg-normal/test-dir/test-normal b/tests/t-disappear-empty/pkg-normal/test-dir/test-normal
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-disappear-empty/pkg-normal/test-dir/test-normal
diff --git a/tests/t-disappear/Makefile b/tests/t-disappear/Makefile
new file mode 100644
index 0000000..573c334
--- /dev/null
+++ b/tests/t-disappear/Makefile
@@ -0,0 +1,14 @@
+TESTS_DEB := pkg-normal pkg-disappear-0 pkg-disappear-1
+
+include ../Test.mk
+
+test-case:
+ # test disappearing package
+ $(DPKG_INSTALL) pkg-disappear-0.deb
+ $(DPKG_INSTALL) pkg-disappear-1.deb
+ $(DPKG_INSTALL) pkg-normal.deb
+
+test-clean:
+ -$(DPKG_PURGE) pkg-disappear
+ $(DPKG_PURGE) pkg-normal
+
diff --git a/tests/t-disappear/pkg-disappear-0/DEBIAN/control b/tests/t-disappear/pkg-disappear-0/DEBIAN/control
new file mode 100644
index 0000000..78c2a17
--- /dev/null
+++ b/tests/t-disappear/pkg-disappear-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-disappear
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - disappear
+
diff --git a/tests/t-disappear/pkg-disappear-0/test-dir/test-disappear b/tests/t-disappear/pkg-disappear-0/test-dir/test-disappear
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-disappear/pkg-disappear-0/test-dir/test-disappear
diff --git a/tests/t-disappear/pkg-disappear-1/DEBIAN/control b/tests/t-disappear/pkg-disappear-1/DEBIAN/control
new file mode 100644
index 0000000..7949c6e
--- /dev/null
+++ b/tests/t-disappear/pkg-disappear-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-disappear
+Version: 0.0-2
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - disappear
+
diff --git a/tests/t-disappear/pkg-normal/DEBIAN/control b/tests/t-disappear/pkg-normal/DEBIAN/control
new file mode 100644
index 0000000..09e51b2
--- /dev/null
+++ b/tests/t-disappear/pkg-normal/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-normal
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - normal
+
diff --git a/tests/t-disappear/pkg-normal/test-dir/test-normal b/tests/t-disappear/pkg-normal/test-dir/test-normal
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-disappear/pkg-normal/test-dir/test-normal
diff --git a/tests/t-failinst-failrm/Makefile b/tests/t-failinst-failrm/Makefile
new file mode 100644
index 0000000..325c7ef
--- /dev/null
+++ b/tests/t-failinst-failrm/Makefile
@@ -0,0 +1,12 @@
+TESTS_DEB := pkg-failinst-failrm-0 pkg-failinst-failrm-1
+
+include ../Test.mk
+
+test-case:
+ -$(DPKG_INSTALL) pkg-failinst-failrm-0.deb
+ $(call pkg_status_is,pkg-failinst-failrm,install ok half-configured)
+
+test-clean:
+ # Upgrade to a working version to allow the purge.
+ -$(DPKG_INSTALL) pkg-failinst-failrm-1.deb
+ $(DPKG_PURGE) pkg-failinst-failrm
diff --git a/tests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/control b/tests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/control
new file mode 100644
index 0000000..1230320
--- /dev/null
+++ b/tests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-failinst-failrm
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - #432893
+ postinst-fail
+ prerm-fail
diff --git a/tests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/postinst b/tests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/postinst
new file mode 100755
index 0000000..b35b197
--- /dev/null
+++ b/tests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/postinst
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+case "$1" in
+ configure)
+ exit 1
+ ;;
+ abort-upgrade|abort-deconfigure|abort-remove)
+ ;;
+ *)
+ echo "$0 called with unknown argument '$1'" 1>&2
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/prerm b/tests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/prerm
new file mode 100755
index 0000000..0abf6fb
--- /dev/null
+++ b/tests/t-failinst-failrm/pkg-failinst-failrm-0/DEBIAN/prerm
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+case "$1" in
+ remove)
+ exit 1
+ ;;
+ purge|upgrade|failed-upgrade|disappear|abort-install|abort-upgrade)
+ ;;
+ *)
+ echo "$0 called with unknown argument '$1'" 1>&2
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-failinst-failrm/pkg-failinst-failrm-1/DEBIAN/control b/tests/t-failinst-failrm/pkg-failinst-failrm-1/DEBIAN/control
new file mode 100644
index 0000000..1709965
--- /dev/null
+++ b/tests/t-failinst-failrm/pkg-failinst-failrm-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-failinst-failrm
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - non-broken package to allow purge
diff --git a/tests/t-field-priority/Makefile b/tests/t-field-priority/Makefile
new file mode 100644
index 0000000..08239e7
--- /dev/null
+++ b/tests/t-field-priority/Makefile
@@ -0,0 +1,12 @@
+TESTS_DEB := pkg-priority
+
+include ../Test.mk
+
+test-case:
+ # test for unknown priority values
+ $(DPKG_INSTALL) pkg-priority.deb
+ $(call pkg_is_installed,pkg-priority)
+ $(call pkg_field_is,pkg-priority,Priority,value not known)
+
+test-clean:
+ $(DPKG_PURGE) pkg-priority
diff --git a/tests/t-field-priority/pkg-priority/DEBIAN/control b/tests/t-field-priority/pkg-priority/DEBIAN/control
new file mode 100644
index 0000000..f06c05c
--- /dev/null
+++ b/tests/t-field-priority/pkg-priority/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-priority
+Version: 0.0-1
+Section: test
+Priority: value not known
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - unknown priority value
diff --git a/tests/t-file-conflicts/Makefile b/tests/t-file-conflicts/Makefile
new file mode 100644
index 0000000..4eeb0f5
--- /dev/null
+++ b/tests/t-file-conflicts/Makefile
@@ -0,0 +1,15 @@
+TESTS_DEB := pkg-a pkg-b
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-a.deb
+ # test if the conflicting package fails on install
+ ! $(DPKG_INSTALL) pkg-b.deb
+
+test-clean:
+ # tell dpkg we do not want pkg-b, even if we asked for it and failed
+ echo pkg-b purge | $(BEROOT) $(DPKG) --set-selections
+ -$(DPKG_PURGE) pkg-b
+ $(DPKG_PURGE) pkg-a
+
diff --git a/tests/t-file-conflicts/pkg-a/DEBIAN/control b/tests/t-file-conflicts/pkg-a/DEBIAN/control
new file mode 100644
index 0000000..7bf61bb
--- /dev/null
+++ b/tests/t-file-conflicts/pkg-a/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conflicting file
+
diff --git a/tests/t-file-conflicts/pkg-a/test-conflict b/tests/t-file-conflicts/pkg-a/test-conflict
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-file-conflicts/pkg-a/test-conflict
diff --git a/tests/t-file-conflicts/pkg-b/DEBIAN/control b/tests/t-file-conflicts/pkg-b/DEBIAN/control
new file mode 100644
index 0000000..135098a
--- /dev/null
+++ b/tests/t-file-conflicts/pkg-b/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - conflicting file
+
diff --git a/tests/t-file-conflicts/pkg-b/test-conflict b/tests/t-file-conflicts/pkg-b/test-conflict
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-file-conflicts/pkg-b/test-conflict
diff --git a/tests/t-file-replaces-disappear/Makefile b/tests/t-file-replaces-disappear/Makefile
new file mode 100644
index 0000000..719f02b
--- /dev/null
+++ b/tests/t-file-replaces-disappear/Makefile
@@ -0,0 +1,65 @@
+TESTS_DEB := pkg-file-original pkg-file-takeover
+
+include ../Test.mk
+
+TEST_CASES += test-two-run-ordered
+TEST_CASES += test-one-run-ordered
+TEST_CASES += test-two-run-reverse
+TEST_CASES += test-one-run-reverse
+
+test-case: $(TEST_CASES)
+
+define VERIFY
+$(call pkg_is_installed,pkg-file-takeover)
+test "`$(DPKG_QUERY) -S /test-file`" = "pkg-file-takeover: /test-file"
+test "`$(DPKG_QUERY) -S /test-other`" = "pkg-file-takeover: /test-other"
+cmp ref-file "$(DPKG_INSTDIR)/test-file"
+cmp ref-file "$(DPKG_INSTDIR)/test-other"
+endef
+
+test-two-run-ordered:
+ # test-two-run-ordered
+ $(DPKG_INSTALL) pkg-file-original.deb
+ $(DPKG_INSTALL) pkg-file-takeover.deb
+ $(call pkg_is_not_installed,pkg-file-original)
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
+ test ! -f "$(DPKG_INSTDIR)/test-file"
+ test ! -f "$(DPKG_INSTDIR)/test-other"
+
+test-one-run-ordered:
+ # test-one-run-ordered
+ $(DPKG_INSTALL) pkg-file-original.deb pkg-file-takeover.deb
+ $(call pkg_is_not_installed,pkg-file-original)
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
+ test ! -f "$(DPKG_INSTDIR)/test-file"
+ test ! -f "$(DPKG_INSTDIR)/test-other"
+
+test-two-run-reverse:
+ # test-two-run-reverse
+ $(DPKG_INSTALL) pkg-file-takeover.deb
+ $(DPKG_INSTALL) pkg-file-original.deb
+ $(call pkg_is_installed,pkg-file-original)
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original
+ test -f "$(DPKG_INSTDIR)/test-file"
+ test -f "$(DPKG_INSTDIR)/test-other"
+ $(DPKG_PURGE) pkg-file-takeover
+ test ! -f "$(DPKG_INSTDIR)/test-file"
+ test ! -f "$(DPKG_INSTDIR)/test-other"
+
+test-one-run-reverse:
+ # test-one-run-reverse
+ $(DPKG_INSTALL) pkg-file-takeover.deb pkg-file-original.deb
+ $(call pkg_is_installed,pkg-file-original)
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original
+ test -f "$(DPKG_INSTDIR)/test-file"
+ test -f "$(DPKG_INSTDIR)/test-other"
+ $(DPKG_PURGE) pkg-file-takeover
+ test ! -f "$(DPKG_INSTDIR)/test-file"
+ test ! -f "$(DPKG_INSTDIR)/test-other"
+
+test-clean:
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
diff --git a/tests/t-file-replaces-disappear/pkg-file-original/DEBIAN/control b/tests/t-file-replaces-disappear/pkg-file-original/DEBIAN/control
new file mode 100644
index 0000000..4dae80f
--- /dev/null
+++ b/tests/t-file-replaces-disappear/pkg-file-original/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-file-original
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide some files
+
diff --git a/tests/t-file-replaces-disappear/pkg-file-original/test-file b/tests/t-file-replaces-disappear/pkg-file-original/test-file
new file mode 100644
index 0000000..7e3c47b
--- /dev/null
+++ b/tests/t-file-replaces-disappear/pkg-file-original/test-file
@@ -0,0 +1 @@
+test original
diff --git a/tests/t-file-replaces-disappear/pkg-file-original/test-other b/tests/t-file-replaces-disappear/pkg-file-original/test-other
new file mode 100644
index 0000000..7e3c47b
--- /dev/null
+++ b/tests/t-file-replaces-disappear/pkg-file-original/test-other
@@ -0,0 +1 @@
+test original
diff --git a/tests/t-file-replaces-disappear/pkg-file-takeover/DEBIAN/control b/tests/t-file-replaces-disappear/pkg-file-takeover/DEBIAN/control
new file mode 100644
index 0000000..6af91c8
--- /dev/null
+++ b/tests/t-file-replaces-disappear/pkg-file-takeover/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-file-takeover
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-file-original
+Description: test package - file replaces takeover
+
diff --git a/tests/t-file-replaces-disappear/pkg-file-takeover/test-file b/tests/t-file-replaces-disappear/pkg-file-takeover/test-file
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-file-replaces-disappear/pkg-file-takeover/test-file
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-file-replaces-disappear/pkg-file-takeover/test-other b/tests/t-file-replaces-disappear/pkg-file-takeover/test-other
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-file-replaces-disappear/pkg-file-takeover/test-other
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-file-replaces-disappear/ref-file b/tests/t-file-replaces-disappear/ref-file
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-file-replaces-disappear/ref-file
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-file-replaces-versioned/Makefile b/tests/t-file-replaces-versioned/Makefile
new file mode 100644
index 0000000..248ca18
--- /dev/null
+++ b/tests/t-file-replaces-versioned/Makefile
@@ -0,0 +1,52 @@
+TESTS_DEB := pkg-file-original-0 pkg-file-original-1 \
+ pkg-file-takeover-0 pkg-file-takeover-1
+
+include ../Test.mk
+
+TEST_CASES += test-two-run-ordered
+TEST_CASES += test-one-run-ordered
+TEST_CASES += test-two-run-reverse
+TEST_CASES += test-one-run-reverse
+
+test-case: $(TEST_CASES)
+
+define VERIFY
+$(call pkg_is_installed,pkg-file-original)
+$(call pkg_is_installed,pkg-file-takeover)
+test "`$(DPKG_QUERY) -S /test-file`" = "pkg-file-takeover: /test-file"
+cmp ref-file "$(DPKG_INSTDIR)/test-file"
+endef
+
+test-two-run-ordered:
+ # test-two-run-ordered
+ $(DPKG_INSTALL) pkg-file-original-0.deb pkg-file-takeover-0.deb
+ $(DPKG_INSTALL) pkg-file-original-1.deb
+ $(DPKG_INSTALL) pkg-file-takeover-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
+
+test-one-run-ordered:
+ # test-one-run-ordered
+ $(DPKG_INSTALL) pkg-file-original-0.deb pkg-file-takeover-0.deb
+ $(DPKG_INSTALL) pkg-file-original-1.deb pkg-file-takeover-1.deb
+ $(DPKG_CONFIGURE) -a
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
+
+test-two-run-reverse:
+ # test-two-run-reverse
+ $(DPKG_INSTALL) pkg-file-original-0.deb pkg-file-takeover-0.deb
+ $(DPKG_INSTALL) pkg-file-takeover-1.deb
+ $(DPKG_INSTALL) pkg-file-original-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
+
+test-one-run-reverse:
+ # test-one-run-reverse
+ $(DPKG_INSTALL) pkg-file-original-0.deb pkg-file-takeover-0.deb
+ $(DPKG_INSTALL) pkg-file-takeover-1.deb pkg-file-original-1.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
+
+test-clean:
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
diff --git a/tests/t-file-replaces-versioned/pkg-file-original-0/DEBIAN/control b/tests/t-file-replaces-versioned/pkg-file-original-0/DEBIAN/control
new file mode 100644
index 0000000..93bb772
--- /dev/null
+++ b/tests/t-file-replaces-versioned/pkg-file-original-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-file-original
+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-file-replaces-versioned/pkg-file-original-0/test-file b/tests/t-file-replaces-versioned/pkg-file-original-0/test-file
new file mode 100644
index 0000000..7e3c47b
--- /dev/null
+++ b/tests/t-file-replaces-versioned/pkg-file-original-0/test-file
@@ -0,0 +1 @@
+test original
diff --git a/tests/t-file-replaces-versioned/pkg-file-original-0/test-original b/tests/t-file-replaces-versioned/pkg-file-original-0/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-file-replaces-versioned/pkg-file-original-0/test-original
diff --git a/tests/t-file-replaces-versioned/pkg-file-original-1/DEBIAN/control b/tests/t-file-replaces-versioned/pkg-file-original-1/DEBIAN/control
new file mode 100644
index 0000000..8c5a742
--- /dev/null
+++ b/tests/t-file-replaces-versioned/pkg-file-original-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-file-original
+Version: 1
+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-file-replaces-versioned/pkg-file-original-1/test-original b/tests/t-file-replaces-versioned/pkg-file-original-1/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-file-replaces-versioned/pkg-file-original-1/test-original
diff --git a/tests/t-file-replaces-versioned/pkg-file-takeover-0/DEBIAN/control b/tests/t-file-replaces-versioned/pkg-file-takeover-0/DEBIAN/control
new file mode 100644
index 0000000..913a3a8
--- /dev/null
+++ b/tests/t-file-replaces-versioned/pkg-file-takeover-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-file-takeover
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - future file replaces takeover
diff --git a/tests/t-file-replaces-versioned/pkg-file-takeover-0/test-takeover b/tests/t-file-replaces-versioned/pkg-file-takeover-0/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-file-replaces-versioned/pkg-file-takeover-0/test-takeover
diff --git a/tests/t-file-replaces-versioned/pkg-file-takeover-1/DEBIAN/control b/tests/t-file-replaces-versioned/pkg-file-takeover-1/DEBIAN/control
new file mode 100644
index 0000000..4c130a9
--- /dev/null
+++ b/tests/t-file-replaces-versioned/pkg-file-takeover-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-file-takeover
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-file-original (<< 1)
+Description: test package - file replaces takeover
diff --git a/tests/t-file-replaces-versioned/pkg-file-takeover-1/test-file b/tests/t-file-replaces-versioned/pkg-file-takeover-1/test-file
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-file-replaces-versioned/pkg-file-takeover-1/test-file
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-file-replaces-versioned/pkg-file-takeover-1/test-takeover b/tests/t-file-replaces-versioned/pkg-file-takeover-1/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-file-replaces-versioned/pkg-file-takeover-1/test-takeover
diff --git a/tests/t-file-replaces-versioned/ref-file b/tests/t-file-replaces-versioned/ref-file
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-file-replaces-versioned/ref-file
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-file-replaces/Makefile b/tests/t-file-replaces/Makefile
new file mode 100644
index 0000000..6c67d75
--- /dev/null
+++ b/tests/t-file-replaces/Makefile
@@ -0,0 +1,44 @@
+TESTS_DEB := pkg-file-original pkg-file-takeover
+
+include ../Test.mk
+
+TEST_CASES += test-two-run-ordered
+TEST_CASES += test-one-run-ordered
+TEST_CASES += test-two-run-reverse
+TEST_CASES += test-one-run-reverse
+
+test-case: $(TEST_CASES)
+
+define VERIFY
+$(call pkg_is_installed,pkg-file-original)
+$(call pkg_is_installed,pkg-file-takeover)
+test "`$(DPKG_QUERY) -S /test-file`" = "pkg-file-takeover: /test-file"
+cmp ref-file "$(DPKG_INSTDIR)/test-file"
+endef
+
+test-two-run-ordered:
+ # test-two-run-ordered
+ $(DPKG_INSTALL) pkg-file-original.deb
+ $(DPKG_INSTALL) pkg-file-takeover.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
+
+test-one-run-ordered:
+ # test-one-run-ordered
+ $(DPKG_INSTALL) pkg-file-original.deb pkg-file-takeover.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
+
+test-two-run-reverse:
+ # test-two-run-reverse
+ $(DPKG_INSTALL) pkg-file-takeover.deb
+ $(DPKG_INSTALL) pkg-file-original.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
+
+test-one-run-reverse:
+ # test-one-run-reverse
+ $(DPKG_INSTALL) pkg-file-takeover.deb pkg-file-original.deb
+ $(VERIFY)
+ $(DPKG_PURGE) pkg-file-original pkg-file-takeover
+
diff --git a/tests/t-file-replaces/pkg-file-original/DEBIAN/control b/tests/t-file-replaces/pkg-file-original/DEBIAN/control
new file mode 100644
index 0000000..305534f
--- /dev/null
+++ b/tests/t-file-replaces/pkg-file-original/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-file-original
+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-file-replaces/pkg-file-original/test-file b/tests/t-file-replaces/pkg-file-original/test-file
new file mode 100644
index 0000000..7e3c47b
--- /dev/null
+++ b/tests/t-file-replaces/pkg-file-original/test-file
@@ -0,0 +1 @@
+test original
diff --git a/tests/t-file-replaces/pkg-file-original/test-original b/tests/t-file-replaces/pkg-file-original/test-original
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-file-replaces/pkg-file-original/test-original
diff --git a/tests/t-file-replaces/pkg-file-takeover/DEBIAN/control b/tests/t-file-replaces/pkg-file-takeover/DEBIAN/control
new file mode 100644
index 0000000..6af91c8
--- /dev/null
+++ b/tests/t-file-replaces/pkg-file-takeover/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-file-takeover
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Replaces: pkg-file-original
+Description: test package - file replaces takeover
+
diff --git a/tests/t-file-replaces/pkg-file-takeover/test-file b/tests/t-file-replaces/pkg-file-takeover/test-file
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-file-replaces/pkg-file-takeover/test-file
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-file-replaces/pkg-file-takeover/test-takeover b/tests/t-file-replaces/pkg-file-takeover/test-takeover
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-file-replaces/pkg-file-takeover/test-takeover
diff --git a/tests/t-file-replaces/ref-file b/tests/t-file-replaces/ref-file
new file mode 100644
index 0000000..82fe7fe
--- /dev/null
+++ b/tests/t-file-replaces/ref-file
@@ -0,0 +1 @@
+test takeover
diff --git a/tests/t-filtering/Makefile b/tests/t-filtering/Makefile
new file mode 100644
index 0000000..63c6ad2
--- /dev/null
+++ b/tests/t-filtering/Makefile
@@ -0,0 +1,166 @@
+TESTS_DEB := pkg-somefiles
+
+include ../Test.mk
+
+DEB_FILES_COUNT = $(shell dpkg-deb -c pkg-somefiles.deb | wc -l )
+
+TEST_CASES += test-no-filter
+TEST_CASES += test-no-doc-sub
+TEST_CASES += test-no-doc-all
+TEST_CASES += test-no-doc-except-copyright
+TEST_CASES += test-no-doc-except-copyright-subdir
+TEST_CASES += test-no-doc-except-copyright-and-readme
+TEST_CASES += test-include-only
+TEST_CASES += test-reinclude-subdir
+TEST_CASES += test-same-include-exclude
+TEST_CASES += test-upgrade test-help
+
+test-case: $(TEST_CASES)
+
+test-clean:
+ $(DPKG_PURGE) pkg-somefiles
+
+test-no-filter:
+ # no filter, should have all files
+ $(DPKG_INSTALL) pkg-somefiles.deb
+ test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = $(DEB_FILES_COUNT)
+ $(DPKG_PURGE) pkg-somefiles
+
+test-no-doc-sub:
+ # filter out /test/share/doc/*/*; this keeps the actual
+ # /test/share/doc/pkg-somefiles dir around
+ $(DPKG_INSTALL) \
+ --path-exclude '/test/share/doc/*/*' \
+ pkg-somefiles.deb
+ test -d "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles"
+ test "`ls '$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles'`" = ""
+ test -f "$(DPKG_INSTDIR)/test/lib/pkg-somefiles/run"
+ $(DPKG_PURGE) pkg-somefiles
+
+test-no-doc-all:
+ # filter out /test/share/doc/*
+ $(DPKG_INSTALL) \
+ --path-exclude '/test/share/doc/*' \
+ pkg-somefiles.deb
+ ! test -d "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles"
+ test -f "$(DPKG_INSTDIR)/test/lib/pkg-somefiles/run"
+ $(DPKG_PURGE) pkg-somefiles
+
+test-no-doc-except-copyright:
+ # filter out /test/share/doc/*/* except copyright
+ $(DPKG_INSTALL) \
+ --path-exclude '/test/share/doc/*/*' \
+ --path-include '/test/share/doc/*/copyright' \
+ pkg-somefiles.deb
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/copyright"
+ ! test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/html/index.html"
+ ! test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/README"
+ test -f "$(DPKG_INSTDIR)/test/lib/pkg-somefiles/run"
+ $(DPKG_PURGE) pkg-somefiles
+
+test-no-doc-except-copyright-subdir:
+ # prune the entire doc dir; this triggers the special case that
+ # /test/share/doc/pkg-somefiles is matched by the exclude, but still
+ # needs to be created due to the following include
+ $(DPKG_INSTALL) \
+ --path-exclude '/test/share/doc/*' \
+ --path-include '/test/share/doc/*/copyright' \
+ pkg-somefiles.deb
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/copyright"
+ ! test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/html/index.html"
+ ! test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/README"
+ test -f "$(DPKG_INSTDIR)/test/lib/pkg-somefiles/run"
+ $(DPKG_PURGE) pkg-somefiles
+
+test-no-doc-except-copyright-and-readme:
+ # two includes which revert an exclude, second of which matches
+ # several subdirs with one *
+ $(DPKG_INSTALL) \
+ --path-exclude '/test/share/doc/*' \
+ --path-include '/test/share/doc/*/copyright' \
+ --path-include '/test*/READ*' \
+ pkg-somefiles.deb
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/copyright"
+ ! test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/html/index.html"
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/README"
+ test -f "$(DPKG_INSTDIR)/test/lib/pkg-somefiles/run"
+ $(DPKG_PURGE) pkg-somefiles
+
+test-include-only:
+ # only includes, should be a no-op and have all files
+ $(DPKG_INSTALL) \
+ --path-include '/test/*' \
+ --path-include '/test/share/doc' \
+ --path-include '/test/lib/*/*' \
+ pkg-somefiles.deb
+ test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = $(DEB_FILES_COUNT)
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/copyright"
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/html/index.html"
+ test -f "$(DPKG_INSTDIR)/test/lib/pkg-somefiles/run"
+ $(DPKG_PURGE) pkg-somefiles
+
+test-reinclude-subdir:
+ # Exclude a directory tree and reinclude some of its subdirectories
+ $(DPKG_INSTALL) \
+ --path-exclude '/test/share/locale/*' \
+ --path-include '/test/share/locale/de/*' \
+ pkg-somefiles.deb
+ test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = $(DEB_FILES_COUNT)
+ test -d "$(DPKG_INSTDIR)/test/share/locale/de"
+ test -f "$(DPKG_INSTDIR)/test/share/locale/de/foo.mo"
+ ! test -f "$(DPKG_INSTDIR)/test/share/locale/ca/foo.mo"
+ ! test -f "$(DPKG_INSTDIR)/test/share/locale/es/foo.mo"
+ $(DPKG_PURGE) pkg-somefiles
+
+test-same-include-exclude:
+ # include the same things than exclude, should be a no-op and have
+ # all files
+ $(DPKG_INSTALL) \
+ --path-exclude '/test/share/*' \
+ --path-include '/test/share/*' \
+ pkg-somefiles.deb
+ test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = $(DEB_FILES_COUNT)
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/html/index.html"
+ test -f "$(DPKG_INSTDIR)/test/lib/pkg-somefiles/run"
+ $(DPKG_PURGE) pkg-somefiles
+
+ # now doubly so
+ $(DPKG_INSTALL) \
+ --path-exclude '/test/share/*' \
+ --path-include '/test/share/*' \
+ --path-exclude '/test/share/*' \
+ --path-include '/test/share/*' \
+ pkg-somefiles.deb
+ test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = $(DEB_FILES_COUNT)
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/html/index.html"
+ test -f "$(DPKG_INSTDIR)/test/lib/pkg-somefiles/run"
+ $(DPKG_PURGE) pkg-somefiles
+
+test-upgrade:
+ # files are removed/re-added on upgrades
+ $(DPKG_INSTALL) pkg-somefiles.deb
+ test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = $(DEB_FILES_COUNT)
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/copyright"
+
+ $(DPKG_INSTALL) \
+ --path-exclude '/test/share/doc/*' \
+ pkg-somefiles.deb
+ ! test -d "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles"
+
+ $(DPKG_INSTALL) \
+ --path-exclude '/test/share/doc/*' \
+ --path-include '/test/share/doc/*/copyright' \
+ pkg-somefiles.deb
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/copyright"
+ ! test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/README"
+
+ $(DPKG_INSTALL) pkg-somefiles.deb
+ test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = $(DEB_FILES_COUNT)
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/copyright"
+ test -f "$(DPKG_INSTDIR)/test/share/doc/pkg-somefiles/README"
+ $(DPKG_PURGE) pkg-somefiles
+
+# --help output explains the options
+test-help:
+ $(DPKG) --help | grep -q -- --path-include
+ $(DPKG) --help | grep -q -- --path-exclude
diff --git a/tests/t-filtering/pkg-somefiles/DEBIAN/control b/tests/t-filtering/pkg-somefiles/DEBIAN/control
new file mode 100644
index 0000000..f468c92
--- /dev/null
+++ b/tests/t-filtering/pkg-somefiles/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-somefiles
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide some files
+
diff --git a/tests/t-filtering/pkg-somefiles/test/lib/pkg-somefiles/run b/tests/t-filtering/pkg-somefiles/test/lib/pkg-somefiles/run
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-filtering/pkg-somefiles/test/lib/pkg-somefiles/run
diff --git a/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/README b/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/README
diff --git a/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/copyright b/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/copyright
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/copyright
diff --git a/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/html/index.html b/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/html/index.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/html/index.html
diff --git a/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/html/topic1/1.html b/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/html/topic1/1.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-filtering/pkg-somefiles/test/share/doc/pkg-somefiles/html/topic1/1.html
diff --git a/tests/t-filtering/pkg-somefiles/test/share/locale/ca/foo.mo b/tests/t-filtering/pkg-somefiles/test/share/locale/ca/foo.mo
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-filtering/pkg-somefiles/test/share/locale/ca/foo.mo
diff --git a/tests/t-filtering/pkg-somefiles/test/share/locale/de/foo.mo b/tests/t-filtering/pkg-somefiles/test/share/locale/de/foo.mo
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-filtering/pkg-somefiles/test/share/locale/de/foo.mo
diff --git a/tests/t-filtering/pkg-somefiles/test/share/locale/es/foo.mo b/tests/t-filtering/pkg-somefiles/test/share/locale/es/foo.mo
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-filtering/pkg-somefiles/test/share/locale/es/foo.mo
diff --git a/tests/t-maintscript-leak/Makefile b/tests/t-maintscript-leak/Makefile
new file mode 100644
index 0000000..c01646a
--- /dev/null
+++ b/tests/t-maintscript-leak/Makefile
@@ -0,0 +1,14 @@
+TESTS_DEB := pkg-maintscript-leak
+
+include ../Test.mk
+
+test-case:
+ # Check for leaks on install
+ $(DPKG_INSTALL) pkg-maintscript-leak.deb
+ # Check for leaks on upgrade
+ $(DPKG_INSTALL) pkg-maintscript-leak.deb
+ # Check for leaks on removal
+ $(DPKG_PURGE) pkg-maintscript-leak
+
+test-clean:
+ $(DPKG_PURGE) pkg-maintscript-leak
diff --git a/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/control b/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/control
new file mode 100644
index 0000000..5829d13
--- /dev/null
+++ b/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-maintscript-leak
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - maintscript leaks
diff --git a/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/postinst b/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/postinst
new file mode 100755
index 0000000..580884d
--- /dev/null
+++ b/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/postinst
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# On kFreeBSD: /dev/fd/
+# On Linux and kFreeBSD w/ linprocfs: /proc/self/fd/
+for d in /dev/fd/ /proc/self/fd/; do
+ if [ -d $d ]; then
+ fddir=$d
+ break
+ fi
+done
+
+if [ -n $fddir ]; then
+ ls -l $fddir
+ # We should have the 3 standard descriptors, plus 1 for the open directory.
+ [ `ls $fddir | wc -l` -eq 4 ] || echo WARN: maintscript leaks fd
+fi
diff --git a/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/postrm b/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/postrm
new file mode 100755
index 0000000..580884d
--- /dev/null
+++ b/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/postrm
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# On kFreeBSD: /dev/fd/
+# On Linux and kFreeBSD w/ linprocfs: /proc/self/fd/
+for d in /dev/fd/ /proc/self/fd/; do
+ if [ -d $d ]; then
+ fddir=$d
+ break
+ fi
+done
+
+if [ -n $fddir ]; then
+ ls -l $fddir
+ # We should have the 3 standard descriptors, plus 1 for the open directory.
+ [ `ls $fddir | wc -l` -eq 4 ] || echo WARN: maintscript leaks fd
+fi
diff --git a/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/preinst b/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/preinst
new file mode 100755
index 0000000..580884d
--- /dev/null
+++ b/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/preinst
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# On kFreeBSD: /dev/fd/
+# On Linux and kFreeBSD w/ linprocfs: /proc/self/fd/
+for d in /dev/fd/ /proc/self/fd/; do
+ if [ -d $d ]; then
+ fddir=$d
+ break
+ fi
+done
+
+if [ -n $fddir ]; then
+ ls -l $fddir
+ # We should have the 3 standard descriptors, plus 1 for the open directory.
+ [ `ls $fddir | wc -l` -eq 4 ] || echo WARN: maintscript leaks fd
+fi
diff --git a/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/prerm b/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/prerm
new file mode 100755
index 0000000..580884d
--- /dev/null
+++ b/tests/t-maintscript-leak/pkg-maintscript-leak/DEBIAN/prerm
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# On kFreeBSD: /dev/fd/
+# On Linux and kFreeBSD w/ linprocfs: /proc/self/fd/
+for d in /dev/fd/ /proc/self/fd/; do
+ if [ -d $d ]; then
+ fddir=$d
+ break
+ fi
+done
+
+if [ -n $fddir ]; then
+ ls -l $fddir
+ # We should have the 3 standard descriptors, plus 1 for the open directory.
+ [ `ls $fddir | wc -l` -eq 4 ] || echo WARN: maintscript leaks fd
+fi
diff --git a/tests/t-multiarch/Makefile b/tests/t-multiarch/Makefile
new file mode 100644
index 0000000..97cbc62
--- /dev/null
+++ b/tests/t-multiarch/Makefile
@@ -0,0 +1,831 @@
+# Copyright © 2011 Linaro Limited
+# Copyright © 2011 Raphaël Hertzog <hertzog@debian.org>
+# Copyright © 2011-2012 Guillem Jover <guillem@debian.org>
+
+TESTS_DEB :=
+
+include ../Test.mk
+
+NATIVE_ARCH := $(shell dpkg --print-architecture)
+ifeq ($(NATIVE_ARCH),i386)
+ FOREIGN_ARCH := amd64
+else
+ FOREIGN_ARCH := i386
+endif
+
+ma-setup:
+ $(DPKG) --add-architecture $(FOREIGN_ARCH)
+
+## BUILDING THE TEST PACKAGES ##
+
+# Params are (dirname, pkgname, ver, arch, ma, dep)
+# Dirname and pkgname are auto-prefixed with "pkg-ma"
+define build_pkg
+PKG_TO_BUILD += pkg-ma-$(1).deb
+
+pkg-ma-$(1):: pkg-template
+ [ -e pkg-ma-$(1) ] || cp -a pkg-template pkg-ma-$(1)
+ sed -i -e "s/Package: .*/Package: pkg-ma-$(2)/" \
+ -e "s/Version: .*/Version: $(3)/" \
+ -e "s/Architecture: .*/Architecture: $(4)/" \
+ -e "s/Multi-Arch: .*/Multi-Arch: $(5)/" \
+ -e "s/Depends:.*/Depends: $(6)/" \
+ pkg-ma-$(1)/DEBIAN/control
+ mkdir -p pkg-ma-$(1)/m-a
+ echo "In file pkg-ma-$(1)" > pkg-ma-$(1)/m-a/foo-$(1)
+ touch pkg-ma-$(1)
+
+pkg-ma-$(1).deb: pkg-ma-$(1)
+ $(DPKG_BUILD_DEB) --nocheck pkg-ma-$(1) pkg-ma-$(1).deb
+
+clean-hook::
+ rm -rf pkg-ma-$(1)
+ rm -f pkg-ma-$(1).deb
+endef
+
+$(foreach arch,$(NATIVE_ARCH) $(FOREIGN_ARCH),\
+ $(foreach ma,same foreign allowed no,\
+ $(foreach version,1.0 2.0,\
+ $(eval $(call build_pkg,$(ma)_$(version)_$(arch),$(ma),$(version),$(arch),$(ma),)))))
+
+# Arch: all done separately because M-A: same can't be Arch: all
+$(foreach ma,foreign allowed no,\
+ $(eval $(call build_pkg,$(ma)_1.0_all,$(ma),1.0,all,$(ma),)))
+
+$(eval $(call build_pkg,same_1.0_all,same,1.0,all,no,))
+
+$(foreach arch,$(NATIVE_ARCH) $(FOREIGN_ARCH),\
+ $(eval $(call build_pkg,self-conflict_1.0_$(arch),self-conflict,1.0,$(arch),same,))\
+ $(foreach ma,same foreign foreign-any allowed allowed-any allowed-fake no,\
+ $(eval $(call build_pkg,dep-on-$(ma)_1.0_$(arch),dep-on-$(ma),1.0,$(arch),foreign,pkg-ma-$(subst -,:,$(ma)) (>= 1.0)))))
+
+$(foreach ma,same foreign foreign-any allowed allowed-any allowed-fake no,\
+ $(eval $(call build_pkg,dep-on-$(ma)_1.0_all,dep-on-$(ma),1.0,all,no,pkg-ma-$(subst -,:,$(ma)) (>= 1.0))))
+
+shared_file_types := file symlink fifo
+ifdef DPKG_AS_ROOT
+shared_file_types += chardev blockdev
+endif
+$(foreach arch,$(NATIVE_ARCH) $(FOREIGN_ARCH),\
+ $(foreach version,1.0 2.0,\
+ $(eval $(call build_pkg,shared-conffiles_$(version)_orig_$(arch),shared-conffiles,$(version),$(arch),same,))\
+ $(eval $(call build_pkg,shared-conffiles_$(version)_alt_$(arch),shared-conffiles,$(version),$(arch),same,))\
+ $(foreach variant,orig alt,\
+ $(foreach type,$(shared_file_types),\
+ $(eval $(call build_pkg,shared-files_$(version)_$(variant)-$(type)_$(arch),shared-files,$(version),$(arch),same,))))))
+
+$(foreach arch,$(NATIVE_ARCH) $(FOREIGN_ARCH),\
+ $(eval $(call build_pkg,triggers_1.0_$(arch),triggers,1.0,$(arch),same,))\
+ $(eval $(call build_pkg,shared-diversion_1.0_$(arch),shared-diversion,1.0,$(arch),same,)))
+
+$(eval $(call build_pkg,act-trig_1.0_all,act-trig,1.0,all,no,))
+$(eval $(call build_pkg,diversion_1.0_all,diversion,1.0,all,no,))
+$(eval $(call build_pkg,diverted_1.0_all,diverted,1.0,all,no,))
+$(eval $(call build_pkg,db-layout_1.0_$(NATIVE_ARCH),db-layout,1.0,$(NATIVE_ARCH),no,))
+$(eval $(call build_pkg,db-layout_2.0_$(NATIVE_ARCH),db-layout,2.0,$(NATIVE_ARCH),same,))
+
+build-hook: $(PKG_TO_BUILD)
+
+## TEST CASES BELOW ##
+
+TEST_CASES += test-print-foreign-architecture
+TEST_CASES += test-build-invalid
+TEST_CASES += test-build-valid
+TEST_CASES += test-install-native
+TEST_CASES += test-install-foreign
+TEST_CASES += test-coinstall-ma-same
+TEST_CASES += test-crossgrade
+TEST_CASES += test-deps
+TEST_CASES += test-coinstall-shared-files
+TEST_CASES += test-coinstall-shared-conffiles
+TEST_CASES += test-coinstall-triggers
+TEST_CASES += test-coinstall-diversions
+TEST_CASES += test-dpkg-output
+TEST_CASES += test-db-layout
+
+test-case: $(TEST_CASES)
+
+test-print-foreign-architecture:
+ echo $(FOREIGN_ARCH) >ref-arch
+ echo foobar >>ref-arch
+ $(DPKG) --remove-architecture $(FOREIGN_ARCH)
+ $(DPKG) --remove-architecture foobar
+ $(call stdout_is,$(DPKG) --print-foreign-architectures,)
+ $(DPKG) --add-architecture $(FOREIGN_ARCH)
+ $(call stdout_is,$(DPKG) --print-foreign-architectures,$(FOREIGN_ARCH))
+ $(DPKG) --add-architecture foobar
+ $(DPKG) --print-foreign-architectures | cmp ref-arch -
+ # Ensure all/any can't be addded as foreign arch
+ ! $(DPKG) --add-architecture all
+ ! $(DPKG) --add-architecture any
+ # Ensure the native arch is never considered as
+ $(DPKG) --add-architecture $(NATIVE_ARCH)
+ $(DPKG) --print-foreign-architectures | cmp ref-arch -
+ $(DPKG) --remove-architecture foobar
+ rm -f ref-arch
+
+test-build-invalid:
+ # Test build of Architecture: all with Multi-Arch: same field
+ ! $(DPKG_BUILD_DEB) pkg-template foo.deb
+ rm -f foo.deb
+
+test-build-valid:
+ # Test build of package with valid dependency (ma-allowed:fake)
+ $(DPKG_BUILD_DEB) pkg-ma-dep-on-allowed-fake_1.0_$(NATIVE_ARCH) foo.deb
+ rm -f foo.deb
+
+test-install-native:
+ $(DPKG_INSTALL) pkg-ma-same_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-foreign_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-allowed_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-no_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-same:$(NATIVE_ARCH))
+ $(call pkg_is_installed,pkg-ma-foreign)
+ $(call pkg_is_installed,pkg-ma-allowed)
+ $(call pkg_is_installed,pkg-ma-no)
+ $(DPKG_PURGE) pkg-ma-same:$(NATIVE_ARCH) pkg-ma-foreign pkg-ma-allowed pkg-ma-no
+ $(call pkg_is_not_installed,pkg-ma-same:$(NATIVE_ARCH))
+ $(call pkg_is_not_installed,pkg-ma-foreign)
+ $(call pkg_is_not_installed,pkg-ma-allowed)
+ $(call pkg_is_not_installed,pkg-ma-no)
+
+test-install-foreign:
+ $(DPKG) --remove-architecture $(FOREIGN_ARCH)
+ # Installation of foreign arch packages must fail by default
+ ! $(DPKG_INSTALL) pkg-ma-same_1.0_$(FOREIGN_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-foreign_1.0_$(FOREIGN_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-allowed_1.0_$(FOREIGN_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-no_1.0_$(FOREIGN_ARCH).deb
+ # Once architecture has been added it should succeed
+ $(DPKG) --add-architecture $(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-same_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-foreign_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-allowed_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-no_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-same:$(FOREIGN_ARCH))
+ $(call pkg_is_installed,pkg-ma-foreign:$(FOREIGN_ARCH))
+ $(call pkg_is_installed,pkg-ma-allowed:$(FOREIGN_ARCH))
+ $(call pkg_is_installed,pkg-ma-no:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-same:$(FOREIGN_ARCH) pkg-ma-foreign:$(FOREIGN_ARCH) pkg-ma-allowed:$(FOREIGN_ARCH) pkg-ma-no:$(FOREIGN_ARCH)
+ $(call pkg_is_not_installed,pkg-ma-same:$(FOREIGN_ARCH))
+ $(call pkg_is_not_installed,pkg-ma-foreign:$(FOREIGN_ARCH))
+ $(call pkg_is_not_installed,pkg-ma-allowed:$(FOREIGN_ARCH))
+ $(call pkg_is_not_installed,pkg-ma-no:$(FOREIGN_ARCH))
+
+test-coinstall-ma-same: ma-setup
+ # Coinstall 2 Multi-Arch: same packages
+ $(DPKG_INSTALL) pkg-ma-same_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-same_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-same:$(NATIVE_ARCH))
+ $(call pkg_is_installed,pkg-ma-same:$(FOREIGN_ARCH))
+ # Upgrade one, the other must be unconfigured
+ $(DPKG_UNPACK) pkg-ma-same_2.0_$(NATIVE_ARCH).deb
+ $(call pkg_status_is,pkg-ma-same:$(NATIVE_ARCH),install ok unpacked)
+ $(call pkg_status_is,pkg-ma-same:$(FOREIGN_ARCH),install ok half-configured)
+ # Configure one alone must fail
+ ! $(DPKG_CONFIGURE) pkg-ma-same:$(NATIVE_ARCH)
+ ! $(DPKG_CONFIGURE) pkg-ma-same:$(FOREIGN_ARCH)
+ # Upgrade the other and it's now possible to configure them
+ $(DPKG_UNPACK) pkg-ma-same_2.0_$(FOREIGN_ARCH).deb
+ $(DPKG_CONFIGURE) --pending
+ $(call pkg_is_installed,pkg-ma-same:$(NATIVE_ARCH))
+ $(call pkg_is_installed,pkg-ma-same:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-same:$(NATIVE_ARCH) pkg-ma-same:$(FOREIGN_ARCH)
+
+TEST_CASES_CROSSGRADE :=
+TEST_CASES_CROSSGRADE += test-crossgrade-foreign-allowed
+
+test-crossgrade: $(TEST_CASES_CROSSGRADE)
+
+test-crossgrade-foreign-allowed: ma-setup
+ # Ensure we can cross-grade Multi-Arch: foreign/allowed
+ $(DPKG_INSTALL) pkg-ma-foreign_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-foreign_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-allowed_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-allowed_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-foreign:$(NATIVE_ARCH) pkg-ma-allowed:$(FOREIGN_ARCH)
+
+TEST_CASES_CROSSGRADE :=
+TEST_CASES_CROSSGRADE += test-crossgrade-any-all-same
+TEST_CASES_CROSSGRADE += test-crossgrade-any-all-foreign
+TEST_CASES_CROSSGRADE += test-crossgrade-any-all-allowed
+TEST_CASES_CROSSGRADE += test-crossgrade-all-any-same
+TEST_CASES_CROSSGRADE += test-crossgrade-all-any-foreign
+TEST_CASES_CROSSGRADE += test-crossgrade-all-any-allowed
+TEST_CASES_CROSSGRADE += test-crossgrade-same-all
+TEST_CASES_CROSSGRADE += test-crossgrade-no
+
+test-crossgrade: $(TEST_CASES_CROSSGRADE)
+
+test-crossgrade-any-all-%: ma-setup
+ # M-A: $* / Upgrade from arch: any-native -> all
+ $(DPKG_INSTALL) pkg-ma-$*_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-$*_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-$*:all)
+ $(call pkg_is_not_installed,pkg-ma-$*:$(NATIVE_ARCH))
+ $(call pkg_field_is,pkg-ma-$*,Architecture,all)
+ $(DPKG_PURGE) pkg-ma-$*
+ $(call pkg_is_not_installed,pkg-ma-$*)
+ # M-A: $* / Upgrade from arch: any-foreign -> all
+ $(DPKG_INSTALL) pkg-ma-$*_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-$*_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-$*:all)
+ $(call pkg_is_not_installed,pkg-ma-$*:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-$*
+
+test-crossgrade-all-any-%: ma-setup
+ # M-A: $* / Upgrade from arch: all -> any-native
+ $(DPKG_INSTALL) pkg-ma-$*_1.0_all.deb
+ $(DPKG_INSTALL) pkg-ma-$*_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-$*:$(NATIVE_ARCH))
+ $(call pkg_is_not_installed,pkg-ma-$*:all)
+ $(call pkg_field_is,pkg-ma-$*,Architecture,$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-$*:$(NATIVE_ARCH)
+ $(call pkg_is_not_installed,pkg-ma-$*:all)
+ $(call pkg_is_not_installed,pkg-ma-$*:$(NATIVE_ARCH))
+ # M-A: $* / Upgrade from arch: all -> any-foreign
+ $(DPKG_INSTALL) pkg-ma-$*_1.0_all.deb
+ $(DPKG_INSTALL) pkg-ma-$*_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_not_installed,pkg-ma-$*:all)
+ $(call pkg_is_installed,pkg-ma-$*:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-$*
+
+test-crossgrade-same-all: ma-setup
+ # Several M-A: same installed, can't upgrade to single arch all
+ $(DPKG_INSTALL) pkg-ma-same_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-same_1.0_$(FOREIGN_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-same_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-same:$(NATIVE_ARCH))
+ $(call pkg_is_installed,pkg-ma-same:$(FOREIGN_ARCH))
+ $(call pkg_is_not_installed,pkg-ma-same:all)
+ $(DPKG_PURGE) pkg-ma-same:$(NATIVE_ARCH) pkg-ma-same:$(FOREIGN_ARCH)
+
+pkg-ma-no_1.0_$(NATIVE_ARCH) pkg-ma-no_1.0_$(FOREIGN_ARCH):: pkg-template
+ echo "A conffile" > $@/m-a/conffile-$@
+ echo "/m-a/conffile-$@" > $@/DEBIAN/conffiles
+
+test-crossgrade-no: ma-setup
+ $(DPKG_INSTALL) pkg-ma-no_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_REMOVE) pkg-ma-no:$(NATIVE_ARCH)
+ $(call pkg_status_is,pkg-ma-no:$(NATIVE_ARCH),deinstall ok config-files)
+ $(call pkg_is_not_installed,pkg-ma-no:$(FOREIGN_ARCH))
+ $(call stdout_has,$(DPKG_QUERY) -L pkg-ma-no,/m-a/conffile-pkg-ma-no_1.0_$(NATIVE_ARCH))
+ $(DPKG_INSTALL) pkg-ma-no_1.0_$(FOREIGN_ARCH).deb
+ # Verify the replaced package disappeared
+ $(call pkg_is_not_installed,pkg-ma-no:$(NATIVE_ARCH))
+ $(call pkg_is_installed,pkg-ma-no:$(FOREIGN_ARCH))
+ $(call stdout_has,$(DPKG_QUERY) -L pkg-ma-no:$(FOREIGN_ARCH),/m-a/conffile-pkg-ma-no_1.0_$(FOREIGN_ARCH))
+ # Ensure the conffile of the disappeared package is still tracked
+ $(call stdout_has,$(DPKG_QUERY) -L pkg-ma-no:$(FOREIGN_ARCH),/m-a/conffile-pkg-ma-no_1.0_$(NATIVE_ARCH))
+ $(call stdout_has,$(DPKG_QUERY) -f '$${Conffiles}' -W pkg-ma-no:$(FOREIGN_ARCH), /m-a/conffile-pkg-ma-no_1.0_$(NATIVE_ARCH) [a-f0-9]+ obsolete$$)
+ $(DPKG_PURGE) pkg-ma-no:$(FOREIGN_ARCH)
+
+TEST_CASES_DEPS :=
+TEST_CASES_DEPS += test-deps-same
+TEST_CASES_DEPS += test-deps-foreign
+TEST_CASES_DEPS += test-deps-allowed
+TEST_CASES_DEPS += test-deps-no
+TEST_CASES_DEPS += test-deps-self-conflict
+TEST_CASES_DEPS += test-deps-force
+
+test-deps: $(TEST_CASES_DEPS)
+
+test-deps-same: ma-setup
+ # Native M-A: same is installed, no cross-arch dep allowed
+ $(DPKG_INSTALL) pkg-ma-same_1.0_$(NATIVE_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-dep-on-same_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-dep-on-same:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-same_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-dep-on-same)
+ $(DPKG_PURGE) pkg-ma-dep-on-same
+ $(DPKG_INSTALL) pkg-ma-dep-on-same_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-same:$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-same:$(NATIVE_ARCH)
+ $(DPKG_PURGE) pkg-ma-same:$(NATIVE_ARCH)
+ # Foreign M-A: same is installed
+ $(DPKG_INSTALL) pkg-ma-same_1.0_$(FOREIGN_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-dep-on-same_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-dep-on-same:$(NATIVE_ARCH)
+ ! $(DPKG_INSTALL) pkg-ma-dep-on-same_1.0_all.deb
+ $(DPKG_PURGE) pkg-ma-dep-on-same
+ $(DPKG_INSTALL) pkg-ma-dep-on-same_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-same:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-same:$(FOREIGN_ARCH)
+ $(DPKG_PURGE) pkg-ma-same:$(FOREIGN_ARCH)
+ # Arch: all M-A: same can't exist
+
+test-deps-foreign: ma-setup
+ # Native M-A: foreign is installed
+ $(DPKG_INSTALL) pkg-ma-foreign_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-dep-on-foreign_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-foreign:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-foreign:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-foreign_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-dep-on-foreign)
+ $(DPKG_PURGE) pkg-ma-dep-on-foreign
+ $(DPKG_INSTALL) pkg-ma-dep-on-foreign_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-foreign:$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-foreign:$(NATIVE_ARCH)
+ $(DPKG_PURGE) pkg-ma-foreign:$(NATIVE_ARCH)
+ # Foreign M-A: foreign is installed
+ $(DPKG_INSTALL) pkg-ma-foreign_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-dep-on-foreign_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-foreign:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-foreign:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-foreign_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-dep-on-foreign)
+ $(DPKG_PURGE) pkg-ma-dep-on-foreign
+ $(DPKG_INSTALL) pkg-ma-dep-on-foreign_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-foreign:$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-foreign:$(NATIVE_ARCH)
+ $(DPKG_PURGE) pkg-ma-foreign:$(FOREIGN_ARCH)
+ # Arch: all M-A: foreign is installed
+ $(DPKG_INSTALL) pkg-ma-foreign_1.0_all.deb
+ $(DPKG_INSTALL) pkg-ma-dep-on-foreign_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-foreign:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-foreign:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-foreign_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-dep-on-foreign)
+ $(DPKG_PURGE) pkg-ma-dep-on-foreign
+ $(DPKG_INSTALL) pkg-ma-dep-on-foreign_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-foreign:$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-foreign:$(NATIVE_ARCH)
+ $(DPKG_PURGE) pkg-ma-foreign
+
+test-deps-allowed: ma-setup
+ ## Native M-A: allowed is installed
+ $(DPKG_INSTALL) pkg-ma-allowed_1.0_$(NATIVE_ARCH).deb
+ # Non-annotated dependency on pkg-ma-allowed
+ ! $(DPKG_INSTALL) pkg-ma-dep-on-allowed_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed:$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed:$(NATIVE_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed)
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed
+ # Annotated dep: pkg-ma-allowed:any
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed-any_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed-any:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed-any:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed-any_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed-any:$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed-any:$(NATIVE_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed-any_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed-any)
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed-any
+ $(DPKG_PURGE) pkg-ma-allowed:$(NATIVE_ARCH)
+ ## Foreign M-A: allowed is installed
+ $(DPKG_INSTALL) pkg-ma-allowed_1.0_$(FOREIGN_ARCH).deb
+ # Non-annotated dependency on pkg-ma-allowed
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed:$(FOREIGN_ARCH)
+ ! $(DPKG_INSTALL) pkg-ma-dep-on-allowed_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed:$(NATIVE_ARCH)
+ ! $(DPKG_INSTALL) pkg-ma-dep-on-allowed_1.0_all.deb
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed
+ # Annotated dep: pkg-ma-allowed:any
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed-any_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed-any:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed-any:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed-any_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed-any:$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed-any:$(NATIVE_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed-any_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed-any)
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed-any
+ $(DPKG_PURGE) pkg-ma-allowed:$(FOREIGN_ARCH)
+ ## Arch: all M-A: allowed is installed
+ $(DPKG_INSTALL) pkg-ma-allowed_1.0_all.deb
+ # Non-annotated dependency on pkg-ma-allowed
+ ! $(DPKG_INSTALL) pkg-ma-dep-on-allowed_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed:$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed:$(NATIVE_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed)
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed
+ # Annotated dep: pkg-ma-allowed:any
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed-any_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed-any:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed-any:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed-any_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed-any:$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed-any:$(NATIVE_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-allowed-any_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-dep-on-allowed-any)
+ $(DPKG_PURGE) pkg-ma-dep-on-allowed-any
+ $(DPKG_PURGE) pkg-ma-allowed
+
+test-deps-no: ma-setup
+ # Native M-A: no is installed
+ $(DPKG_INSTALL) pkg-ma-no_1.0_$(NATIVE_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-dep-on-no_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-dep-on-no:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-no_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-dep-on-no)
+ $(DPKG_PURGE) pkg-ma-dep-on-no
+ $(DPKG_INSTALL) pkg-ma-dep-on-no_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-no:$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-no:$(NATIVE_ARCH)
+ $(DPKG_PURGE) pkg-ma-no:$(NATIVE_ARCH)
+ # Foreign M-A: no is installed (with --force-architecture)
+ $(DPKG_INSTALL) --force-architecture pkg-ma-no_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-dep-on-no_1.0_$(FOREIGN_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-no:$(FOREIGN_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-no:$(FOREIGN_ARCH)
+ ! $(DPKG_INSTALL) pkg-ma-dep-on-no_1.0_all.deb
+ $(DPKG_PURGE) pkg-ma-dep-on-no
+ ! $(DPKG_INSTALL) pkg-ma-dep-on-no_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-dep-on-no:$(NATIVE_ARCH)
+ $(DPKG_PURGE) pkg-ma-no:$(FOREIGN_ARCH)
+ # Arch: all M-A: no is installed
+ $(DPKG_INSTALL) pkg-ma-no_1.0_all.deb
+ ! $(DPKG_INSTALL) pkg-ma-dep-on-no_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-dep-on-no:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-dep-on-no_1.0_all.deb
+ $(call pkg_is_installed,pkg-ma-dep-on-no)
+ $(DPKG_PURGE) pkg-ma-dep-on-no
+ $(DPKG_INSTALL) pkg-ma-dep-on-no_1.0_$(NATIVE_ARCH).deb
+ $(call pkg_is_installed,pkg-ma-dep-on-no:$(NATIVE_ARCH))
+ $(DPKG_PURGE) pkg-ma-dep-on-no:$(NATIVE_ARCH)
+ $(DPKG_PURGE) pkg-ma-no
+
+pkg-ma-self-conflict_1.0_$(NATIVE_ARCH) pkg-ma-self-conflict_1.0_$(FOREIGN_ARCH):: pkg-template
+ grep -q "Conflicts: " $@/DEBIAN/control || \
+ (echo "Conflicts: virtual-foo" >> $@/DEBIAN/control; \
+ echo "Provides: virtual-foo" >> $@/DEBIAN/control)
+
+test-deps-self-conflict: ma-setup
+ $(DPKG_INSTALL) pkg-ma-self-conflict_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-self-conflict_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-self-conflict:$(NATIVE_ARCH)
+ $(DPKG_PURGE) pkg-ma-self-conflict:$(FOREIGN_ARCH)
+
+test-deps-force: ma-setup
+ # Try --force-depends when dependency is missing
+ $(DPKG_INSTALL) --force-depends pkg-ma-dep-on-no_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-dep-on-no:$(FOREIGN_ARCH)
+ # Try --force-depends when dependency is of the wrong arch
+ $(DPKG_INSTALL) pkg-ma-no_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) --force-depends pkg-ma-dep-on-no_1.0_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-dep-on-no:$(FOREIGN_ARCH)
+ $(DPKG_PURGE) pkg-ma-no
+
+common_file = /m-a/common-file
+
+# Further customize test packages for test-coinstall-shared-files
+define customize_shared_files
+pkg-ma-shared-files_$(1)_$(2)-file_$(3):: pkg-template
+ echo "Variant: $(2) Version: $(1)" > pkg-ma-shared-files_$(1)_$(2)-file_$(3)$(common_file)
+
+pkg-ma-shared-files_$(1)_$(2)-symlink_$(3):: pkg-template
+ ln -sf "$(2)-$(1)" pkg-ma-shared-files_$(1)_$(2)-symlink_$(3)$(common_file)
+
+pkg-ma-shared-files_$(1)_$(2)-fifo_$(3):: pkg-template
+ test -e pkg-ma-shared-files_$(1)_$(2)-fifo_$(3)$(common_file) || \
+ $(BEROOT) mkfifo pkg-ma-shared-files_$(1)_$(2)-fifo_$(3)$(common_file)
+
+pkg-ma-shared-files_$(1)_$(2)-chardev_$(3):: pkg-template
+ [ "$(2)" = "orig" ] && major=1 || major=2; \
+ [ "$(1)" = "1.0" ] && minor=3 || minor=4; \
+ test -e pkg-ma-shared-files_$(1)_$(2)-chardev_$(3)$(common_file) || \
+ $(BEROOT) mknod pkg-ma-shared-files_$(1)_$(2)-chardev_$(3)$(common_file) c $$$$major $$$$minor
+
+pkg-ma-shared-files_$(1)_$(2)-blockdev_$(3):: pkg-template
+ [ "$(2)" = "orig" ] && major=1 || major=2; \
+ [ "$(1)" = "1.0" ] && minor=3 || minor=4; \
+ test -e pkg-ma-shared-files_$(1)_$(2)-blockdev_$(3)$(common_file) || \
+ $(BEROOT) mknod pkg-ma-shared-files_$(1)_$(2)-blockdev_$(3)$(common_file) b $$$$major $$$$minor
+endef
+
+$(foreach version,1.0 2.0,$(foreach variant,orig alt,\
+ $(eval $(call customize_shared_files,$(version),$(variant),$(NATIVE_ARCH)))\
+ $(eval $(call customize_shared_files,$(version),$(variant),$(FOREIGN_ARCH)))))
+
+test-coinstall-shared-files: ma-setup
+ # Ensure we can't install a shared file conflicting with a
+ # multi-arch sibling package of the same version
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-file_$(NATIVE_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-symlink_$(FOREIGN_ARCH).deb
+ test -f "$(DPKG_INSTDIR)$(common_file)"
+ ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-fifo_$(FOREIGN_ARCH).deb
+ test -f "$(DPKG_INSTDIR)$(common_file)"
+ifdef DPKG_AS_ROOT
+ ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-chardev_$(FOREIGN_ARCH).deb
+ test -f "$(DPKG_INSTDIR)$(common_file)"
+ ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-blockdev_$(FOREIGN_ARCH).deb
+ test -f "$(DPKG_INSTDIR)$(common_file)"
+endif
+ ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-file_$(FOREIGN_ARCH).deb
+ grep -q "Variant: orig Version: 1.0" "$(DPKG_INSTDIR)$(common_file)"
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-file_$(FOREIGN_ARCH).deb
+ $(call stdout_has,$(DPKG_QUERY) -L pkg-ma-shared-files:$(NATIVE_ARCH),$(common_file))
+ $(call stdout_has,$(DPKG_QUERY) -L pkg-ma-shared-files:$(FOREIGN_ARCH),$(common_file))
+ ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-file_$(FOREIGN_ARCH).deb
+ # But that we can install another version while upgrading
+ $(DPKG_UNPACK) pkg-ma-shared-files_2.0_orig-file_$(NATIVE_ARCH).deb
+ grep -q "Variant: orig Version: 2.0" "$(DPKG_INSTDIR)$(common_file)"
+ ! $(DPKG_UNPACK) pkg-ma-shared-files_2.0_alt-file_$(FOREIGN_ARCH).deb
+ $(DPKG_UNPACK) pkg-ma-shared-files_2.0_orig-file_$(FOREIGN_ARCH).deb
+ $(DPKG_CONFIGURE) --pending
+ $(DPKG_UNPACK) pkg-ma-shared-files_1.0_alt-file_$(NATIVE_ARCH).deb
+ grep -q "Variant: alt" "$(DPKG_INSTDIR)$(common_file)"
+ # Even during upgrade you can't come with a conflicting version
+ ! $(DPKG_UNPACK) pkg-ma-shared-files_1.0_orig-file_$(FOREIGN_ARCH).deb
+ $(DPKG_UNPACK) pkg-ma-shared-files_1.0_alt-file_$(FOREIGN_ARCH).deb
+ $(DPKG_CONFIGURE) --pending
+ $(DPKG_PURGE) pkg-ma-shared-files:$(NATIVE_ARCH)
+ $(DPKG_PURGE) pkg-ma-shared-files:$(FOREIGN_ARCH)
+ # Ensure we can re-install a conflicting version of a package if
+ # no multi-arch siblings are installed
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-file_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-file_$(NATIVE_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-shared-files:$(NATIVE_ARCH)
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-file_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-file_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-shared-files:$(FOREIGN_ARCH)
+ # Ensure files are kept during removal
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-file_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-file_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-shared-files:$(FOREIGN_ARCH)
+ grep -q "Variant: orig Version: 1.0" "$(DPKG_INSTDIR)$(common_file)"
+ $(call stdout_has,$(DPKG_QUERY) -L pkg-ma-shared-files:$(NATIVE_ARCH),$(common_file))
+ $(DPKG_PURGE) pkg-ma-shared-files:$(NATIVE_ARCH)
+ # Ensure we detect differences with non-files too
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-symlink_$(NATIVE_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-symlink_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-symlink_$(FOREIGN_ARCH).deb
+ $(call stdout_is,readlink "$(DPKG_INSTDIR)$(common_file)",orig-1.0)
+ $(DPKG_PURGE) pkg-ma-shared-files:$(NATIVE_ARCH) pkg-ma-shared-files:$(FOREIGN_ARCH)
+ifdef DPKG_AS_ROOT
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-chardev_$(NATIVE_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-chardev_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-chardev_$(FOREIGN_ARCH).deb
+ test -c "$(DPKG_INSTDIR)$(common_file)"
+ $(call stdout_is,stat -c "%t %T" "$(DPKG_INSTDIR)$(common_file)",1 3)
+ $(DPKG_PURGE) pkg-ma-shared-files:$(NATIVE_ARCH) pkg-ma-shared-files:$(FOREIGN_ARCH)
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-blockdev_$(NATIVE_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-blockdev_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-blockdev_$(FOREIGN_ARCH).deb
+ test -b "$(DPKG_INSTDIR)$(common_file)"
+ $(call stdout_is,stat -c "%t %T" "$(DPKG_INSTDIR)$(common_file)",1 3)
+ $(DPKG_PURGE) pkg-ma-shared-files:$(NATIVE_ARCH) pkg-ma-shared-files:$(FOREIGN_ARCH)
+endif
+
+# Further customize test packages for test-coinstall-shared-conffiles
+define customize_shared_conffiles
+pkg-ma-shared-conffiles_$(1)_$(2)_$(3):: pkg-template
+ echo "Variant: $(2) Version: $(1)" > pkg-ma-shared-conffiles_$(1)_$(2)_$(3)/m-a/conffile
+ echo "/m-a/conffile" > pkg-ma-shared-conffiles_$(1)_$(2)_$(3)/DEBIAN/conffiles
+endef
+
+$(foreach version,1.0 2.0,$(foreach variant,orig alt,\
+ $(eval $(call customize_shared_conffiles,$(version),$(variant),$(NATIVE_ARCH)))\
+ $(eval $(call customize_shared_conffiles,$(version),$(variant),$(FOREIGN_ARCH)))))
+
+test-coinstall-shared-conffiles: ma-setup
+ # Ensure we can't install a shared conffile conflicting with a
+ # multi-arch sibling package of the same version
+ $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_orig_$(NATIVE_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_alt_$(FOREIGN_ARCH).deb
+ grep -q "Variant: orig Version: 1.0" "$(DPKG_INSTDIR)/m-a/conffile"
+ $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_orig_$(FOREIGN_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_alt_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-shared-conffiles:$(NATIVE_ARCH)
+ $(DPKG_PURGE) pkg-ma-shared-conffiles:$(FOREIGN_ARCH)
+ # Ensure this is still true even if the installed conffile is modified
+ $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_orig_$(NATIVE_ARCH).deb
+ $(BEROOT) sh -c "echo 'MODIFIED' >>'$(DPKG_INSTDIR)/m-a/conffile'"
+ ! $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_alt_$(FOREIGN_ARCH).deb
+ grep -q "Variant: orig Version: 1.0" "$(DPKG_INSTDIR)/m-a/conffile"
+ $(DPKG_INSTALL) --force-confold pkg-ma-shared-conffiles_1.0_orig_$(FOREIGN_ARCH).deb
+ ! $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_alt_$(FOREIGN_ARCH).deb
+ # Ensure we can install another version while upgrading even
+ # with a modified conffile
+ $(DPKG_UNPACK) pkg-ma-shared-conffiles_2.0_orig_$(NATIVE_ARCH).deb
+ grep -q "Variant: orig Version: 2.0" "$(DPKG_INSTDIR)/m-a/conffile.dpkg-new"
+ ! $(DPKG_UNPACK) pkg-ma-shared-conffiles_2.0_alt_$(FOREIGN_ARCH).deb
+ grep -q "Variant: orig Version: 2.0" "$(DPKG_INSTDIR)/m-a/conffile.dpkg-new"
+ $(DPKG_UNPACK) pkg-ma-shared-conffiles_2.0_orig_$(FOREIGN_ARCH).deb
+ $(DPKG_CONFIGURE) --force-confnew --pending
+ grep -q "Variant: orig Version: 2.0" "$(DPKG_INSTDIR)/m-a/conffile"
+ # Ensure the conffile hashes are correct, i.e. the new hashes have
+ # propagated to all instances
+ $(call stdout_is,$(DPKG_QUERY) -f '$${Conffiles}' -W pkg-ma-shared-conffiles:$(NATIVE_ARCH), /m-a/conffile 7404b80581282025ee3ec6689e111114)
+ $(call stdout_is,$(DPKG_QUERY) -f '$${Conffiles}' -W pkg-ma-shared-conffiles:$(FOREIGN_ARCH), /m-a/conffile 7404b80581282025ee3ec6689e111114)
+ # Ensure we can reinstall coinstallable packages with conffiles on
+ # the same run
+ $(DPKG_INSTALL) pkg-ma-shared-conffiles_2.0_orig_$(NATIVE_ARCH).deb \
+ pkg-ma-shared-conffiles_2.0_orig_$(FOREIGN_ARCH).deb
+ grep -q "Variant: orig Version: 2.0" "$(DPKG_INSTDIR)/m-a/conffile"
+ # Ensure we can reinstall coinstallable packages with conffiles on
+ # different runs
+ $(DPKG_UNPACK) pkg-ma-shared-conffiles_2.0_orig_$(FOREIGN_ARCH).deb
+ $(DPKG_UNPACK) pkg-ma-shared-conffiles_2.0_orig_$(NATIVE_ARCH).deb
+ $(DPKG_CONFIGURE) pkg-ma-shared-conffiles:$(NATIVE_ARCH)
+ $(DPKG_CONFIGURE) pkg-ma-shared-conffiles:$(FOREIGN_ARCH)
+ grep -q "Variant: orig Version: 2.0" "$(DPKG_INSTDIR)/m-a/conffile"
+ # Another time with a downgrade and an unmodified conffile
+ $(DPKG_UNPACK) pkg-ma-shared-conffiles_1.0_alt_$(NATIVE_ARCH).deb
+ grep -q "Variant: alt" "$(DPKG_INSTDIR)/m-a/conffile.dpkg-new"
+ ! $(DPKG_UNPACK) pkg-ma-shared-conffiles_1.0_orig_$(FOREIGN_ARCH).deb
+ $(DPKG_UNPACK) pkg-ma-shared-conffiles_1.0_alt_$(FOREIGN_ARCH).deb
+ $(DPKG_CONFIGURE) --force-confnew --pending
+ # Verify shared conffiles are forgotten on remove, and really
+ # removed on purge of last package
+ $(DPKG_REMOVE) pkg-ma-shared-conffiles:$(NATIVE_ARCH)
+ ! $(call stdout_has,$(DPKG_QUERY) -L pkg-ma-shared-conffiles:$(NATIVE_ARCH),/m-a/conffile)
+ $(DPKG_PURGE) pkg-ma-shared-conffiles:$(NATIVE_ARCH)
+ test -e "$(DPKG_INSTDIR)/m-a/conffile"
+ $(DPKG_PURGE) pkg-ma-shared-conffiles:$(FOREIGN_ARCH)
+ ! test -e "$(DPKG_INSTDIR)/m-a/conffile"
+ # Ensure we can re-install a conflicting version of a package if
+ # no multi-arch siblings are installed
+ $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_orig_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_alt_$(NATIVE_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-shared-conffiles:$(NATIVE_ARCH)
+ $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_orig_$(FOREIGN_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_alt_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-shared-conffiles:$(FOREIGN_ARCH)
+ # Same with modified conffile
+ $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_orig_$(NATIVE_ARCH).deb
+ $(BEROOT) sh -c "echo 'MODIFIED' >>'$(DPKG_INSTDIR)/m-a/conffile'"
+ $(DPKG_INSTALL) --force-confnew pkg-ma-shared-conffiles_1.0_alt_$(NATIVE_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-shared-conffiles:$(NATIVE_ARCH)
+ $(DPKG_INSTALL) pkg-ma-shared-conffiles_1.0_orig_$(FOREIGN_ARCH).deb
+ $(BEROOT) sh -c "echo 'MODIFIED' >>'$(DPKG_INSTDIR)/m-a/conffile'"
+ $(DPKG_INSTALL) --force-confnew pkg-ma-shared-conffiles_1.0_alt_$(FOREIGN_ARCH).deb
+ $(DPKG_PURGE) pkg-ma-shared-conffiles:$(FOREIGN_ARCH)
+
+# Further customize test packages for test-coinstall-triggers
+pkg-ma-triggers_1.0_$(NATIVE_ARCH) pkg-ma-triggers_1.0_$(FOREIGN_ARCH):: pkg-template
+ echo "#!/bin/sh" >$@/DEBIAN/postinst
+ echo '[ "$$1" = "triggered" ] || exit 0' >>$@/DEBIAN/postinst
+ echo 'case " $$2 " in' >>$@/DEBIAN/postinst
+ echo '*" /m-a/trigger-watch "*) ' >>$@/DEBIAN/postinst
+ echo ' echo "FILE $$DPKG_MAINTSCRIPT_ARCH" >>"$$DPKG_ROOT/m-a/triggers" ;;' >>$@/DEBIAN/postinst
+ echo 'esac' >>$@/DEBIAN/postinst
+ echo 'case " $$2 " in' >>$@/DEBIAN/postinst
+ echo '*" test-m-a-same "*)' >>$@/DEBIAN/postinst
+ echo ' echo "MANUAL $$DPKG_MAINTSCRIPT_ARCH" >>"$$DPKG_ROOT/m-a/triggers" ;;' >>$@/DEBIAN/postinst
+ echo 'esac' >>$@/DEBIAN/postinst
+ chmod 755 $@/DEBIAN/postinst
+ echo 'interest /m-a/trigger-watch' >$@/DEBIAN/triggers
+ echo 'interest test-m-a-same' >>$@/DEBIAN/triggers
+
+pkg-ma-act-trig_1.0_all:: pkg-template
+ echo "Activates a trigger" >$@/m-a/trigger-watch
+ echo "#!/bin/sh" >$@/DEBIAN/postinst
+ echo "dpkg-trigger test-m-a-same" >>$@/DEBIAN/postinst
+ chmod 755 $@/DEBIAN/postinst
+
+test-coinstall-triggers: ma-setup
+ -cat "$(DPKG_ADMINDIR)/triggers/File"
+ $(DPKG_INSTALL) pkg-ma-triggers_1.0_$(NATIVE_ARCH).deb
+ cat "$(DPKG_ADMINDIR)/triggers/File"
+ $(DPKG_INSTALL) pkg-ma-triggers_1.0_$(FOREIGN_ARCH).deb
+ cat "$(DPKG_ADMINDIR)/triggers/File"
+ # Test file trigger processing
+ $(BEROOT) sh -c ":>'$(DPKG_INSTDIR)/m-a/triggers'"
+ $(DPKG_UNPACK) --no-triggers pkg-ma-act-trig_1.0_all.deb
+ $(call pkg_status_is,pkg-ma-triggers:$(NATIVE_ARCH),install ok triggers-pending)
+ $(call pkg_status_is,pkg-ma-triggers:$(FOREIGN_ARCH),install ok triggers-pending)
+ $(DPKG_CONFIGURE) pkg-ma-triggers:$(NATIVE_ARCH) pkg-ma-triggers:$(FOREIGN_ARCH)
+ $(call pkg_is_installed,pkg-ma-triggers:$(NATIVE_ARCH))
+ $(call pkg_is_installed,pkg-ma-triggers:$(FOREIGN_ARCH))
+ $(call stdout_is,grep -c FILE "$(DPKG_INSTDIR)/m-a/triggers",2)
+ grep -q "FILE $(NATIVE_ARCH)" "$(DPKG_INSTDIR)/m-a/triggers"
+ grep -q "FILE $(FOREIGN_ARCH)" "$(DPKG_INSTDIR)/m-a/triggers"
+ # Test manual trigger processing
+ $(DPKG_CONFIGURE) pkg-ma-act-trig
+ $(call pkg_is_installed,pkg-ma-triggers:$(NATIVE_ARCH))
+ $(call pkg_is_installed,pkg-ma-triggers:$(FOREIGN_ARCH))
+ $(call stdout_is,grep -c MANUAL "$(DPKG_INSTDIR)/m-a/triggers",2)
+ grep -q "MANUAL $(NATIVE_ARCH)" "$(DPKG_INSTDIR)/m-a/triggers"
+ grep -q "MANUAL $(FOREIGN_ARCH)" "$(DPKG_INSTDIR)/m-a/triggers"
+ # Clean up
+ $(DPKG_PURGE) pkg-ma-act-trig
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/m-a/triggers"
+ $(DPKG_PURGE) pkg-ma-triggers:$(NATIVE_ARCH)
+ $(DPKG_PURGE) pkg-ma-triggers:$(FOREIGN_ARCH)
+
+# Further customize test packages for test-coinstall-diversions
+pkg-ma-diversion_1.0_all:: pkg-template
+ echo "File provided by pkg-ma-diversion" >$@$(common_file)
+ echo "#!/bin/sh" >$@/DEBIAN/preinst
+ echo '[ "$$1" = "install" ] || exit 0' >>$@/DEBIAN/preinst
+ echo 'dpkg-divert --add --rename $(common_file)' >>$@/DEBIAN/preinst
+ echo "#!/bin/sh" >$@/DEBIAN/postrm
+ echo '[ "$$1" = "remove" ] || exit 0' >>$@/DEBIAN/postrm
+ echo 'dpkg-divert --remove --rename $(common_file)' >>$@/DEBIAN/postrm
+ chmod 755 $@/DEBIAN/preinst $@/DEBIAN/postrm
+
+pkg-ma-diverted_1.0_all:: pkg-template
+ echo "File provided by pkg-ma-diverted" >$@$(common_file)
+
+pkg-ma-shared-diversion_1.0_$(NATIVE_ARCH) pkg-ma-shared-diversion_1.0_$(FOREIGN_ARCH):: pkg-template
+ echo "File provided by pkg-ma-shared-diversion" >$@$(common_file)
+ echo "#!/bin/sh" >$@/DEBIAN/preinst
+ echo '[ "$$1" = "install" ] || exit 0' >>$@/DEBIAN/preinst
+ echo 'dpkg-divert --add --rename $(common_file)' >>$@/DEBIAN/preinst
+ echo "#!/bin/sh" >$@/DEBIAN/postrm
+ echo '[ "$$1" = "remove" ] || exit 0' >>$@/DEBIAN/postrm
+ echo 'dpkg-divert --remove --rename $(common_file)' >>$@/DEBIAN/postrm
+ chmod 755 $@/DEBIAN/preinst $@/DEBIAN/postrm
+
+test-coinstall-diversions: ma-setup
+ # Test shared files with a diversion
+ $(DPKG_DIVERT_ADD) --local --divert $(common_file).real $(common_file)
+ $(MAKE) test-coinstall-shared-files common_file=$(common_file).real
+ $(DPKG_DIVERT_DEL) --local --divert $(common_file).real $(common_file)
+ $(DPKG_INSTALL) pkg-ma-diversion_1.0_all.deb
+ $(MAKE) test-coinstall-shared-files common_file=$(common_file).distrib
+ $(DPKG_PURGE) pkg-ma-diversion
+ # Test with another package providing a conflicting file
+ # and the multiarch packages registering the diversion
+ $(DPKG_INSTALL) pkg-ma-diverted_1.0_all.deb
+ $(DPKG_INSTALL) pkg-ma-shared-diversion_1.0_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-shared-diversion_1.0_$(FOREIGN_ARCH).deb
+ grep -q "pkg-ma-diverted" "$(DPKG_INSTDIR)$(common_file).distrib"
+ grep -q "pkg-ma-shared-diversion" "$(DPKG_INSTDIR)$(common_file)"
+ $(DPKG_PURGE) pkg-ma-shared-diversion:$(NATIVE_ARCH)
+ $(call stdout_has,$(DPKG_DIVERT) --list,$(common_file).distrib)
+ $(DPKG_PURGE) pkg-ma-shared-diversion:$(FOREIGN_ARCH)
+ ! $(call stdout_has,$(DPKG_DIVERT) --list,$(common_file).distrib)
+ $(DPKG_PURGE) pkg-ma-diverted
+
+test-dpkg-output: ma-setup
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-file_$(NATIVE_ARCH).deb
+ $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-file_$(FOREIGN_ARCH).deb
+ $(call stdout_has,$(DPKG_QUERY) -W,^pkg-ma-shared-files:$(NATIVE_ARCH) 1.0$)
+ $(call stdout_has,$(DPKG_QUERY) -W,^pkg-ma-shared-files:$(FOREIGN_ARCH) 1.0$)
+ ! $(call stdout_is,$(DPKG_QUERY) -f'$${binary:Package}' -W pkg-ma-shared-files,pkg-ma-shared-files)
+ $(call stdout_is,$(DPKG_QUERY) -f'$${binary:Package}' -W pkg-ma-shared-files:$(NATIVE_ARCH),pkg-ma-shared-files:$(NATIVE_ARCH))
+ $(call stdout_is,$(DPKG_QUERY) -f'$${binary:Package}' -W pkg-ma-shared-files:$(FOREIGN_ARCH),pkg-ma-shared-files:$(FOREIGN_ARCH))
+ ! $(call stdout_is,$(DPKG_QUERY) -f'$${Package}' -W pkg-ma-shared-files,pkg-ma-shared-files)
+ $(call stdout_is,$(DPKG_QUERY) -f'$${Package}' -W pkg-ma-shared-files:$(NATIVE_ARCH),pkg-ma-shared-files)
+ $(call stdout_is,$(DPKG_QUERY) -f'$${Package}' -W pkg-ma-shared-files:$(FOREIGN_ARCH),pkg-ma-shared-files)
+ $(call stdout_has,$(DPKG_QUERY) -W,^pkg-ma-shared-files:$(FOREIGN_ARCH) 1.0$)
+ $(call stdout_has,$(DPKG_QUERY) --search $(common_file),(\, |^)pkg-ma-shared-files:$(NATIVE_ARCH)(\, |: ))
+ $(call stdout_has,$(DPKG_QUERY) --search $(common_file),(\, |^)pkg-ma-shared-files:$(FOREIGN_ARCH)(\, |: ))
+ $(call stdout_has,$(DPKG_QUERY) --list,^ii pkg-ma-shared-files:$(NATIVE_ARCH))
+ $(call stdout_has,$(DPKG_QUERY) --list,^ii pkg-ma-shared-files:$(FOREIGN_ARCH) )
+ $(call stdout_has,$(DPKG) --get-selections,^pkg-ma-shared-files:$(NATIVE_ARCH) +install$)
+ $(call stdout_has,$(DPKG) --get-selections,^pkg-ma-shared-files:$(FOREIGN_ARCH) +install$)
+ echo "pkg-ma-shared-files:$(NATIVE_ARCH) hold" | $(BEROOT) $(DPKG) --set-selections
+ $(call stdout_has,$(DPKG) --get-selections,^pkg-ma-shared-files:$(NATIVE_ARCH) +hold$)
+ $(call stdout_has,$(DPKG) --get-selections,^pkg-ma-shared-files:$(FOREIGN_ARCH) +install$)
+ echo "pkg-ma-shared-files:$(FOREIGN_ARCH) deinstall" | $(BEROOT) $(DPKG) --set-selections
+ $(call stdout_has,$(DPKG) --get-selections,^pkg-ma-shared-files:$(NATIVE_ARCH) +hold$)
+ $(call stdout_has,$(DPKG) --get-selections,^pkg-ma-shared-files:$(FOREIGN_ARCH) +deinstall$)
+ echo "pkg-ma-shared-files:$(NATIVE_ARCH) install" | $(BEROOT) $(DPKG) --set-selections
+ $(call stdout_has,$(DPKG) --get-selections,^pkg-ma-shared-files:$(NATIVE_ARCH) +install$)
+ $(call stdout_has,$(DPKG) --get-selections,^pkg-ma-shared-files:$(FOREIGN_ARCH) +deinstall$)
+ $(DPKG_PURGE) pkg-ma-shared-files:$(NATIVE_ARCH) pkg-ma-shared-files:$(FOREIGN_ARCH)
+
+pkg-ma-db-layout_1.0_$(NATIVE_ARCH):: pkg-template
+ touch pkg-ma-db-layout_1.0_$(NATIVE_ARCH)/DEBIAN/foo-1
+
+pkg-ma-db-layout_2.0_$(NATIVE_ARCH):: pkg-template
+ touch pkg-ma-db-layout_2.0_$(NATIVE_ARCH)/DEBIAN/foo-2
+
+test-db-layout: ma-setup
+ $(DPKG_INSTALL) pkg-ma-db-layout_1.0_$(NATIVE_ARCH).deb
+ test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.list"
+ test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.foo-1"
+ $(DPKG_INSTALL) pkg-ma-db-layout_2.0_$(NATIVE_ARCH).deb
+ ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.list"
+ ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.foo-1"
+ test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).list"
+ test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).foo-2"
+ $(DPKG_INSTALL) pkg-ma-db-layout_1.0_$(NATIVE_ARCH).deb
+ test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.list"
+ test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.foo-1"
+ ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).list"
+ ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).foo-2"
+ $(DPKG_PURGE) pkg-ma-db-layout
+ # Test the upgrade of the db layout
+ $(DPKG_INSTALL) pkg-ma-db-layout_2.0_$(NATIVE_ARCH).deb
+ rm -f "$(DPKG_ADMINDIR)/info/format"
+ mv "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).list" "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.list"
+ mv "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).foo-2" "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.foo-2"
+ $(call stdout_has,$(DPKG_QUERY) --control-path pkg-ma-db-layout foo-2,/pkg-ma-db-layout\.foo-2$$)
+ $(DPKG_CONFIGURE) -a
+ grep -q "^1$$" "$(DPKG_ADMINDIR)/info/format"
+ test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).list"
+ test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).foo-2"
+ ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.list"
+ ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.foo-2"
+ $(call stdout_has,$(DPKG_QUERY) --control-path pkg-ma-db-layout foo-2,/pkg-ma-db-layout:$(NATIVE_ARCH)\.foo-2$$)
+ $(DPKG_PURGE) pkg-ma-db-layout
+
+test-clean:
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/m-a/triggers"
+ $(DPKG_QUERY) -W | grep ^pkg-ma- | (while read pkg ver; do \
+ $(DPKG_PURGE) $$pkg; \
+ done)
+ -$(DPKG_DIVERT_DEL) --local --divert $(common_file).real $(common_file)
+ rm -f "$(DPKG_ADMINDIR)/arch"
diff --git a/tests/t-multiarch/pkg-template/DEBIAN/control b/tests/t-multiarch/pkg-template/DEBIAN/control
new file mode 100644
index 0000000..c1daefe
--- /dev/null
+++ b/tests/t-multiarch/pkg-template/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-template
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Multi-Arch: same
+Depends:
+Description: test package
diff --git a/tests/t-normal/Makefile b/tests/t-normal/Makefile
new file mode 100644
index 0000000..70e1dd0
--- /dev/null
+++ b/tests/t-normal/Makefile
@@ -0,0 +1,12 @@
+TESTS_DEB := pkg-normal
+
+include ../Test.mk
+
+test-case:
+ # test normal working packages
+ $(DPKG_INSTALL) pkg-normal.deb
+ $(call pkg_is_installed,pkg-normal)
+
+test-clean:
+ $(DPKG_PURGE) pkg-normal
+
diff --git a/tests/t-normal/pkg-normal/DEBIAN/control b/tests/t-normal/pkg-normal/DEBIAN/control
new file mode 100644
index 0000000..09e51b2
--- /dev/null
+++ b/tests/t-normal/pkg-normal/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-normal
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - normal
+
diff --git a/tests/t-option-dry-run/Makefile b/tests/t-option-dry-run/Makefile
new file mode 100644
index 0000000..b534a41
--- /dev/null
+++ b/tests/t-option-dry-run/Makefile
@@ -0,0 +1,32 @@
+TESTS_DEB := pkg-normal
+
+include ../Test.mk
+
+test-case:
+ # Make sure the package is not there
+ $(DPKG_PURGE) pkg-normal
+
+ # Simulate unpacking a package
+ $(DPKG_UNPACK) --dry-run pkg-normal.deb
+ $(call pkg_is_not_installed,pkg-normal)
+ $(DPKG_INSTALL) --dry-run pkg-normal.deb
+ $(call pkg_is_not_installed,pkg-normal)
+
+ $(DPKG_UNPACK) pkg-normal.deb
+
+ # Simulate configuring a package
+ $(DPKG_CONFIGURE) --dry-run pkg-normal
+ $(call pkg_status_is,pkg-normal,install ok unpacked)
+
+ $(DPKG_CONFIGURE) pkg-normal
+
+ # Simulate removing and purging a package
+ $(DPKG_REMOVE) --dry-run pkg-normal
+ $(call pkg_is_installed,pkg-normal)
+ $(DPKG_PURGE) --dry-run pkg-normal
+ $(call pkg_is_installed,pkg-normal)
+
+ # XXX: Complete
+
+test-clean:
+ $(DPKG_PURGE) pkg-normal
diff --git a/tests/t-option-dry-run/pkg-normal/DEBIAN/control b/tests/t-option-dry-run/pkg-normal/DEBIAN/control
new file mode 100644
index 0000000..09e51b2
--- /dev/null
+++ b/tests/t-option-dry-run/pkg-normal/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-normal
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - normal
+
diff --git a/tests/t-option-recursive/Makefile b/tests/t-option-recursive/Makefile
new file mode 100644
index 0000000..c0108ed
--- /dev/null
+++ b/tests/t-option-recursive/Makefile
@@ -0,0 +1,25 @@
+TESTS_DEB := dir-a/pkg-a dir-b/dir-bb/pkg-b pkg-c
+
+include ../Test.mk
+
+test-case:
+ # Try recursive directory unpacking of packages
+ $(DPKG_INSTALL) -R .
+ $(call pkg_is_unpacked,pkg-a)
+ $(call pkg_is_unpacked,pkg-b)
+ $(call pkg_is_unpacked,pkg-c)
+
+ $(DPKG_PURGE) pkg-a
+ $(DPKG_PURGE) pkg-b
+ $(DPKG_PURGE) pkg-c
+
+ # Try recursive directory installation of packages
+ $(DPKG_INSTALL) -R .
+ $(call pkg_is_installed,pkg-a)
+ $(call pkg_is_installed,pkg-b)
+ $(call pkg_is_installed,pkg-c)
+
+test-clean:
+ $(DPKG_PURGE) pkg-a
+ $(DPKG_PURGE) pkg-b
+ $(DPKG_PURGE) pkg-c
diff --git a/tests/t-option-recursive/dir-a/pkg-a/DEBIAN/control b/tests/t-option-recursive/dir-a/pkg-a/DEBIAN/control
new file mode 100644
index 0000000..af9ae1a
--- /dev/null
+++ b/tests/t-option-recursive/dir-a/pkg-a/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-a
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - normal
diff --git a/tests/t-option-recursive/dir-b/dir-bb/pkg-b/DEBIAN/control b/tests/t-option-recursive/dir-b/dir-bb/pkg-b/DEBIAN/control
new file mode 100644
index 0000000..e70151f
--- /dev/null
+++ b/tests/t-option-recursive/dir-b/dir-bb/pkg-b/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-b
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - normal
diff --git a/tests/t-option-recursive/pkg-c/DEBIAN/control b/tests/t-option-recursive/pkg-c/DEBIAN/control
new file mode 100644
index 0000000..2ae6c72
--- /dev/null
+++ b/tests/t-option-recursive/pkg-c/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-c
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - normal
diff --git a/tests/t-predepends-no-triggers/Makefile b/tests/t-predepends-no-triggers/Makefile
new file mode 100644
index 0000000..962cf93
--- /dev/null
+++ b/tests/t-predepends-no-triggers/Makefile
@@ -0,0 +1,28 @@
+TESTS_DEB := pkg-real pkg-predepends pkg-trigger
+
+include ../Test.mk
+
+test-case:
+ # Install the file trigger
+ $(DPKG_INSTALL) pkg-trigger.deb
+ # Install the pre-dependency with --no-triggers
+ $(DPKG_INSTALL) --no-triggers pkg-real.deb
+ $(call pkg_status_is,pkg-real,install ok triggers-awaited)
+ # Should pass even if not yet configured...
+ $(DPKG_UNPACK) --no-triggers pkg-predepends.deb
+ # ...by running the required triggers
+ $(call pkg_status_is,pkg-real,install ok installed)
+ # Retry again, this time the trigger processing is not required
+ # because pkg-real has already been configured once
+ $(DPKG_PURGE) pkg-predepends
+ $(DPKG_INSTALL) --no-triggers pkg-real.deb
+ $(call pkg_status_is,pkg-real,install ok triggers-awaited)
+ $(DPKG_UNPACK) --no-triggers pkg-predepends.deb
+ $(call pkg_status_is,pkg-real,install ok triggers-awaited)
+ # Cleanup
+ $(DPKG_PURGE) pkg-predepends
+ $(DPKG_PURGE) pkg-real
+ $(DPKG_PURGE) pkg-trigger
+
+test-clean:
+ -$(DPKG_PURGE) pkg-predepends pkg-real pkg-trigger
diff --git a/tests/t-predepends-no-triggers/pkg-predepends/DEBIAN/control b/tests/t-predepends-no-triggers/pkg-predepends/DEBIAN/control
new file mode 100644
index 0000000..33b5450
--- /dev/null
+++ b/tests/t-predepends-no-triggers/pkg-predepends/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-predepends
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Pre-Depends: pkg-real
+Description: test package - package pre-depending on a real package
diff --git a/tests/t-predepends-no-triggers/pkg-real/DEBIAN/control b/tests/t-predepends-no-triggers/pkg-real/DEBIAN/control
new file mode 100644
index 0000000..9428516
--- /dev/null
+++ b/tests/t-predepends-no-triggers/pkg-real/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-real
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - real package to pre-depend on
+ Contains a file that will activate a trigger.
diff --git a/tests/t-predepends-no-triggers/pkg-real/trigger/a-file b/tests/t-predepends-no-triggers/pkg-real/trigger/a-file
new file mode 100644
index 0000000..e7ee9ee
--- /dev/null
+++ b/tests/t-predepends-no-triggers/pkg-real/trigger/a-file
@@ -0,0 +1 @@
+Just a file.
diff --git a/tests/t-predepends-no-triggers/pkg-trigger/DEBIAN/control b/tests/t-predepends-no-triggers/pkg-trigger/DEBIAN/control
new file mode 100644
index 0000000..19519d9
--- /dev/null
+++ b/tests/t-predepends-no-triggers/pkg-trigger/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-trigger
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - interested in a file trigger on /trigger
+ Contains a file that will activate a trigger.
diff --git a/tests/t-predepends-no-triggers/pkg-trigger/DEBIAN/postinst b/tests/t-predepends-no-triggers/pkg-trigger/DEBIAN/postinst
new file mode 100755
index 0000000..c52d3c2
--- /dev/null
+++ b/tests/t-predepends-no-triggers/pkg-trigger/DEBIAN/postinst
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exit 0
diff --git a/tests/t-predepends-no-triggers/pkg-trigger/DEBIAN/triggers b/tests/t-predepends-no-triggers/pkg-trigger/DEBIAN/triggers
new file mode 100644
index 0000000..91238aa
--- /dev/null
+++ b/tests/t-predepends-no-triggers/pkg-trigger/DEBIAN/triggers
@@ -0,0 +1 @@
+interest /trigger
diff --git a/tests/t-provides-arch-implicit/Makefile b/tests/t-provides-arch-implicit/Makefile
new file mode 100644
index 0000000..4b1ffe3
--- /dev/null
+++ b/tests/t-provides-arch-implicit/Makefile
@@ -0,0 +1,24 @@
+TESTS_DEB := pkg-a pkg-b pkg-dep
+
+include ../Test.mk
+
+test-case:
+ $(DPKG) --add-architecture i386
+ $(DPKG) --add-architecture amd64
+ $(DPKG_INSTALL) pkg-a.deb
+ $(DPKG_INSTALL) pkg-b.deb
+ $(DPKG_INSTALL) pkg-dep.deb
+ ! $(DPKG_PURGE) pkg-b
+ $(DPKG_PURGE) pkg-a
+ $(DPKG_PURGE) pkg-dep
+ $(DPKG_PURGE) pkg-b
+
+ $(DPKG_INSTALL) pkg-a.deb
+ ! $(DPKG_INSTALL) pkg-dep.deb
+ $(DPKG_PURGE) pkg-a
+
+test-clean:
+ $(DPKG_PURGE) pkg-dep
+ $(DPKG_PURGE) pkg-b pkg-b
+ $(DPKG) --remove-architecture i386
+ $(DPKG) --remove-architecture amd64
diff --git a/tests/t-provides-arch-implicit/pkg-a/DEBIAN/control b/tests/t-provides-arch-implicit/pkg-a/DEBIAN/control
new file mode 100644
index 0000000..c2cab2e
--- /dev/null
+++ b/tests/t-provides-arch-implicit/pkg-a/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Provides: pkg-v
+Description: test package - provides a virtual package
+
diff --git a/tests/t-provides-arch-implicit/pkg-b/DEBIAN/control b/tests/t-provides-arch-implicit/pkg-b/DEBIAN/control
new file mode 100644
index 0000000..b7446bc
--- /dev/null
+++ b/tests/t-provides-arch-implicit/pkg-b/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Provides: pkg-v
+Description: test package - provides a virtual package
+
diff --git a/tests/t-provides-arch-implicit/pkg-dep/DEBIAN/control b/tests/t-provides-arch-implicit/pkg-dep/DEBIAN/control
new file mode 100644
index 0000000..b0eec43
--- /dev/null
+++ b/tests/t-provides-arch-implicit/pkg-dep/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-dep
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Depends: pkg-v
+Description: test package - depends on a virtual package
+
diff --git a/tests/t-provides-arch-qualified/Makefile b/tests/t-provides-arch-qualified/Makefile
new file mode 100644
index 0000000..0334b19
--- /dev/null
+++ b/tests/t-provides-arch-qualified/Makefile
@@ -0,0 +1,16 @@
+TESTS_DEB := pkg-a pkg-b
+
+include ../Test.mk
+
+test-case:
+ $(DPKG) --add-architecture i386
+ $(DPKG) --add-architecture amd64
+ $(DPKG_INSTALL) pkg-a.deb
+ # test if the conflicting package fails on install
+ ! $(DPKG_INSTALL) pkg-b.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-b
+ $(DPKG_PURGE) pkg-a
+ $(DPKG) --remove-architecture i386
+ $(DPKG) --remove-architecture amd64
diff --git a/tests/t-provides-arch-qualified/pkg-a/DEBIAN/control b/tests/t-provides-arch-qualified/pkg-a/DEBIAN/control
new file mode 100644
index 0000000..5b69929
--- /dev/null
+++ b/tests/t-provides-arch-qualified/pkg-a/DEBIAN/control
@@ -0,0 +1,10 @@
+Package: pkg-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: i386
+Multi-Arch: foreign
+Provides: pkg-v:armel
+Description: test package - provide an arch-qualified virtual package
+
diff --git a/tests/t-provides-arch-qualified/pkg-b/DEBIAN/control b/tests/t-provides-arch-qualified/pkg-b/DEBIAN/control
new file mode 100644
index 0000000..1fe149d
--- /dev/null
+++ b/tests/t-provides-arch-qualified/pkg-b/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Depends: pkg-v:mips
+Description: test package - unsatisfied virtual
+
diff --git a/tests/t-provides-self/Makefile b/tests/t-provides-self/Makefile
new file mode 100644
index 0000000..caa6886
--- /dev/null
+++ b/tests/t-provides-self/Makefile
@@ -0,0 +1,281 @@
+TESTS_DEB := \
+ pkg-provides pkg-provides-10 pkg-provides-20 pkg-provides-10-20 \
+ pkg-depends pkg-depends-eq pkg-depends-le pkg-depends-ge \
+ pkg-predepends pkg-predepends-eq pkg-predepends-le pkg-predepends-ge \
+ pkg-breaks pkg-breaks-eq pkg-breaks-le pkg-breaks-ge \
+ pkg-conflicts pkg-conflicts-eq pkg-conflicts-le pkg-conflicts-ge
+
+include ../Test.mk
+
+define PURGE_DEPENDS
+$(DPKG_PURGE) pkg-depends
+$(DPKG_PURGE) pkg-depends-le
+$(DPKG_PURGE) pkg-depends-eq
+$(DPKG_PURGE) pkg-depends-ge
+endef
+
+test-depends:
+ # The provided dependency is not present, fail
+ ! $(DPKG_INSTALL) pkg-depends.deb
+ ! $(DPKG_INSTALL) pkg-depends-eq.deb
+ ! $(DPKG_INSTALL) pkg-depends-le.deb
+ ! $(DPKG_INSTALL) pkg-depends-ge.deb
+
+ # Install the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ $(DPKG_INSTALL) pkg-depends.deb
+ ! $(DPKG_INSTALL) pkg-depends-eq.deb
+ ! $(DPKG_INSTALL) pkg-depends-le.deb
+ ! $(DPKG_INSTALL) pkg-depends-ge.deb
+ # Upgrade the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ ! $(DPKG_PURGE) pkg-provides
+
+ $(PURGE_DEPENDS)
+
+ # Install the providing package (pkg-provides 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+ $(DPKG_INSTALL) pkg-depends.deb
+ $(DPKG_INSTALL) pkg-depends-le.deb
+ ! $(DPKG_INSTALL) pkg-depends-eq.deb
+ ! $(DPKG_INSTALL) pkg-depends-ge.deb
+ # Upgrade the providing package (pkg-provides 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+
+ $(PURGE_DEPENDS)
+
+ # Install the providing package (pkg-provides 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+ $(DPKG_INSTALL) pkg-depends.deb
+ $(DPKG_INSTALL) pkg-depends-eq.deb
+ ! $(DPKG_INSTALL) pkg-depends-le.deb
+ $(DPKG_INSTALL) pkg-depends-ge.deb
+ # Upgrade the providing package (pkg-provides 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+
+ $(PURGE_DEPENDS)
+
+ # Install the providing package (pkg-provides 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+ $(DPKG_INSTALL) pkg-depends.deb
+ $(DPKG_INSTALL) pkg-depends-eq.deb
+ $(DPKG_INSTALL) pkg-depends-le.deb
+ $(DPKG_INSTALL) pkg-depends-ge.deb
+ # Upgrade the providing package (pkg-provides 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+
+ $(PURGE_DEPENDS)
+
+ # The provided dependency is removed, pass
+ $(DPKG_PURGE) pkg-provides
+
+define PURGE_PREDEPENDS
+$(DPKG_PURGE) pkg-predepends
+$(DPKG_PURGE) pkg-predepends-le
+$(DPKG_PURGE) pkg-predepends-eq
+$(DPKG_PURGE) pkg-predepends-ge
+endef
+
+test-predepends:
+ # The provided predependency is not present, fail
+ ! $(DPKG_UNPACK) pkg-predepends.deb
+ ! $(DPKG_UNPACK) pkg-predepends-eq.deb
+ ! $(DPKG_UNPACK) pkg-predepends-le.deb
+ ! $(DPKG_UNPACK) pkg-predepends-ge.deb
+
+ # Install the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ $(DPKG_UNPACK) pkg-predepends.deb
+ ! $(DPKG_UNPACK) pkg-predepends-eq.deb
+ ! $(DPKG_UNPACK) pkg-predepends-le.deb
+ ! $(DPKG_UNPACK) pkg-predepends-ge.deb
+ # Upgrade the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ ! $(DPKG_PURGE) pkg-provides
+
+ $(PURGE_PREDEPENDS)
+
+ # Install the providing package (pkg-provides 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+ $(DPKG_UNPACK) pkg-predepends.deb
+ $(DPKG_UNPACK) pkg-predepends-le.deb
+ ! $(DPKG_UNPACK) pkg-predepends-eq.deb
+ ! $(DPKG_UNPACK) pkg-predepends-ge.deb
+ # Upgrade the providing package (pkg-provides 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+
+ $(PURGE_PREDEPENDS)
+
+ # Install the providing package (pkg-provides 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+ $(DPKG_UNPACK) pkg-predepends.deb
+ $(DPKG_UNPACK) pkg-predepends-eq.deb
+ ! $(DPKG_UNPACK) pkg-predepends-le.deb
+ $(DPKG_UNPACK) pkg-predepends-ge.deb
+ # Upgrade the providing package (pkg-provides 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+
+ $(PURGE_PREDEPENDS)
+
+ # Install the providing package (pkg-provides 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+ $(DPKG_UNPACK) pkg-predepends.deb
+ $(DPKG_UNPACK) pkg-predepends-eq.deb
+ $(DPKG_UNPACK) pkg-predepends-le.deb
+ $(DPKG_UNPACK) pkg-predepends-ge.deb
+ # Upgrade the providing package (pkg-provides 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+
+ $(PURGE_PREDEPENDS)
+
+ # The provided predependency is removed, pass
+ $(DPKG_PURGE) pkg-provides
+
+define PURGE_BREAKS
+$(DPKG_PURGE) pkg-breaks
+$(DPKG_PURGE) pkg-breaks-le
+$(DPKG_PURGE) pkg-breaks-eq
+$(DPKG_PURGE) pkg-breaks-ge
+endef
+
+test-breaks:
+ # The provided dependency is not present, pass
+ $(DPKG_INSTALL) pkg-breaks.deb
+ $(DPKG_INSTALL) pkg-breaks-eq.deb
+ $(DPKG_INSTALL) pkg-breaks-le.deb
+ $(DPKG_INSTALL) pkg-breaks-ge.deb
+
+ $(PURGE_BREAKS)
+
+ # Install the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ ! $(DPKG_INSTALL) pkg-breaks.deb
+ $(DPKG_INSTALL) pkg-breaks-eq.deb
+ $(DPKG_INSTALL) pkg-breaks-le.deb
+ $(DPKG_INSTALL) pkg-breaks-ge.deb
+ # Upgrade the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ $(DPKG_PURGE) pkg-provides
+
+ $(PURGE_BREAKS)
+
+ # Install the providing package (pkg-provides 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+ ! $(DPKG_INSTALL) pkg-breaks.deb
+ ! $(DPKG_INSTALL) pkg-breaks-le.deb
+ $(DPKG_INSTALL) pkg-breaks-eq.deb
+ $(DPKG_INSTALL) pkg-breaks-ge.deb
+ # Upgrade the providing package (pkg-provides 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+
+ $(PURGE_BREAKS)
+
+ # Install the providing package (pkg-provides 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+ ! $(DPKG_INSTALL) pkg-breaks.deb
+ ! $(DPKG_INSTALL) pkg-breaks-eq.deb
+ $(DPKG_INSTALL) pkg-breaks-le.deb
+ ! $(DPKG_INSTALL) pkg-breaks-ge.deb
+ # Upgrade the providing package (pkg-provides 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+
+ $(PURGE_BREAKS)
+
+ # Install the providing package (pkg-provides 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+ ! $(DPKG_INSTALL) pkg-breaks.deb
+ ! $(DPKG_INSTALL) pkg-breaks-eq.deb
+ ! $(DPKG_INSTALL) pkg-breaks-le.deb
+ ! $(DPKG_INSTALL) pkg-breaks-ge.deb
+ # Upgrade the providing package (pkg-provides 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+
+ $(PURGE_BREAKS)
+
+ # The provided dependency is removed, pass
+ $(DPKG_PURGE) pkg-provides
+
+define PURGE_CONFLICTS
+$(DPKG_PURGE) pkg-conflicts
+$(DPKG_PURGE) pkg-conflicts-le
+$(DPKG_PURGE) pkg-conflicts-eq
+$(DPKG_PURGE) pkg-conflicts-ge
+endef
+
+test-conflicts:
+ # The provided predependency is not present, fail
+ $(DPKG_UNPACK) pkg-conflicts.deb
+ $(DPKG_UNPACK) pkg-conflicts-eq.deb
+ $(DPKG_UNPACK) pkg-conflicts-le.deb
+ $(DPKG_UNPACK) pkg-conflicts-ge.deb
+
+ $(PURGE_CONFLICTS)
+
+ # Install the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ ! $(DPKG_UNPACK) pkg-conflicts.deb
+ $(DPKG_UNPACK) pkg-conflicts-eq.deb
+ $(DPKG_UNPACK) pkg-conflicts-le.deb
+ $(DPKG_UNPACK) pkg-conflicts-ge.deb
+ # Upgrade the providing package (pkg-provides versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ $(DPKG_PURGE) pkg-provides
+
+ $(PURGE_CONFLICTS)
+
+ # Install the providing package (pkg-provides 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+ ! $(DPKG_UNPACK) pkg-conflicts.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-le.deb
+ $(DPKG_UNPACK) pkg-conflicts-eq.deb
+ $(DPKG_UNPACK) pkg-conflicts-ge.deb
+ # Upgrade the providing package (pkg-provides 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+
+ $(PURGE_CONFLICTS)
+
+ # Install the providing package (pkg-provides 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+ ! $(DPKG_UNPACK) pkg-conflicts.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-eq.deb
+ $(DPKG_UNPACK) pkg-conflicts-le.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-ge.deb
+ # Upgrade the providing package (pkg-provides 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+
+ $(PURGE_CONFLICTS)
+
+ # Install the providing package (pkg-provides 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+ ! $(DPKG_UNPACK) pkg-conflicts.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-eq.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-le.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-ge.deb
+ # Upgrade the providing package (pkg-provides 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+
+ $(PURGE_CONFLICTS)
+
+ # The provided predependency is removed, pass
+ $(DPKG_PURGE) pkg-provides
+
+test-case: test-depends test-predepends test-breaks test-conflicts
+
+test-clean:
+ -$(DPKG_PURGE) pkg-depends
+ -$(DPKG_PURGE) pkg-depends-eq
+ -$(DPKG_PURGE) pkg-depends-ge
+ -$(DPKG_PURGE) pkg-depends-le
+ -$(DPKG_PURGE) pkg-predepends
+ -$(DPKG_PURGE) pkg-predepends-eq
+ -$(DPKG_PURGE) pkg-predepends-ge
+ -$(DPKG_PURGE) pkg-predepends-le
+ -$(DPKG_PURGE) pkg-breaks
+ -$(DPKG_PURGE) pkg-breaks-eq
+ -$(DPKG_PURGE) pkg-breaks-ge
+ -$(DPKG_PURGE) pkg-breaks-le
+ -$(DPKG_PURGE) pkg-conflicts
+ -$(DPKG_PURGE) pkg-conflicts-eq
+ -$(DPKG_PURGE) pkg-conflicts-ge
+ -$(DPKG_PURGE) pkg-conflicts-le
+ -$(DPKG_PURGE) pkg-provides
diff --git a/tests/t-provides-self/pkg-breaks-eq/DEBIAN/control b/tests/t-provides-self/pkg-breaks-eq/DEBIAN/control
new file mode 100644
index 0000000..b6a6edd
--- /dev/null
+++ b/tests/t-provides-self/pkg-breaks-eq/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-breaks-eq
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: pkg-provides (= 20)
+Description: test package - package breaking on a virtual package
diff --git a/tests/t-provides-self/pkg-breaks-ge/DEBIAN/control b/tests/t-provides-self/pkg-breaks-ge/DEBIAN/control
new file mode 100644
index 0000000..223d00c
--- /dev/null
+++ b/tests/t-provides-self/pkg-breaks-ge/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-breaks-ge
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: pkg-provides (>= 20)
+Description: test package - package breaking on a virtual package
diff --git a/tests/t-provides-self/pkg-breaks-le/DEBIAN/control b/tests/t-provides-self/pkg-breaks-le/DEBIAN/control
new file mode 100644
index 0000000..3326245
--- /dev/null
+++ b/tests/t-provides-self/pkg-breaks-le/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-breaks-le
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: pkg-provides (<= 10)
+Description: test package - package breaking on a virtual package
diff --git a/tests/t-provides-self/pkg-breaks/DEBIAN/control b/tests/t-provides-self/pkg-breaks/DEBIAN/control
new file mode 100644
index 0000000..188486f
--- /dev/null
+++ b/tests/t-provides-self/pkg-breaks/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-breaks
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: pkg-provides
+Description: test package - package breaking on a virtual package
diff --git a/tests/t-provides-self/pkg-conflicts-eq/DEBIAN/control b/tests/t-provides-self/pkg-conflicts-eq/DEBIAN/control
new file mode 100644
index 0000000..0ad703c
--- /dev/null
+++ b/tests/t-provides-self/pkg-conflicts-eq/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conflicts-eq
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-provides (= 20)
+Description: test package - package conflicting on a virtual package
diff --git a/tests/t-provides-self/pkg-conflicts-ge/DEBIAN/control b/tests/t-provides-self/pkg-conflicts-ge/DEBIAN/control
new file mode 100644
index 0000000..cccc1d0
--- /dev/null
+++ b/tests/t-provides-self/pkg-conflicts-ge/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conflicts-ge
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-provides (>= 20)
+Description: test package - package conflicting on a virtual package
diff --git a/tests/t-provides-self/pkg-conflicts-le/DEBIAN/control b/tests/t-provides-self/pkg-conflicts-le/DEBIAN/control
new file mode 100644
index 0000000..e34a5c0
--- /dev/null
+++ b/tests/t-provides-self/pkg-conflicts-le/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conflicts-le
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-provides (<= 10)
+Description: test package - package conflicting on a virtual package
diff --git a/tests/t-provides-self/pkg-conflicts/DEBIAN/control b/tests/t-provides-self/pkg-conflicts/DEBIAN/control
new file mode 100644
index 0000000..90efe2b
--- /dev/null
+++ b/tests/t-provides-self/pkg-conflicts/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conflicts
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-provides
+Description: test package - package conflicting on a virtual package
diff --git a/tests/t-provides-self/pkg-depends-eq/DEBIAN/control b/tests/t-provides-self/pkg-depends-eq/DEBIAN/control
new file mode 100644
index 0000000..2266b03
--- /dev/null
+++ b/tests/t-provides-self/pkg-depends-eq/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-eq
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-provides (= 20)
+Description: test package - package depending on a virtual package
diff --git a/tests/t-provides-self/pkg-depends-ge/DEBIAN/control b/tests/t-provides-self/pkg-depends-ge/DEBIAN/control
new file mode 100644
index 0000000..60867d6
--- /dev/null
+++ b/tests/t-provides-self/pkg-depends-ge/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-ge
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-provides (>= 20)
+Description: test package - package depending on a virtual package
diff --git a/tests/t-provides-self/pkg-depends-le/DEBIAN/control b/tests/t-provides-self/pkg-depends-le/DEBIAN/control
new file mode 100644
index 0000000..45136eb
--- /dev/null
+++ b/tests/t-provides-self/pkg-depends-le/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-le
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-provides (<= 10)
+Description: test package - package depending on a virtual package
diff --git a/tests/t-provides-self/pkg-depends/DEBIAN/control b/tests/t-provides-self/pkg-depends/DEBIAN/control
new file mode 100644
index 0000000..d07cc45
--- /dev/null
+++ b/tests/t-provides-self/pkg-depends/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-provides
+Description: test package - package depending on a virtual package
diff --git a/tests/t-provides-self/pkg-predepends-eq/DEBIAN/control b/tests/t-provides-self/pkg-predepends-eq/DEBIAN/control
new file mode 100644
index 0000000..11e7a0a
--- /dev/null
+++ b/tests/t-provides-self/pkg-predepends-eq/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-predepends-eq
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Pre-Depends: pkg-provides (= 20)
+Description: test package - package pre-depending on a virtual package
diff --git a/tests/t-provides-self/pkg-predepends-ge/DEBIAN/control b/tests/t-provides-self/pkg-predepends-ge/DEBIAN/control
new file mode 100644
index 0000000..ff8d720
--- /dev/null
+++ b/tests/t-provides-self/pkg-predepends-ge/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-predepends-ge
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Pre-Depends: pkg-provides (>= 20)
+Description: test package - package pre-depending on a virtual package
diff --git a/tests/t-provides-self/pkg-predepends-le/DEBIAN/control b/tests/t-provides-self/pkg-predepends-le/DEBIAN/control
new file mode 100644
index 0000000..b7df6fb
--- /dev/null
+++ b/tests/t-provides-self/pkg-predepends-le/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-predepends-le
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Pre-Depends: pkg-provides (<= 10)
+Description: test package - package pre-depending on a virtual package
diff --git a/tests/t-provides-self/pkg-predepends/DEBIAN/control b/tests/t-provides-self/pkg-predepends/DEBIAN/control
new file mode 100644
index 0000000..8423965
--- /dev/null
+++ b/tests/t-provides-self/pkg-predepends/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-predepends
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Pre-Depends: pkg-provides
+Description: test package - package pre-depending on a virtual package
diff --git a/tests/t-provides-self/pkg-provides-10-20/DEBIAN/control b/tests/t-provides-self/pkg-provides-10-20/DEBIAN/control
new file mode 100644
index 0000000..37dbe97
--- /dev/null
+++ b/tests/t-provides-self/pkg-provides-10-20/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-provides
+Version: 10
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Provides: pkg-provides (= 20)
+Description: test package - package providing a versioned virtual package
diff --git a/tests/t-provides-self/pkg-provides-10/DEBIAN/control b/tests/t-provides-self/pkg-provides-10/DEBIAN/control
new file mode 100644
index 0000000..5fa91ae
--- /dev/null
+++ b/tests/t-provides-self/pkg-provides-10/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-provides
+Version: 10
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Provides: pkg-provides (= 10)
+Description: test package - package providing a versioned virtual package
diff --git a/tests/t-provides-self/pkg-provides-20/DEBIAN/control b/tests/t-provides-self/pkg-provides-20/DEBIAN/control
new file mode 100644
index 0000000..3c94af2
--- /dev/null
+++ b/tests/t-provides-self/pkg-provides-20/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-provides
+Version: 20
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Provides: pkg-provides (= 20)
+Description: test package - package providing a versioned virtual package
diff --git a/tests/t-provides-self/pkg-provides/DEBIAN/control b/tests/t-provides-self/pkg-provides/DEBIAN/control
new file mode 100644
index 0000000..865b72a
--- /dev/null
+++ b/tests/t-provides-self/pkg-provides/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-provides
+Version: 15
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Provides: pkg-provides
+Description: test package - package providing a virtual package
diff --git a/tests/t-provides/Makefile b/tests/t-provides/Makefile
new file mode 100644
index 0000000..6794c20
--- /dev/null
+++ b/tests/t-provides/Makefile
@@ -0,0 +1,307 @@
+TESTS_DEB := \
+ pkg-provides pkg-provides-10 pkg-provides-20 pkg-provides-10-20 \
+ pkg-depends pkg-depends-eq pkg-depends-le pkg-depends-ge \
+ pkg-predepends pkg-predepends-eq pkg-predepends-le pkg-predepends-ge \
+ pkg-breaks pkg-breaks-eq pkg-breaks-le pkg-breaks-ge \
+ pkg-conflicts pkg-conflicts-eq pkg-conflicts-le pkg-conflicts-ge \
+ pkg-a-depends-ge-lt pkg-b-provides-10 pkg-c-provides-20
+
+include ../Test.mk
+
+define PURGE_DEPENDS
+$(DPKG_PURGE) pkg-depends
+$(DPKG_PURGE) pkg-depends-le
+$(DPKG_PURGE) pkg-depends-eq
+$(DPKG_PURGE) pkg-depends-ge
+endef
+
+test-depends:
+ # The provided dependency is not present, fail
+ ! $(DPKG_INSTALL) pkg-depends.deb
+ ! $(DPKG_INSTALL) pkg-depends-eq.deb
+ ! $(DPKG_INSTALL) pkg-depends-le.deb
+ ! $(DPKG_INSTALL) pkg-depends-ge.deb
+
+ # Install the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ $(DPKG_INSTALL) pkg-depends.deb
+ ! $(DPKG_INSTALL) pkg-depends-eq.deb
+ ! $(DPKG_INSTALL) pkg-depends-le.deb
+ ! $(DPKG_INSTALL) pkg-depends-ge.deb
+ # Upgrade the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ ! $(DPKG_PURGE) pkg-provides
+
+ $(PURGE_DEPENDS)
+
+ # Install the providing package (pkg-virtual 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+ $(DPKG_INSTALL) pkg-depends.deb
+ $(DPKG_INSTALL) pkg-depends-le.deb
+ ! $(DPKG_INSTALL) pkg-depends-eq.deb
+ ! $(DPKG_INSTALL) pkg-depends-ge.deb
+ # Upgrade the providing package (pkg-virtual 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+
+ $(PURGE_DEPENDS)
+
+ # Install the providing package (pkg-virtual 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+ $(DPKG_INSTALL) pkg-depends.deb
+ $(DPKG_INSTALL) pkg-depends-eq.deb
+ ! $(DPKG_INSTALL) pkg-depends-le.deb
+ $(DPKG_INSTALL) pkg-depends-ge.deb
+ # Upgrade the providing package (pkg-virtual 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+
+ $(PURGE_DEPENDS)
+
+ # Install the providing package (pkg-virtual 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+ $(DPKG_INSTALL) pkg-depends.deb
+ $(DPKG_INSTALL) pkg-depends-eq.deb
+ $(DPKG_INSTALL) pkg-depends-le.deb
+ $(DPKG_INSTALL) pkg-depends-ge.deb
+ # Upgrade the providing package (pkg-virtual 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+
+ $(PURGE_DEPENDS)
+
+ $(DPKG_PURGE) pkg-provides
+
+ # Install the providing package (pkg-virtual 20)
+ $(DPKG_INSTALL) pkg-c-provides-20.deb
+ ! $(DPKG_INSTALL) pkg-a-depends-ge-lt.deb
+ $(DPKG_PURGE) pkg-a-depends-ge-lt
+ $(DPKG_PURGE) pkg-c-provides
+
+ # Install the providing package (pkg-virtual 10)
+ $(DPKG_INSTALL) pkg-b-provides-10.deb
+ $(DPKG_INSTALL) pkg-a-depends-ge-lt.deb
+ # Install the providing package (pkg-virtual 20)
+ $(DPKG_INSTALL) pkg-c-provides-20.deb
+
+ # Cannot purge the only package satisfying the dependency
+ ! $(DPKG_PURGE) pkg-b-provides
+ # Can purge package not satisfying the dependency
+ $(DPKG_PURGE) pkg-c-provides
+
+ $(DPKG_PURGE) pkg-a-depends-ge-lt
+ $(DPKG_PURGE) pkg-b-provides
+
+ # The provided dependency is removed, pass
+ $(DPKG_PURGE) pkg-provides
+
+define PURGE_PREDEPENDS
+$(DPKG_PURGE) pkg-predepends
+$(DPKG_PURGE) pkg-predepends-le
+$(DPKG_PURGE) pkg-predepends-eq
+$(DPKG_PURGE) pkg-predepends-ge
+endef
+
+test-predepends:
+ # The provided predependency is not present, fail
+ ! $(DPKG_UNPACK) pkg-predepends.deb
+ ! $(DPKG_UNPACK) pkg-predepends-eq.deb
+ ! $(DPKG_UNPACK) pkg-predepends-le.deb
+ ! $(DPKG_UNPACK) pkg-predepends-ge.deb
+
+ # Install the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ $(DPKG_UNPACK) pkg-predepends.deb
+ ! $(DPKG_UNPACK) pkg-predepends-eq.deb
+ ! $(DPKG_UNPACK) pkg-predepends-le.deb
+ ! $(DPKG_UNPACK) pkg-predepends-ge.deb
+ # Upgrade the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ ! $(DPKG_PURGE) pkg-provides
+
+ $(PURGE_PREDEPENDS)
+
+ # Install the providing package (pkg-virtual 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+ $(DPKG_UNPACK) pkg-predepends.deb
+ $(DPKG_UNPACK) pkg-predepends-le.deb
+ ! $(DPKG_UNPACK) pkg-predepends-eq.deb
+ ! $(DPKG_UNPACK) pkg-predepends-ge.deb
+ # Upgrade the providing package (pkg-virtual 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+
+ $(PURGE_PREDEPENDS)
+
+ # Install the providing package (pkg-virtual 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+ $(DPKG_UNPACK) pkg-predepends.deb
+ $(DPKG_UNPACK) pkg-predepends-eq.deb
+ ! $(DPKG_UNPACK) pkg-predepends-le.deb
+ $(DPKG_UNPACK) pkg-predepends-ge.deb
+ # Upgrade the providing package (pkg-virtual 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+
+ $(PURGE_PREDEPENDS)
+
+ # Install the providing package (pkg-virtual 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+ $(DPKG_UNPACK) pkg-predepends.deb
+ $(DPKG_UNPACK) pkg-predepends-eq.deb
+ $(DPKG_UNPACK) pkg-predepends-le.deb
+ $(DPKG_UNPACK) pkg-predepends-ge.deb
+ # Upgrade the providing package (pkg-virtual 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+
+ $(PURGE_PREDEPENDS)
+
+ # The provided predependency is removed, pass
+ $(DPKG_PURGE) pkg-provides
+
+define PURGE_BREAKS
+$(DPKG_PURGE) pkg-breaks
+$(DPKG_PURGE) pkg-breaks-le
+$(DPKG_PURGE) pkg-breaks-eq
+$(DPKG_PURGE) pkg-breaks-ge
+endef
+
+test-breaks:
+ # The provided dependency is not present, pass
+ $(DPKG_INSTALL) pkg-breaks.deb
+ $(DPKG_INSTALL) pkg-breaks-eq.deb
+ $(DPKG_INSTALL) pkg-breaks-le.deb
+ $(DPKG_INSTALL) pkg-breaks-ge.deb
+
+ $(PURGE_BREAKS)
+
+ # Install the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ ! $(DPKG_INSTALL) pkg-breaks.deb
+ $(DPKG_INSTALL) pkg-breaks-eq.deb
+ $(DPKG_INSTALL) pkg-breaks-le.deb
+ $(DPKG_INSTALL) pkg-breaks-ge.deb
+ # Upgrade the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ $(DPKG_PURGE) pkg-provides
+
+ $(PURGE_BREAKS)
+
+ # Install the providing package (pkg-virtual 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+ ! $(DPKG_INSTALL) pkg-breaks.deb
+ ! $(DPKG_INSTALL) pkg-breaks-le.deb
+ $(DPKG_INSTALL) pkg-breaks-eq.deb
+ $(DPKG_INSTALL) pkg-breaks-ge.deb
+ # Upgrade the providing package (pkg-virtual 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+
+ $(PURGE_BREAKS)
+
+ # Install the providing package (pkg-virtual 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+ ! $(DPKG_INSTALL) pkg-breaks.deb
+ ! $(DPKG_INSTALL) pkg-breaks-eq.deb
+ $(DPKG_INSTALL) pkg-breaks-le.deb
+ ! $(DPKG_INSTALL) pkg-breaks-ge.deb
+ # Upgrade the providing package (pkg-virtual 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+
+ $(PURGE_BREAKS)
+
+ # Install the providing package (pkg-virtual 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+ ! $(DPKG_INSTALL) pkg-breaks.deb
+ ! $(DPKG_INSTALL) pkg-breaks-eq.deb
+ ! $(DPKG_INSTALL) pkg-breaks-le.deb
+ ! $(DPKG_INSTALL) pkg-breaks-ge.deb
+ # Upgrade the providing package (pkg-virtual 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+
+ $(PURGE_BREAKS)
+
+ # The provided dependency is removed, pass
+ $(DPKG_PURGE) pkg-provides
+
+define PURGE_CONFLICTS
+$(DPKG_PURGE) pkg-conflicts
+$(DPKG_PURGE) pkg-conflicts-le
+$(DPKG_PURGE) pkg-conflicts-eq
+$(DPKG_PURGE) pkg-conflicts-ge
+endef
+
+test-conflicts:
+ # The provided predependency is not present, fail
+ $(DPKG_UNPACK) pkg-conflicts.deb
+ $(DPKG_UNPACK) pkg-conflicts-eq.deb
+ $(DPKG_UNPACK) pkg-conflicts-le.deb
+ $(DPKG_UNPACK) pkg-conflicts-ge.deb
+
+ $(PURGE_CONFLICTS)
+
+ # Install the providing package (versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ ! $(DPKG_UNPACK) pkg-conflicts.deb
+ $(DPKG_UNPACK) pkg-conflicts-eq.deb
+ $(DPKG_UNPACK) pkg-conflicts-le.deb
+ $(DPKG_UNPACK) pkg-conflicts-ge.deb
+ # Upgrade the providing package (pkg-virtual versionless)
+ $(DPKG_INSTALL) pkg-provides.deb
+ $(DPKG_PURGE) pkg-provides
+
+ $(PURGE_CONFLICTS)
+
+ # Install the providing package (pkg-virtual 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+ ! $(DPKG_UNPACK) pkg-conflicts.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-le.deb
+ $(DPKG_UNPACK) pkg-conflicts-eq.deb
+ $(DPKG_UNPACK) pkg-conflicts-ge.deb
+ # Upgrade the providing package (pkg-virtual 10)
+ $(DPKG_INSTALL) pkg-provides-10.deb
+
+ $(PURGE_CONFLICTS)
+
+ # Install the providing package (pkg-virtual 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+ ! $(DPKG_UNPACK) pkg-conflicts.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-eq.deb
+ $(DPKG_UNPACK) pkg-conflicts-le.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-ge.deb
+ # Upgrade the providing package (pkg-virtual 20)
+ $(DPKG_INSTALL) pkg-provides-20.deb
+
+ $(PURGE_CONFLICTS)
+
+ # Install the providing package (pkg-virtual 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+ ! $(DPKG_UNPACK) pkg-conflicts.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-eq.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-le.deb
+ ! $(DPKG_UNPACK) pkg-conflicts-ge.deb
+ # Upgrade the providing package (pkg-virtual 10 && 20)
+ $(DPKG_INSTALL) pkg-provides-10-20.deb
+
+ $(PURGE_CONFLICTS)
+
+ # The provided predependency is removed, pass
+ $(DPKG_PURGE) pkg-provides
+
+test-case: test-depends test-predepends test-breaks test-conflicts
+
+test-clean:
+ -$(DPKG_PURGE) pkg-depends
+ -$(DPKG_PURGE) pkg-depends-eq
+ -$(DPKG_PURGE) pkg-depends-ge
+ -$(DPKG_PURGE) pkg-depends-le
+ -$(DPKG_PURGE) pkg-predepends
+ -$(DPKG_PURGE) pkg-predepends-eq
+ -$(DPKG_PURGE) pkg-predepends-ge
+ -$(DPKG_PURGE) pkg-predepends-le
+ -$(DPKG_PURGE) pkg-breaks
+ -$(DPKG_PURGE) pkg-breaks-eq
+ -$(DPKG_PURGE) pkg-breaks-ge
+ -$(DPKG_PURGE) pkg-breaks-le
+ -$(DPKG_PURGE) pkg-conflicts
+ -$(DPKG_PURGE) pkg-conflicts-eq
+ -$(DPKG_PURGE) pkg-conflicts-ge
+ -$(DPKG_PURGE) pkg-conflicts-le
+ -$(DPKG_PURGE) pkg-provides
+ -$(DPKG_PURGE) pkg-a-depends-ge-lt
+ -$(DPKG_PURGE) pkg-b-provides
+ -$(DPKG_PURGE) pkg-c-provides
diff --git a/tests/t-provides/pkg-a-depends-ge-lt/DEBIAN/control b/tests/t-provides/pkg-a-depends-ge-lt/DEBIAN/control
new file mode 100644
index 0000000..77cc4b0
--- /dev/null
+++ b/tests/t-provides/pkg-a-depends-ge-lt/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-a-depends-ge-lt
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-virtual (>= 10), pkg-virtual (<< 20)
+Description: test package - package depending on a virtual package
diff --git a/tests/t-provides/pkg-b-provides-10/DEBIAN/control b/tests/t-provides/pkg-b-provides-10/DEBIAN/control
new file mode 100644
index 0000000..105d44c
--- /dev/null
+++ b/tests/t-provides/pkg-b-provides-10/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-b-provides
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Provides: pkg-virtual (= 10)
+Description: test package - package providing a versioned virtual package
diff --git a/tests/t-provides/pkg-breaks-eq/DEBIAN/control b/tests/t-provides/pkg-breaks-eq/DEBIAN/control
new file mode 100644
index 0000000..67d20b1
--- /dev/null
+++ b/tests/t-provides/pkg-breaks-eq/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-breaks-eq
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: pkg-virtual (= 20)
+Description: test package - package breaking on a virtual package
diff --git a/tests/t-provides/pkg-breaks-ge/DEBIAN/control b/tests/t-provides/pkg-breaks-ge/DEBIAN/control
new file mode 100644
index 0000000..33caed5
--- /dev/null
+++ b/tests/t-provides/pkg-breaks-ge/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-breaks-ge
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: pkg-virtual (>= 20)
+Description: test package - package breaking on a virtual package
diff --git a/tests/t-provides/pkg-breaks-le/DEBIAN/control b/tests/t-provides/pkg-breaks-le/DEBIAN/control
new file mode 100644
index 0000000..05152e2
--- /dev/null
+++ b/tests/t-provides/pkg-breaks-le/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-breaks-le
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: pkg-virtual (<= 10)
+Description: test package - package breaking on a virtual package
diff --git a/tests/t-provides/pkg-breaks/DEBIAN/control b/tests/t-provides/pkg-breaks/DEBIAN/control
new file mode 100644
index 0000000..6857392
--- /dev/null
+++ b/tests/t-provides/pkg-breaks/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-breaks
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: pkg-virtual
+Description: test package - package breaking on a virtual package
diff --git a/tests/t-provides/pkg-c-provides-20/DEBIAN/control b/tests/t-provides/pkg-c-provides-20/DEBIAN/control
new file mode 100644
index 0000000..a69d26a
--- /dev/null
+++ b/tests/t-provides/pkg-c-provides-20/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-c-provides
+Version: 2
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Provides: pkg-virtual (= 20)
+Description: test package - package providing a versioned virtual package
diff --git a/tests/t-provides/pkg-conflicts-eq/DEBIAN/control b/tests/t-provides/pkg-conflicts-eq/DEBIAN/control
new file mode 100644
index 0000000..ca077d1
--- /dev/null
+++ b/tests/t-provides/pkg-conflicts-eq/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conflicts-eq
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-virtual (= 20)
+Description: test package - package conflicting on a virtual package
diff --git a/tests/t-provides/pkg-conflicts-ge/DEBIAN/control b/tests/t-provides/pkg-conflicts-ge/DEBIAN/control
new file mode 100644
index 0000000..d93415f
--- /dev/null
+++ b/tests/t-provides/pkg-conflicts-ge/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conflicts-ge
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-virtual (>= 20)
+Description: test package - package conflicting on a virtual package
diff --git a/tests/t-provides/pkg-conflicts-le/DEBIAN/control b/tests/t-provides/pkg-conflicts-le/DEBIAN/control
new file mode 100644
index 0000000..4f62226
--- /dev/null
+++ b/tests/t-provides/pkg-conflicts-le/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conflicts-le
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-virtual (<= 10)
+Description: test package - package conflicting on a virtual package
diff --git a/tests/t-provides/pkg-conflicts/DEBIAN/control b/tests/t-provides/pkg-conflicts/DEBIAN/control
new file mode 100644
index 0000000..1b03248
--- /dev/null
+++ b/tests/t-provides/pkg-conflicts/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-conflicts
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Conflicts: pkg-virtual
+Description: test package - package conflicting on a virtual package
diff --git a/tests/t-provides/pkg-depends-eq/DEBIAN/control b/tests/t-provides/pkg-depends-eq/DEBIAN/control
new file mode 100644
index 0000000..b0c1bc5
--- /dev/null
+++ b/tests/t-provides/pkg-depends-eq/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-eq
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-virtual (= 20)
+Description: test package - package depending on a virtual package
diff --git a/tests/t-provides/pkg-depends-ge/DEBIAN/control b/tests/t-provides/pkg-depends-ge/DEBIAN/control
new file mode 100644
index 0000000..7c874a4
--- /dev/null
+++ b/tests/t-provides/pkg-depends-ge/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-ge
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-virtual (>= 20)
+Description: test package - package depending on a virtual package
diff --git a/tests/t-provides/pkg-depends-le/DEBIAN/control b/tests/t-provides/pkg-depends-le/DEBIAN/control
new file mode 100644
index 0000000..706c086
--- /dev/null
+++ b/tests/t-provides/pkg-depends-le/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-le
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-virtual (<= 10)
+Description: test package - package depending on a virtual package
diff --git a/tests/t-provides/pkg-depends/DEBIAN/control b/tests/t-provides/pkg-depends/DEBIAN/control
new file mode 100644
index 0000000..57572b8
--- /dev/null
+++ b/tests/t-provides/pkg-depends/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-virtual
+Description: test package - package depending on a virtual package
diff --git a/tests/t-provides/pkg-predepends-eq/DEBIAN/control b/tests/t-provides/pkg-predepends-eq/DEBIAN/control
new file mode 100644
index 0000000..25b1b46
--- /dev/null
+++ b/tests/t-provides/pkg-predepends-eq/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-predepends-eq
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Pre-Depends: pkg-virtual (= 20)
+Description: test package - package pre-depending on a virtual package
diff --git a/tests/t-provides/pkg-predepends-ge/DEBIAN/control b/tests/t-provides/pkg-predepends-ge/DEBIAN/control
new file mode 100644
index 0000000..65d155f
--- /dev/null
+++ b/tests/t-provides/pkg-predepends-ge/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-predepends-ge
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Pre-Depends: pkg-virtual (>= 20)
+Description: test package - package pre-depending on a virtual package
diff --git a/tests/t-provides/pkg-predepends-le/DEBIAN/control b/tests/t-provides/pkg-predepends-le/DEBIAN/control
new file mode 100644
index 0000000..d95d89b
--- /dev/null
+++ b/tests/t-provides/pkg-predepends-le/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-predepends-le
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Pre-Depends: pkg-virtual (<= 10)
+Description: test package - package pre-depending on a virtual package
diff --git a/tests/t-provides/pkg-predepends/DEBIAN/control b/tests/t-provides/pkg-predepends/DEBIAN/control
new file mode 100644
index 0000000..ca1df84
--- /dev/null
+++ b/tests/t-provides/pkg-predepends/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-predepends
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Pre-Depends: pkg-virtual
+Description: test package - package pre-depending on a virtual package
diff --git a/tests/t-provides/pkg-provides-10-20/DEBIAN/control b/tests/t-provides/pkg-provides-10-20/DEBIAN/control
new file mode 100644
index 0000000..ac83a68
--- /dev/null
+++ b/tests/t-provides/pkg-provides-10-20/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-provides
+Version: 3
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Provides: pkg-virtual (= 10), pkg-virtual (= 20)
+Description: test package - package providing a versioned virtual package
diff --git a/tests/t-provides/pkg-provides-10/DEBIAN/control b/tests/t-provides/pkg-provides-10/DEBIAN/control
new file mode 100644
index 0000000..d4014e3
--- /dev/null
+++ b/tests/t-provides/pkg-provides-10/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-provides
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Provides: pkg-virtual (= 10)
+Description: test package - package providing a versioned virtual package
diff --git a/tests/t-provides/pkg-provides-20/DEBIAN/control b/tests/t-provides/pkg-provides-20/DEBIAN/control
new file mode 100644
index 0000000..f923647
--- /dev/null
+++ b/tests/t-provides/pkg-provides-20/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-provides
+Version: 2
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Provides: pkg-virtual (= 20)
+Description: test package - package providing a versioned virtual package
diff --git a/tests/t-provides/pkg-provides/DEBIAN/control b/tests/t-provides/pkg-provides/DEBIAN/control
new file mode 100644
index 0000000..10f4932
--- /dev/null
+++ b/tests/t-provides/pkg-provides/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-provides
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Provides: pkg-virtual
+Description: test package - package providing a virtual package
diff --git a/tests/t-queue-process-deconf-dupe/Makefile b/tests/t-queue-process-deconf-dupe/Makefile
new file mode 100644
index 0000000..4524936
--- /dev/null
+++ b/tests/t-queue-process-deconf-dupe/Makefile
@@ -0,0 +1,12 @@
+TESTS_DEB := pkg-a-0 pkg-a-1 pkg-b
+
+include ../Test.mk
+
+DPKG_OPTIONS += --auto-deconfigure
+
+test-case:
+ $(DPKG_INSTALL) pkg-a-0.deb
+ $(DPKG_INSTALL) pkg-b.deb pkg-a-1.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-b pkg-a
diff --git a/tests/t-queue-process-deconf-dupe/pkg-a-0/DEBIAN/control b/tests/t-queue-process-deconf-dupe/pkg-a-0/DEBIAN/control
new file mode 100644
index 0000000..7559bbe
--- /dev/null
+++ b/tests/t-queue-process-deconf-dupe/pkg-a-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - broken package
diff --git a/tests/t-queue-process-deconf-dupe/pkg-a-0/test-a b/tests/t-queue-process-deconf-dupe/pkg-a-0/test-a
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-queue-process-deconf-dupe/pkg-a-0/test-a
diff --git a/tests/t-queue-process-deconf-dupe/pkg-a-0/test-move b/tests/t-queue-process-deconf-dupe/pkg-a-0/test-move
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-queue-process-deconf-dupe/pkg-a-0/test-move
diff --git a/tests/t-queue-process-deconf-dupe/pkg-a-1/DEBIAN/control b/tests/t-queue-process-deconf-dupe/pkg-a-1/DEBIAN/control
new file mode 100644
index 0000000..f14ed79
--- /dev/null
+++ b/tests/t-queue-process-deconf-dupe/pkg-a-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-a
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - broken package
diff --git a/tests/t-queue-process-deconf-dupe/pkg-a-1/test-a b/tests/t-queue-process-deconf-dupe/pkg-a-1/test-a
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-queue-process-deconf-dupe/pkg-a-1/test-a
diff --git a/tests/t-queue-process-deconf-dupe/pkg-b/DEBIAN/control b/tests/t-queue-process-deconf-dupe/pkg-b/DEBIAN/control
new file mode 100644
index 0000000..11fe204
--- /dev/null
+++ b/tests/t-queue-process-deconf-dupe/pkg-b/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Breaks: pkg-a (<< 1)
+Replaces: pkg-a (<< 1)
+Description: test package - breaking package
diff --git a/tests/t-queue-process-deconf-dupe/pkg-b/test-b b/tests/t-queue-process-deconf-dupe/pkg-b/test-b
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-queue-process-deconf-dupe/pkg-b/test-b
diff --git a/tests/t-queue-process-deconf-dupe/pkg-b/test-move b/tests/t-queue-process-deconf-dupe/pkg-b/test-move
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-queue-process-deconf-dupe/pkg-b/test-move
diff --git a/tests/t-switch-dir-to-symlink-abs/Makefile b/tests/t-switch-dir-to-symlink-abs/Makefile
new file mode 100644
index 0000000..e285cfd
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/Makefile
@@ -0,0 +1,146 @@
+TESTS_DEB := \
+ pkg-dir-conffile-0 pkg-dir-conffile-1 \
+ pkg-dir-file-other pkg-dir-symlink-int-0 pkg-dir-symlink-int-1 \
+ pkg-dir-file-moved pkg-dir-symlink-ext-0 pkg-dir-symlink-ext-1
+
+include ../Test.mk
+
+build-hook:
+ ln -sf test-dir pkg-dir-conffile-1/test-path
+ ln -sf test-dir pkg-dir-symlink-ext-1/test-path
+ ln -sf test-dir pkg-dir-symlink-int-1/test-path
+
+clean-hook:
+ $(RM) pkg-dir-conffile-1/test-path
+ $(RM) pkg-dir-symlink-ext-1/test-path
+ $(RM) pkg-dir-symlink-int-1/test-path
+
+test-case:
+ # Cannot switch a directory containing conffiles
+ $(DPKG_INSTALL) pkg-dir-conffile-0.deb
+ test -d '$(DPKG_INSTDIR)/test-path'
+ ! $(DPKG_INSTALL) pkg-dir-conffile-1.deb
+ 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 '$(DPKG_INSTDIR)/test-path'
+ ! test -h '$(DPKG_INSTDIR)/test-path'
+ ! $(DPKG_INSTALL) pkg-dir-symlink-int-1.deb
+ 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 '$(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 '$(DPKG_INSTDIR)/test-path'
+ ! test -h '$(DPKG_INSTDIR)/test-path'
+ rm '$(DPKG_INSTDIR)/test-path/local file'
+ $(DPKG_PURGE) pkg-dir-symlink-int
+
+ #
+ # Otherwise allow the switch
+ #
+
+ # 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 '$(DPKG_INSTDIR)/test-path'
+ ! test -h '$(DPKG_INSTDIR)/test-path'
+ $(DPKG_INSTALL) pkg-dir-symlink-int-1.deb
+ test -h '$(DPKG_INSTDIR)/test-path'
+ $(DPKG_PURGE) pkg-dir-symlink-int
+ ! 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 '$(DPKG_INSTDIR)/test-path'
+ test -d '$(DPKG_INSTDIR)/test-path'
+ $(DPKG_UNPACK) pkg-dir-symlink-int-1.deb
+ ! test -h '$(DPKG_INSTDIR)/test-path'
+ test -d '$(DPKG_INSTDIR)/test-path'
+ $(DPKG_CONFIGURE) pkg-dir-symlink-int
+ test -h '$(DPKG_INSTDIR)/test-path'
+ $(DPKG_PURGE) pkg-dir-symlink-int
+ ! 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 '$(DPKG_INSTDIR)/test-path'
+ $(DPKG_UNPACK) pkg-dir-symlink-int-1.deb
+ ! test -h '$(DPKG_INSTDIR)/test-path'
+ test -d '$(DPKG_INSTDIR)/test-path'
+ $(DPKG_CONFIGURE) pkg-dir-symlink-int
+ test -h '$(DPKG_INSTDIR)/test-path'
+ $(DPKG_PURGE) pkg-dir-symlink-int
+ ! 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 '$(DPKG_INSTDIR)/test-path'
+ $(DPKG_INSTALL) pkg-dir-file-moved.deb
+ test -d '$(DPKG_INSTDIR)/test-path'
+ test -d '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_INSTALL) pkg-dir-symlink-ext-1.deb
+ test -h '$(DPKG_INSTDIR)/test-path'
+ test "`readlink -f '$(DPKG_INSTDIR)/test-path'`" = "/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 '$(DPKG_INSTDIR)/test-path'
+ $(DPKG_INSTALL) pkg-dir-file-moved.deb
+ test -d '$(DPKG_INSTDIR)/test-path'
+ test -d '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_UNPACK) pkg-dir-symlink-ext-1.deb
+ test -d '$(DPKG_INSTDIR)/test-path'
+ test -d '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_CONFIGURE) -a
+ test -h '$(DPKG_INSTDIR)/test-path'
+ test "`readlink -f '$(DPKG_INSTDIR)/test-path'`" = "/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 '$(DPKG_INSTDIR)/test-path'
+ $(DPKG_UNPACK) pkg-dir-file-moved.deb
+ test -d '$(DPKG_INSTDIR)/test-path'
+ test -d '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_UNPACK) pkg-dir-symlink-ext-1.deb
+ test -d '$(DPKG_INSTDIR)/test-path'
+ test -d '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_CONFIGURE) -a
+ test -h '$(DPKG_INSTDIR)/test-path'
+ test "`readlink -f '$(DPKG_INSTDIR)/test-path'`" = "/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
+
+test-clean:
+ $(DPKG_PURGE) pkg-dir-conffile
+ $(DPKG_PURGE) pkg-dir-symlink-int
+ $(DPKG_PURGE) pkg-dir-symlink-ext
+ $(DPKG_PURGE) pkg-dir-file-other
+ $(DPKG_PURGE) pkg-dir-file-moved
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/DEBIAN/conffiles b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/DEBIAN/conffiles
new file mode 100644
index 0000000..296ef19
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-path/file-conf
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/DEBIAN/control b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/DEBIAN/control
new file mode 100644
index 0000000..57fdc53
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-conffile
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with dir to be switched to symlink
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/test-path/file-conf b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/test-path/file-conf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-0/test-path/file-conf
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/control b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/control
new file mode 100644
index 0000000..69f4d74
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-conffile
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package switching dir to symlink
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/postinst b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/postinst
new file mode 100755
index 0000000..1e539b9
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/postinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink /test-path /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/postrm b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/postrm
new file mode 100755
index 0000000..1e539b9
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/postrm
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink /test-path /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/preinst b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/preinst
new file mode 100755
index 0000000..1e539b9
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-conffile-1/DEBIAN/preinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink /test-path /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-moved/DEBIAN/control b/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-moved/DEBIAN/control
new file mode 100644
index 0000000..db492dd
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-moved/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-file-moved
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with file moved from dir-to-symlink switch
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-moved/test-dir/file-normal b/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-moved/test-dir/file-normal
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-moved/test-dir/file-normal
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-other/DEBIAN/control b/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-other/DEBIAN/control
new file mode 100644
index 0000000..985c6db
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-other/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-file-other
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with real dir and contents
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-other/test-path/file-other b/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-other/test-path/file-other
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-file-other/test-path/file-other
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-0/DEBIAN/control b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-0/DEBIAN/control
new file mode 100644
index 0000000..f9aca91
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-symlink-ext
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with dir to be switched to symlink
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-0/test-path/file-normal b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-0/test-path/file-normal
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-0/test-path/file-normal
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/control b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/control
new file mode 100644
index 0000000..255195b
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-dir-symlink-ext
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-dir-file-moved (>= 1)
+Description: test package - package switching dir to symlink
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/postinst b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/postinst
new file mode 100755
index 0000000..1e539b9
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/postinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink /test-path /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/postrm b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/postrm
new file mode 100755
index 0000000..1e539b9
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/postrm
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink /test-path /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/preinst b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/preinst
new file mode 100755
index 0000000..1e539b9
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-ext-1/DEBIAN/preinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink /test-path /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-0/DEBIAN/control b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-0/DEBIAN/control
new file mode 100644
index 0000000..3526664
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-symlink-int
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with dir to be switched to symlink
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-0/test-path/file-normal b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-0/test-path/file-normal
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-0/test-path/file-normal
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/control b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/control
new file mode 100644
index 0000000..6852587
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-symlink-int
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package switching dir to symlink
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/postinst b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/postinst
new file mode 100755
index 0000000..1e539b9
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/postinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink /test-path /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/postrm b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/postrm
new file mode 100755
index 0000000..1e539b9
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/postrm
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink /test-path /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/preinst b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/preinst
new file mode 100755
index 0000000..1e539b9
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/DEBIAN/preinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink /test-path /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/test-dir/file-other b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/test-dir/file-other
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-abs/pkg-dir-symlink-int-1/test-dir/file-other
diff --git a/tests/t-switch-dir-to-symlink-rel/Makefile b/tests/t-switch-dir-to-symlink-rel/Makefile
new file mode 100644
index 0000000..ae4056b
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/Makefile
@@ -0,0 +1,156 @@
+TESTS_DEB := \
+ pkg-dir-conffile-0 pkg-dir-conffile-1 \
+ pkg-dir-file-other pkg-dir-symlink-int-0 pkg-dir-symlink-int-1 \
+ pkg-dir-file-moved pkg-dir-symlink-ext-0 pkg-dir-symlink-ext-1
+
+include ../Test.mk
+
+build-hook:
+ mkdir -p pkg-dir-conffile-1/test-path
+ ln -sf ../test-dir pkg-dir-conffile-1/test-path/test-subpath
+ mkdir -p pkg-dir-symlink-ext-1/test-path
+ ln -sf ../test-dir pkg-dir-symlink-ext-1/test-path/test-subpath
+ mkdir -p pkg-dir-symlink-int-1/test-path
+ ln -sf ../test-dir pkg-dir-symlink-int-1/test-path/test-subpath
+
+clean-hook:
+ $(RM) pkg-dir-conffile-1/test-path/test-subpath
+ -rmdir pkg-dir-conffile-1/test-path
+ $(RM) pkg-dir-symlink-ext-1/test-path/test-subpath
+ -rmdir pkg-dir-symlink-ext-1/test-path
+ $(RM) pkg-dir-symlink-int-1/test-path/test-subpath
+ -rmdir pkg-dir-symlink-int-1/test-path
+
+test-case:
+ # Cannot switch a directory containing conffiles
+ $(DPKG_INSTALL) pkg-dir-conffile-0.deb
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ ! $(DPKG_INSTALL) pkg-dir-conffile-1.deb
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(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 '$(DPKG_INSTDIR)/test-path/test-subpath'
+ ! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ ! $(DPKG_INSTALL) pkg-dir-symlink-int-1.deb
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ ! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(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 '$(DPKG_INSTDIR)/test-path/test-subpath'
+ ! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ touch '$(DPKG_INSTDIR)/test-path/test-subpath/local file'
+ ! $(DPKG_INSTALL) pkg-dir-symlink-int-1.deb
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ ! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ rm '$(DPKG_INSTDIR)/test-path/test-subpath/local file'
+ $(DPKG_PURGE) pkg-dir-symlink-int
+
+ #
+ # Otherwise allow the switch
+ #
+
+ # 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 '$(DPKG_INSTDIR)/test-path/test-subpath'
+ ! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(DPKG_INSTALL) pkg-dir-symlink-int-1.deb
+ test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(DPKG_PURGE) pkg-dir-symlink-int
+ ! test -e '$(DPKG_INSTDIR)/test-path/test-subpath'
+
+ # 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 '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(DPKG_UNPACK) pkg-dir-symlink-int-1.deb
+ ! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(DPKG_CONFIGURE) pkg-dir-symlink-int
+ test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(DPKG_PURGE) pkg-dir-symlink-int
+ ! test -e '$(DPKG_INSTDIR)/test-path/test-subpath'
+
+ # 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 '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(DPKG_UNPACK) pkg-dir-symlink-int-1.deb
+ ! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(DPKG_CONFIGURE) pkg-dir-symlink-int
+ test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(DPKG_PURGE) pkg-dir-symlink-int
+ ! test -e '$(DPKG_INSTDIR)/test-path/test-subpath'
+
+ # 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 '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(DPKG_INSTALL) pkg-dir-file-moved.deb
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_INSTALL) pkg-dir-symlink-ext-1.deb
+ test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test "`readlink '$(DPKG_INSTDIR)/test-path/test-subpath'`" = "../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 '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(DPKG_INSTALL) pkg-dir-file-moved.deb
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_UNPACK) pkg-dir-symlink-ext-1.deb
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_CONFIGURE) -a
+ test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test "`readlink '$(DPKG_INSTDIR)/test-path/test-subpath'`" = "../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 '$(DPKG_INSTDIR)/test-path/test-subpath'
+ $(DPKG_UNPACK) pkg-dir-file-moved.deb
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_UNPACK) pkg-dir-symlink-ext-1.deb
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-dir'
+ $(DPKG_CONFIGURE) -a
+ test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
+ test "`readlink '$(DPKG_INSTDIR)/test-path/test-subpath'`" = "../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
+
+test-clean:
+ $(DPKG_PURGE) pkg-dir-conffile
+ $(DPKG_PURGE) pkg-dir-symlink-int
+ $(DPKG_PURGE) pkg-dir-symlink-ext
+ $(DPKG_PURGE) pkg-dir-file-other
+ $(DPKG_PURGE) pkg-dir-file-moved
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/DEBIAN/conffiles b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/DEBIAN/conffiles
new file mode 100644
index 0000000..77b39da
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-path/test-subpath/file-conf
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/DEBIAN/control b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/DEBIAN/control
new file mode 100644
index 0000000..57fdc53
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-conffile
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with dir to be switched to symlink
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/test-path/test-subpath/file-conf b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/test-path/test-subpath/file-conf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-0/test-path/test-subpath/file-conf
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/control b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/control
new file mode 100644
index 0000000..69f4d74
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-conffile
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package switching dir to symlink
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/postinst b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/postinst
new file mode 100755
index 0000000..572dfa2
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/postinst
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink \
+ /test-path/test-subpath ../test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/postrm b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/postrm
new file mode 100755
index 0000000..572dfa2
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/postrm
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink \
+ /test-path/test-subpath ../test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/preinst b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/preinst
new file mode 100755
index 0000000..572dfa2
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-conffile-1/DEBIAN/preinst
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink \
+ /test-path/test-subpath ../test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-moved/DEBIAN/control b/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-moved/DEBIAN/control
new file mode 100644
index 0000000..db492dd
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-moved/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-file-moved
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with file moved from dir-to-symlink switch
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-moved/test-dir/file-normal b/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-moved/test-dir/file-normal
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-moved/test-dir/file-normal
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-other/DEBIAN/control b/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-other/DEBIAN/control
new file mode 100644
index 0000000..985c6db
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-other/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-file-other
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with real dir and contents
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-other/test-path/test-subpath/file-other b/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-other/test-path/test-subpath/file-other
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-file-other/test-path/test-subpath/file-other
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-0/DEBIAN/control b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-0/DEBIAN/control
new file mode 100644
index 0000000..f9aca91
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-symlink-ext
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with dir to be switched to symlink
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-0/test-path/test-subpath/file-normal b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-0/test-path/test-subpath/file-normal
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-0/test-path/test-subpath/file-normal
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/control b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/control
new file mode 100644
index 0000000..255195b
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-dir-symlink-ext
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-dir-file-moved (>= 1)
+Description: test package - package switching dir to symlink
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/postinst b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/postinst
new file mode 100755
index 0000000..572dfa2
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/postinst
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink \
+ /test-path/test-subpath ../test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/postrm b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/postrm
new file mode 100755
index 0000000..572dfa2
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/postrm
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink \
+ /test-path/test-subpath ../test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/preinst b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/preinst
new file mode 100755
index 0000000..572dfa2
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-ext-1/DEBIAN/preinst
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink \
+ /test-path/test-subpath ../test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-0/DEBIAN/control b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-0/DEBIAN/control
new file mode 100644
index 0000000..3526664
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-symlink-int
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with dir to be switched to symlink
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-0/test-path/test-subpath/file-normal b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-0/test-path/test-subpath/file-normal
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-0/test-path/test-subpath/file-normal
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/control b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/control
new file mode 100644
index 0000000..6852587
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-symlink-int
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package switching dir to symlink
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/postinst b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/postinst
new file mode 100755
index 0000000..572dfa2
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/postinst
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink \
+ /test-path/test-subpath ../test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/postrm b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/postrm
new file mode 100755
index 0000000..572dfa2
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/postrm
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink \
+ /test-path/test-subpath ../test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/preinst b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/preinst
new file mode 100755
index 0000000..572dfa2
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/DEBIAN/preinst
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports dir_to_symlink; then
+ dpkg-maintscript-helper dir_to_symlink \
+ /test-path/test-subpath ../test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/test-dir/file-other b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/test-dir/file-other
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-dir-to-symlink-rel/pkg-dir-symlink-int-1/test-dir/file-other
diff --git a/tests/t-switch-symlink-abs-to-dir/Makefile b/tests/t-switch-symlink-abs-to-dir/Makefile
new file mode 100644
index 0000000..1d1b40d
--- /dev/null
+++ b/tests/t-switch-symlink-abs-to-dir/Makefile
@@ -0,0 +1,28 @@
+TESTS_DEB := pkg-dir-real pkg-dir-symlink-0 pkg-dir-symlink-1
+
+include ../Test.mk
+
+build-hook:
+ ln -sf test-dir pkg-dir-symlink-0/test-symlink
+
+clean-hook:
+ $(RM) pkg-dir-symlink-0/test-symlink
+
+test-case:
+ $(DPKG_INSTALL) pkg-dir-real.deb
+
+ $(DPKG_INSTALL) pkg-dir-symlink-0.deb
+ test -h "$(DPKG_INSTDIR)/test-symlink"
+
+ $(DPKG_INSTALL) pkg-dir-symlink-1.deb
+ ! test -h "$(DPKG_INSTDIR)/test-symlink"
+ test -d "$(DPKG_INSTDIR)/test-symlink"
+
+ $(DPKG_PURGE) pkg-dir-symlink
+ ! test -e "$(DPKG_INSTDIR)/test-symlink"
+
+ $(DPKG_PURGE) pkg-dir-real
+
+test-clean:
+ $(DPKG_PURGE) pkg-dir-symlink
+ $(DPKG_PURGE) pkg-dir-real
diff --git a/tests/t-switch-symlink-abs-to-dir/pkg-dir-real/DEBIAN/control b/tests/t-switch-symlink-abs-to-dir/pkg-dir-real/DEBIAN/control
new file mode 100644
index 0000000..1e94e7a
--- /dev/null
+++ b/tests/t-switch-symlink-abs-to-dir/pkg-dir-real/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-real
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with real dir
diff --git a/tests/t-switch-symlink-abs-to-dir/pkg-dir-real/test-dir/file-dir b/tests/t-switch-symlink-abs-to-dir/pkg-dir-real/test-dir/file-dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-symlink-abs-to-dir/pkg-dir-real/test-dir/file-dir
diff --git a/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-0/DEBIAN/control b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-0/DEBIAN/control
new file mode 100644
index 0000000..730258b
--- /dev/null
+++ b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-symlink
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with symlink to dir
diff --git a/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/control b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/control
new file mode 100644
index 0000000..f68d6dc
--- /dev/null
+++ b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-symlink
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package switching symlink to dir
diff --git a/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/postinst b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/postinst
new file mode 100755
index 0000000..e87967a
--- /dev/null
+++ b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/postinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports symlink_to_dir; then
+ dpkg-maintscript-helper symlink_to_dir /test-symlink /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/postrm b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/postrm
new file mode 100755
index 0000000..e87967a
--- /dev/null
+++ b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/postrm
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports symlink_to_dir; then
+ dpkg-maintscript-helper symlink_to_dir /test-symlink /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/preinst b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/preinst
new file mode 100755
index 0000000..e87967a
--- /dev/null
+++ b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/DEBIAN/preinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports symlink_to_dir; then
+ dpkg-maintscript-helper symlink_to_dir /test-symlink /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/test-symlink/file-owned b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/test-symlink/file-owned
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-symlink-abs-to-dir/pkg-dir-symlink-1/test-symlink/file-owned
diff --git a/tests/t-switch-symlink-rel-to-dir/Makefile b/tests/t-switch-symlink-rel-to-dir/Makefile
new file mode 100644
index 0000000..ee936a1
--- /dev/null
+++ b/tests/t-switch-symlink-rel-to-dir/Makefile
@@ -0,0 +1,30 @@
+TESTS_DEB := pkg-dir-real pkg-dir-symlink-0 pkg-dir-symlink-1
+
+include ../Test.mk
+
+build-hook:
+ mkdir -p pkg-dir-symlink-0/test-path
+ ln -sf ../test-dir pkg-dir-symlink-0/test-path/test-symlink
+
+clean-hook:
+ $(RM) pkg-dir-symlink-0/test-path/test-symlink
+ -rmdir pkg-dir-symlink-0/test-path
+
+test-case:
+ $(DPKG_INSTALL) pkg-dir-real.deb
+
+ $(DPKG_INSTALL) pkg-dir-symlink-0.deb
+ test -h '$(DPKG_INSTDIR)/test-path/test-symlink'
+
+ $(DPKG_INSTALL) pkg-dir-symlink-1.deb
+ ! test -h '$(DPKG_INSTDIR)/test-path/test-symlink'
+ test -d '$(DPKG_INSTDIR)/test-path/test-symlink'
+
+ $(DPKG_PURGE) pkg-dir-symlink
+ ! test -e '$(DPKG_INSTDIR)/test-path/test-symlink'
+
+ $(DPKG_PURGE) pkg-dir-real
+
+test-clean:
+ $(DPKG_PURGE) pkg-dir-symlink
+ $(DPKG_PURGE) pkg-dir-real
diff --git a/tests/t-switch-symlink-rel-to-dir/pkg-dir-real/DEBIAN/control b/tests/t-switch-symlink-rel-to-dir/pkg-dir-real/DEBIAN/control
new file mode 100644
index 0000000..1e94e7a
--- /dev/null
+++ b/tests/t-switch-symlink-rel-to-dir/pkg-dir-real/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-real
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with real dir
diff --git a/tests/t-switch-symlink-rel-to-dir/pkg-dir-real/test-dir/file-dir b/tests/t-switch-symlink-rel-to-dir/pkg-dir-real/test-dir/file-dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-symlink-rel-to-dir/pkg-dir-real/test-dir/file-dir
diff --git a/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-0/DEBIAN/control b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-0/DEBIAN/control
new file mode 100644
index 0000000..730258b
--- /dev/null
+++ b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-symlink
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with symlink to dir
diff --git a/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/control b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/control
new file mode 100644
index 0000000..f68d6dc
--- /dev/null
+++ b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-dir-symlink
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package switching symlink to dir
diff --git a/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/postinst b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/postinst
new file mode 100755
index 0000000..89e4fcd
--- /dev/null
+++ b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/postinst
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports symlink_to_dir; then
+ dpkg-maintscript-helper symlink_to_dir \
+ /test-path/test-symlink /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/postrm b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/postrm
new file mode 100755
index 0000000..89e4fcd
--- /dev/null
+++ b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/postrm
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports symlink_to_dir; then
+ dpkg-maintscript-helper symlink_to_dir \
+ /test-path/test-symlink /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/preinst b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/preinst
new file mode 100755
index 0000000..89e4fcd
--- /dev/null
+++ b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/DEBIAN/preinst
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+if dpkg-maintscript-helper supports symlink_to_dir; then
+ dpkg-maintscript-helper symlink_to_dir \
+ /test-path/test-symlink /test-dir 0 -- "$@"
+fi
diff --git a/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/test-path/test-symlink/file-owned b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/test-path/test-symlink/file-owned
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-switch-symlink-rel-to-dir/pkg-dir-symlink-1/test-path/test-symlink/file-owned
diff --git a/tests/t-symlink-dir/Makefile b/tests/t-symlink-dir/Makefile
new file mode 100644
index 0000000..6fa0a0b
--- /dev/null
+++ b/tests/t-symlink-dir/Makefile
@@ -0,0 +1,29 @@
+TESTS_DEB := pkg-dir-real pkg-dir-symlink-0 pkg-dir-symlink-1 pkg-file
+
+include ../Test.mk
+
+build-hook:
+ ln -fs test-dir pkg-dir-symlink-0/test-symlink
+ ln -fs test-dir pkg-dir-symlink-1/test-symlink
+
+clean-hook:
+ $(RM) pkg-dir-symlink-0/test-symlink
+ $(RM) pkg-dir-symlink-1/test-symlink
+
+test-case:
+ $(DPKG_INSTALL) pkg-dir-real.deb
+ $(DPKG_INSTALL) pkg-dir-symlink-0.deb
+ $(DPKG_INSTALL) pkg-file.deb
+ $(DPKG_INSTALL) pkg-dir-symlink-1.deb
+
+ $(DPKG_PURGE) pkg-dir-symlink
+ $(DPKG_PURGE) pkg-file
+ $(DPKG_PURGE) pkg-dir-real
+
+ test ! -L '$(DPKG_INSTDIR)/test-symlink'
+
+test-clean:
+ $(DPKG_PURGE) pkg-dir-symlink
+ $(DPKG_PURGE) pkg-file
+ $(DPKG_PURGE) pkg-dir-real
+ $(BEROOT) $(RM) '$(DPKG_INSTDIR)/test-symlink'
diff --git a/tests/t-symlink-dir/pkg-dir-real/DEBIAN/control b/tests/t-symlink-dir/pkg-dir-real/DEBIAN/control
new file mode 100644
index 0000000..8d73fa6
--- /dev/null
+++ b/tests/t-symlink-dir/pkg-dir-real/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-dir-real
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with real dir
+
diff --git a/tests/t-symlink-dir/pkg-dir-real/test-dir/file-dir b/tests/t-symlink-dir/pkg-dir-real/test-dir/file-dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-symlink-dir/pkg-dir-real/test-dir/file-dir
diff --git a/tests/t-symlink-dir/pkg-dir-symlink-0/DEBIAN/control b/tests/t-symlink-dir/pkg-dir-symlink-0/DEBIAN/control
new file mode 100644
index 0000000..a19a7e1
--- /dev/null
+++ b/tests/t-symlink-dir/pkg-dir-symlink-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-dir-symlink
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with symlink to dir
+
diff --git a/tests/t-symlink-dir/pkg-dir-symlink-0/file-symlink b/tests/t-symlink-dir/pkg-dir-symlink-0/file-symlink
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-symlink-dir/pkg-dir-symlink-0/file-symlink
diff --git a/tests/t-symlink-dir/pkg-dir-symlink-1/DEBIAN/control b/tests/t-symlink-dir/pkg-dir-symlink-1/DEBIAN/control
new file mode 100644
index 0000000..becfc01
--- /dev/null
+++ b/tests/t-symlink-dir/pkg-dir-symlink-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-dir-symlink
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with symlink to dir
+
diff --git a/tests/t-symlink-dir/pkg-dir-symlink-1/file-symlink b/tests/t-symlink-dir/pkg-dir-symlink-1/file-symlink
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-symlink-dir/pkg-dir-symlink-1/file-symlink
diff --git a/tests/t-symlink-dir/pkg-file/DEBIAN/conffiles b/tests/t-symlink-dir/pkg-file/DEBIAN/conffiles
new file mode 100644
index 0000000..551fc78
--- /dev/null
+++ b/tests/t-symlink-dir/pkg-file/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test-symlink/file-file
diff --git a/tests/t-symlink-dir/pkg-file/DEBIAN/control b/tests/t-symlink-dir/pkg-file/DEBIAN/control
new file mode 100644
index 0000000..b9a481c
--- /dev/null
+++ b/tests/t-symlink-dir/pkg-file/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-file
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package with file inside dir
+
diff --git a/tests/t-symlink-dir/pkg-file/test-symlink/file-file b/tests/t-symlink-dir/pkg-file/test-symlink/file-file
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-symlink-dir/pkg-file/test-symlink/file-file
diff --git a/tests/t-triggers-configure/Makefile b/tests/t-triggers-configure/Makefile
new file mode 100644
index 0000000..96996b2
--- /dev/null
+++ b/tests/t-triggers-configure/Makefile
@@ -0,0 +1,22 @@
+TESTS_DEB := pkg-activate pkg-interest-0 pkg-interest-1
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-interest-0.deb
+
+ # Activate the trigger, and leave pkg-interest in triggers-pending.
+ $(DPKG_INSTALL) --no-triggers pkg-activate.deb
+ $(call pkg_status_is,pkg-interest,install ok triggers-pending)
+
+ # Test that an upgrade from triggers-pending passes the previous
+ # configured version to "postinst configure".
+ $(DPKG_INSTALL) pkg-interest-1.deb
+
+ # Cleanup.
+ $(DPKG_PURGE) pkg-interest
+ $(DPKG_PURGE) pkg-activate
+
+test-clean:
+ -$(DPKG_PURGE) pkg-interest
+ -$(DPKG_PURGE) pkg-activate
diff --git a/tests/t-triggers-configure/pkg-activate/DEBIAN/control b/tests/t-triggers-configure/pkg-activate/DEBIAN/control
new file mode 100644
index 0000000..b8a6cc9
--- /dev/null
+++ b/tests/t-triggers-configure/pkg-activate/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-activate
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - activates triggers interested in /test/
diff --git a/tests/t-triggers-configure/pkg-activate/test/trigger/test-file b/tests/t-triggers-configure/pkg-activate/test/trigger/test-file
new file mode 100644
index 0000000..fb67027
--- /dev/null
+++ b/tests/t-triggers-configure/pkg-activate/test/trigger/test-file
@@ -0,0 +1 @@
+sample file
diff --git a/tests/t-triggers-configure/pkg-interest-0/DEBIAN/control b/tests/t-triggers-configure/pkg-interest-0/DEBIAN/control
new file mode 100644
index 0000000..e5a1833
--- /dev/null
+++ b/tests/t-triggers-configure/pkg-interest-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-interest
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - interested in files under /test/
diff --git a/tests/t-triggers-configure/pkg-interest-0/DEBIAN/triggers b/tests/t-triggers-configure/pkg-interest-0/DEBIAN/triggers
new file mode 100644
index 0000000..97d27a2
--- /dev/null
+++ b/tests/t-triggers-configure/pkg-interest-0/DEBIAN/triggers
@@ -0,0 +1 @@
+interest-noawait /test
diff --git a/tests/t-triggers-configure/pkg-interest-1/DEBIAN/control b/tests/t-triggers-configure/pkg-interest-1/DEBIAN/control
new file mode 100644
index 0000000..59c323b
--- /dev/null
+++ b/tests/t-triggers-configure/pkg-interest-1/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-interest
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - interested in files under /test/
diff --git a/tests/t-triggers-configure/pkg-interest-1/DEBIAN/postinst b/tests/t-triggers-configure/pkg-interest-1/DEBIAN/postinst
new file mode 100755
index 0000000..69ad9b5
--- /dev/null
+++ b/tests/t-triggers-configure/pkg-interest-1/DEBIAN/postinst
@@ -0,0 +1,15 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ configure)
+ if [ -z "$2" ]; then
+ echo "FAIL: upgrading and no previous version passed to configure" 2>&1
+ exit 1
+ else
+ echo "PASS: upgrading from version '$2'"
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-triggers-configure/pkg-interest-1/DEBIAN/triggers b/tests/t-triggers-configure/pkg-interest-1/DEBIAN/triggers
new file mode 100644
index 0000000..97d27a2
--- /dev/null
+++ b/tests/t-triggers-configure/pkg-interest-1/DEBIAN/triggers
@@ -0,0 +1 @@
+interest-noawait /test
diff --git a/tests/t-triggers-cycle/Makefile b/tests/t-triggers-cycle/Makefile
new file mode 100644
index 0000000..b17f877
--- /dev/null
+++ b/tests/t-triggers-cycle/Makefile
@@ -0,0 +1,21 @@
+TESTS_DEB := pkg-depends pkg-trigger-a pkg-trigger-b
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-depends.deb
+ # Should fail due to a trigger cycle.
+ ! $(DPKG_INSTALL) pkg-trigger-a.deb pkg-trigger-b.deb
+ ! $(DPKG_CONFIGURE) --pending
+
+ # Make sure everything is left in a correct state.
+ $(call pkg_is_installed,pkg-depends)
+ $(call pkg_is_installed,pkg-trigger-a)
+ $(call pkg_status_is,pkg-trigger-b,install ok half-configured)
+
+ # Cleanup.
+ $(DPKG_PURGE) pkg-trigger-a pkg-trigger-b
+ $(DPKG_PURGE) pkg-depends
+
+test-clean:
+ -$(DPKG_PURGE) pkg-trigger-a pkg-trigger-b pkg-depends
diff --git a/tests/t-triggers-cycle/pkg-depends/DEBIAN/control b/tests/t-triggers-cycle/pkg-depends/DEBIAN/control
new file mode 100644
index 0000000..27c429f
--- /dev/null
+++ b/tests/t-triggers-cycle/pkg-depends/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-depends
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package to be configured
diff --git a/tests/t-triggers-cycle/pkg-trigger-a/DEBIAN/control b/tests/t-triggers-cycle/pkg-trigger-a/DEBIAN/control
new file mode 100644
index 0000000..093d8a6
--- /dev/null
+++ b/tests/t-triggers-cycle/pkg-trigger-a/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-trigger-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-depends
+Description: test package - interested in files on /test/trigger-b/
diff --git a/tests/t-triggers-cycle/pkg-trigger-a/DEBIAN/postinst b/tests/t-triggers-cycle/pkg-trigger-a/DEBIAN/postinst
new file mode 100755
index 0000000..a874abf
--- /dev/null
+++ b/tests/t-triggers-cycle/pkg-trigger-a/DEBIAN/postinst
@@ -0,0 +1,20 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ configure)
+ dpkg-trigger /test/trigger-b/test-file
+ ;;
+ triggered)
+ pkg_status=`dpkg-query -f '${Status}' -W pkg-depends`
+ if [ "$pkg_status" = "install ok installed" ]; then
+ echo "Pass: pkg-depends is installed"
+ else
+ echo "Fail: pkg-depends is not installed ($pkg_status)"
+ exit 1
+ fi
+ dpkg-trigger /test/trigger-b/test-file
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-triggers-cycle/pkg-trigger-a/DEBIAN/triggers b/tests/t-triggers-cycle/pkg-trigger-a/DEBIAN/triggers
new file mode 100644
index 0000000..0f10564
--- /dev/null
+++ b/tests/t-triggers-cycle/pkg-trigger-a/DEBIAN/triggers
@@ -0,0 +1 @@
+interest /test/trigger-a
diff --git a/tests/t-triggers-cycle/pkg-trigger-b/DEBIAN/control b/tests/t-triggers-cycle/pkg-trigger-b/DEBIAN/control
new file mode 100644
index 0000000..9cc2094
--- /dev/null
+++ b/tests/t-triggers-cycle/pkg-trigger-b/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-trigger-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-depends
+Description: test package - interested in files on /test/trigger-a/
diff --git a/tests/t-triggers-cycle/pkg-trigger-b/DEBIAN/postinst b/tests/t-triggers-cycle/pkg-trigger-b/DEBIAN/postinst
new file mode 100755
index 0000000..8f1c02f
--- /dev/null
+++ b/tests/t-triggers-cycle/pkg-trigger-b/DEBIAN/postinst
@@ -0,0 +1,20 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ configure)
+ dpkg-trigger /test/trigger-a/test-file
+ ;;
+ triggered)
+ pkg_status=`dpkg-query -f '${Status}' -W pkg-depends`
+ if [ "$pkg_status" = "install ok installed" ]; then
+ echo "Pass: pkg-depends is installed"
+ else
+ echo "Fail: pkg-depends is not installed ($pkg_status)"
+ exit 1
+ fi
+ dpkg-trigger /test/trigger-a/test-file
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-triggers-cycle/pkg-trigger-b/DEBIAN/triggers b/tests/t-triggers-cycle/pkg-trigger-b/DEBIAN/triggers
new file mode 100644
index 0000000..86b4728
--- /dev/null
+++ b/tests/t-triggers-cycle/pkg-trigger-b/DEBIAN/triggers
@@ -0,0 +1 @@
+interest /test/trigger-b
diff --git a/tests/t-triggers-depcycle/Makefile b/tests/t-triggers-depcycle/Makefile
new file mode 100644
index 0000000..5b1f0fb
--- /dev/null
+++ b/tests/t-triggers-depcycle/Makefile
@@ -0,0 +1,25 @@
+TESTS_DEB := \
+ pkg-depends-0 pkg-depends-1 \
+ pkg-files-0 pkg-files-1 \
+ pkg-trigger
+
+include ../Test.mk
+
+test-case:
+ # Now provoke the trigger cycle
+ $(DPKG_INSTALL) pkg-depends-0.deb
+ $(DPKG_INSTALL) pkg-trigger.deb pkg-files-0.deb
+ $(DPKG_UNPACK) pkg-files-1.deb
+ ! $(DPKG_CONFIGURE) --pending
+
+ # Make sure everything is left in the expected state.
+ $(call pkg_is_installed,pkg-files)
+ $(call pkg_is_installed,pkg-depends)
+ $(call pkg_status_is,pkg-trigger,install ok half-configured)
+
+ # Cleanup.
+ $(DPKG_PURGE) pkg-trigger pkg-files
+ $(DPKG_PURGE) pkg-depends
+
+test-clean:
+ -$(DPKG_PURGE) --force-all pkg-trigger pkg-files pkg-depends
diff --git a/tests/t-triggers-depcycle/pkg-depends-0/DEBIAN/control b/tests/t-triggers-depcycle/pkg-depends-0/DEBIAN/control
new file mode 100644
index 0000000..27c429f
--- /dev/null
+++ b/tests/t-triggers-depcycle/pkg-depends-0/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-depends
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package to be configured
diff --git a/tests/t-triggers-depcycle/pkg-depends-1/DEBIAN/control b/tests/t-triggers-depcycle/pkg-depends-1/DEBIAN/control
new file mode 100644
index 0000000..2b3a8f3
--- /dev/null
+++ b/tests/t-triggers-depcycle/pkg-depends-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-files
+Description: test package - package to be configured
diff --git a/tests/t-triggers-depcycle/pkg-files-0/DEBIAN/control b/tests/t-triggers-depcycle/pkg-files-0/DEBIAN/control
new file mode 100644
index 0000000..9668941
--- /dev/null
+++ b/tests/t-triggers-depcycle/pkg-files-0/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-files
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-trigger
+Description: test package - provides a file under /test/trigger/
diff --git a/tests/t-triggers-depcycle/pkg-files-0/test/trigger/test-file b/tests/t-triggers-depcycle/pkg-files-0/test/trigger/test-file
new file mode 100644
index 0000000..fb67027
--- /dev/null
+++ b/tests/t-triggers-depcycle/pkg-files-0/test/trigger/test-file
@@ -0,0 +1 @@
+sample file
diff --git a/tests/t-triggers-depcycle/pkg-files-1/DEBIAN/control b/tests/t-triggers-depcycle/pkg-files-1/DEBIAN/control
new file mode 100644
index 0000000..f4312fa
--- /dev/null
+++ b/tests/t-triggers-depcycle/pkg-files-1/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-files
+Version: 1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-trigger
+Description: test package - provides a file under /test/trigger/
diff --git a/tests/t-triggers-depcycle/pkg-files-1/test/trigger/test-file b/tests/t-triggers-depcycle/pkg-files-1/test/trigger/test-file
new file mode 100644
index 0000000..fb67027
--- /dev/null
+++ b/tests/t-triggers-depcycle/pkg-files-1/test/trigger/test-file
@@ -0,0 +1 @@
+sample file
diff --git a/tests/t-triggers-depcycle/pkg-trigger/DEBIAN/control b/tests/t-triggers-depcycle/pkg-trigger/DEBIAN/control
new file mode 100644
index 0000000..72221a7
--- /dev/null
+++ b/tests/t-triggers-depcycle/pkg-trigger/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-trigger
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-depends, pkg-files
+Description: test package - interested in files on /test/trigger/
diff --git a/tests/t-triggers-depcycle/pkg-trigger/DEBIAN/postinst b/tests/t-triggers-depcycle/pkg-trigger/DEBIAN/postinst
new file mode 100755
index 0000000..716cdd5
--- /dev/null
+++ b/tests/t-triggers-depcycle/pkg-trigger/DEBIAN/postinst
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ triggered)
+ pkg_status=`dpkg-query -f '${Status}' -W pkg-depends`
+ if [ "$pkg_status" = "install ok installed" ]; then
+ echo "Pass: pkg-depends is installed"
+ else
+ echo "Fail: pkg-depends is not installed ($pkg_status)"
+ exit 1
+ fi
+ pkg_status=`dpkg-query -f '${Status}' -W pkg-files`
+ if [ "$pkg_status" = "install ok installed" ]; then
+ echo "Pass: pkg-files is installed"
+ else
+ echo "Fail: pkg-files is not installed ($pkg_status)"
+ exit 1
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-triggers-depcycle/pkg-trigger/DEBIAN/triggers b/tests/t-triggers-depcycle/pkg-trigger/DEBIAN/triggers
new file mode 100644
index 0000000..3b047af
--- /dev/null
+++ b/tests/t-triggers-depcycle/pkg-trigger/DEBIAN/triggers
@@ -0,0 +1 @@
+interest /test/trigger
diff --git a/tests/t-triggers-depends/Makefile b/tests/t-triggers-depends/Makefile
new file mode 100644
index 0000000..cdce58d
--- /dev/null
+++ b/tests/t-triggers-depends/Makefile
@@ -0,0 +1,25 @@
+TESTS_DEB := pkg-depended pkg-interest pkg-activate
+
+include ../Test.mk
+
+test-case:
+ # Should pass due to satisfied dependencies.
+ $(DPKG_INSTALL) pkg-depended.deb pkg-interest.deb
+ $(DPKG_INSTALL) pkg-activate.deb
+ $(DPKG_CONFIGURE) --pending
+
+ # Should fail due to unsatisfied dependencies.
+ $(DPKG_UNPACK) --no-triggers pkg-depended.deb
+ $(DPKG_INSTALL) --no-triggers pkg-activate.deb
+ ! $(DPKG_CONFIGURE) pkg-interest
+
+ # Should pass now due to satisfied dependencies.
+ $(DPKG_CONFIGURE) --no-triggers pkg-depended
+ $(DPKG_CONFIGURE) pkg-interest
+
+ # Cleanup.
+ $(DPKG_PURGE) pkg-trigger-a pkg-trigger-b
+ $(DPKG_PURGE) pkg-depends
+
+test-clean:
+ -$(DPKG_PURGE) pkg-activate pkg-interest pkg-depended
diff --git a/tests/t-triggers-depends/pkg-activate/DEBIAN/control b/tests/t-triggers-depends/pkg-activate/DEBIAN/control
new file mode 100644
index 0000000..e6c4ab5
--- /dev/null
+++ b/tests/t-triggers-depends/pkg-activate/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-activate
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - activate a trigger on /test/trigger/
diff --git a/tests/t-triggers-depends/pkg-activate/test/trigger/trigger-file b/tests/t-triggers-depends/pkg-activate/test/trigger/trigger-file
new file mode 100644
index 0000000..647063d
--- /dev/null
+++ b/tests/t-triggers-depends/pkg-activate/test/trigger/trigger-file
@@ -0,0 +1 @@
+activating file
diff --git a/tests/t-triggers-depends/pkg-depended/DEBIAN/control b/tests/t-triggers-depends/pkg-depended/DEBIAN/control
new file mode 100644
index 0000000..2b0e100
--- /dev/null
+++ b/tests/t-triggers-depends/pkg-depended/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-depended
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package to be depended on
diff --git a/tests/t-triggers-depends/pkg-interest/DEBIAN/control b/tests/t-triggers-depends/pkg-interest/DEBIAN/control
new file mode 100644
index 0000000..dc4d98a
--- /dev/null
+++ b/tests/t-triggers-depends/pkg-interest/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-interest
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-depended
+Description: test package - interested in files on /test/trigger/
diff --git a/tests/t-triggers-depends/pkg-interest/DEBIAN/postinst b/tests/t-triggers-depends/pkg-interest/DEBIAN/postinst
new file mode 100755
index 0000000..9f76726
--- /dev/null
+++ b/tests/t-triggers-depends/pkg-interest/DEBIAN/postinst
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ triggered)
+ pkg_status=`dpkg-query -f '${Status}' -W pkg-depended`
+ if [ "$pkg_status" = "install ok installed" ]; then
+ echo "Pass: pkg-depended is installed"
+ else
+ echo "Fail: pkg-depended is not installed ($pkg_status)"
+ exit 1
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-triggers-depends/pkg-interest/DEBIAN/triggers b/tests/t-triggers-depends/pkg-interest/DEBIAN/triggers
new file mode 100644
index 0000000..3b047af
--- /dev/null
+++ b/tests/t-triggers-depends/pkg-interest/DEBIAN/triggers
@@ -0,0 +1 @@
+interest /test/trigger
diff --git a/tests/t-triggers-depfarcycle/Makefile b/tests/t-triggers-depfarcycle/Makefile
new file mode 100644
index 0000000..65a490c
--- /dev/null
+++ b/tests/t-triggers-depfarcycle/Makefile
@@ -0,0 +1,36 @@
+TESTS_DEB := pkg-depends-a pkg-depends-b pkg-files pkg-trigger
+
+include ../Test.mk
+
+test-case:
+ # The trigger cycle does not affect us here.
+ $(DPKG_INSTALL) pkg-depends-a.deb pkg-files.deb \
+ pkg-depends-b.deb pkg-trigger.deb
+ $(DPKG_UNPACK) pkg-files.deb
+ $(DPKG_CONFIGURE) --pending
+
+ # Make sure everything is left in a correct state.
+ $(call pkg_is_installed,pkg-files)
+ $(call pkg_is_installed,pkg-depends-a)
+ $(call pkg_is_installed,pkg-depends-b)
+ $(call pkg_is_installed,pkg-trigger)
+
+ # Provoke the trigger cycle.
+ $(DPKG_UNPACK) pkg-depends-a.deb
+ $(DPKG_UNPACK) pkg-depends-b.deb
+ $(DPKG_UNPACK) pkg-files.deb
+ ! $(DPKG_CONFIGURE) pkg-trigger
+ $(DPKG) -s pkg-depends-a pkg-depends-b pkg-files pkg-trigger
+ ! $(DPKG_CONFIGURE) --pending
+
+ # Make sure everything is left in a correct state.
+ $(call pkg_is_installed,pkg-files)
+ $(call pkg_is_installed,pkg-depends-a)
+ $(call pkg_is_installed,pkg-depends-b)
+ $(call pkg_status_is,pkg-trigger,install ok half-configured)
+
+ # Cleanup.
+ $(DPKG_PURGE) pkg-trigger pkg-files pkg-depends-a pkg-depends-b
+
+test-clean:
+ -$(DPKG_PURGE) pkg-trigger pkg-files pkg-depends-a pkg-depends-b
diff --git a/tests/t-triggers-depfarcycle/pkg-depends-a/DEBIAN/control b/tests/t-triggers-depfarcycle/pkg-depends-a/DEBIAN/control
new file mode 100644
index 0000000..e8a34db
--- /dev/null
+++ b/tests/t-triggers-depfarcycle/pkg-depends-a/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-a
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-files
+Description: test package - package to be configured
diff --git a/tests/t-triggers-depfarcycle/pkg-depends-b/DEBIAN/control b/tests/t-triggers-depfarcycle/pkg-depends-b/DEBIAN/control
new file mode 100644
index 0000000..5498857
--- /dev/null
+++ b/tests/t-triggers-depfarcycle/pkg-depends-b/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends-b
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-trigger
+Description: test package - package to be configured
diff --git a/tests/t-triggers-depfarcycle/pkg-files/DEBIAN/control b/tests/t-triggers-depfarcycle/pkg-files/DEBIAN/control
new file mode 100644
index 0000000..7ce4ebc
--- /dev/null
+++ b/tests/t-triggers-depfarcycle/pkg-files/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-files
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-depends-b
+Description: test package - provides a file under /test/trigger/
diff --git a/tests/t-triggers-depfarcycle/pkg-files/test/trigger/test-file b/tests/t-triggers-depfarcycle/pkg-files/test/trigger/test-file
new file mode 100644
index 0000000..fb67027
--- /dev/null
+++ b/tests/t-triggers-depfarcycle/pkg-files/test/trigger/test-file
@@ -0,0 +1 @@
+sample file
diff --git a/tests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/control b/tests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/control
new file mode 100644
index 0000000..8ed63e6
--- /dev/null
+++ b/tests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-trigger
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-depends-a
+Description: test package - interested in files on /test/trigger/
diff --git a/tests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/postinst b/tests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/postinst
new file mode 100755
index 0000000..ffbad78
--- /dev/null
+++ b/tests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/postinst
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ triggered)
+ pkg_status=`dpkg-query -f '${Status}' -W pkg-depends-a`
+ if [ "$pkg_status" = "install ok installed" ]; then
+ echo "Pass: pkg-depends is installed"
+ else
+ echo "Fail: pkg-depends is not installed ($pkg_status)"
+ exit 1
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/triggers b/tests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/triggers
new file mode 100644
index 0000000..3b047af
--- /dev/null
+++ b/tests/t-triggers-depfarcycle/pkg-trigger/DEBIAN/triggers
@@ -0,0 +1 @@
+interest /test/trigger
diff --git a/tests/t-triggers-halt/Makefile b/tests/t-triggers-halt/Makefile
new file mode 100644
index 0000000..0ce5c0f
--- /dev/null
+++ b/tests/t-triggers-halt/Makefile
@@ -0,0 +1,26 @@
+TESTS_DEB := pkg-files pkg-depends pkg-remove pkg-trigger
+
+include ../Test.mk
+
+test-case:
+ # This is what apt is doing currently. :(
+ $(DPKG_INSTALL) pkg-files.deb
+ $(DPKG_INSTALL) pkg-depends.deb
+ $(DPKG_INSTALL) pkg-remove.deb
+ $(DPKG_INSTALL) pkg-trigger.deb
+ $(DPKG_REMOVE) --force-depends pkg-remove
+ $(DPKG_INSTALL) pkg-files.deb
+ $(DPKG_UNPACK) pkg-depends.deb
+
+ $(DPKG) -s pkg-trigger pkg-files pkg-depends
+
+ # Make sure everything is left in the expected state.
+ $(call pkg_status_is,pkg-depends,install ok unpacked)
+ $(call pkg_status_is,pkg-files,install ok triggers-awaited)
+ $(call pkg_status_is,pkg-trigger,install ok triggers-pending)
+
+ # Should fail due to unsatisfied dependencies.
+ ! $(DPKG_CONFIGURE) pkg-trigger pkg-depends
+
+test-clean:
+ -$(DPKG_PURGE) pkg-trigger pkg-depends pkg-files
diff --git a/tests/t-triggers-halt/pkg-depends/DEBIAN/control b/tests/t-triggers-halt/pkg-depends/DEBIAN/control
new file mode 100644
index 0000000..aadf8be
--- /dev/null
+++ b/tests/t-triggers-halt/pkg-depends/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-depends
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-files
+Description: test package - package to be configured
diff --git a/tests/t-triggers-halt/pkg-files/DEBIAN/control b/tests/t-triggers-halt/pkg-files/DEBIAN/control
new file mode 100644
index 0000000..92fa468
--- /dev/null
+++ b/tests/t-triggers-halt/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 - provides a file under /test/trigger/
diff --git a/tests/t-triggers-halt/pkg-files/test/trigger/test-file b/tests/t-triggers-halt/pkg-files/test/trigger/test-file
new file mode 100644
index 0000000..fb67027
--- /dev/null
+++ b/tests/t-triggers-halt/pkg-files/test/trigger/test-file
@@ -0,0 +1 @@
+sample file
diff --git a/tests/t-triggers-halt/pkg-remove/DEBIAN/control b/tests/t-triggers-halt/pkg-remove/DEBIAN/control
new file mode 100644
index 0000000..59c8876
--- /dev/null
+++ b/tests/t-triggers-halt/pkg-remove/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-remove
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package to be removed
diff --git a/tests/t-triggers-halt/pkg-trigger/DEBIAN/control b/tests/t-triggers-halt/pkg-trigger/DEBIAN/control
new file mode 100644
index 0000000..05a4d31
--- /dev/null
+++ b/tests/t-triggers-halt/pkg-trigger/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-trigger
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Depends: pkg-remove, pkg-depends
+Description: test package - interested in files on /test/trigger/
diff --git a/tests/t-triggers-halt/pkg-trigger/DEBIAN/postinst b/tests/t-triggers-halt/pkg-trigger/DEBIAN/postinst
new file mode 100755
index 0000000..72b74a1
--- /dev/null
+++ b/tests/t-triggers-halt/pkg-trigger/DEBIAN/postinst
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ triggered)
+ pkg_status=`dpkg-query -f '${Status}' -W pkg-depends`
+ if [ "$pkg_status" = "install ok installed" ]; then
+ echo "Pass: pkg-depends is installed"
+ else
+ echo "Fail: pkg-depends is not installed ($pkg_status)"
+ exit 1
+ fi
+ pkg_status=`dpkg-query -f '${Status}' -W pkg-nonexistent`
+ if [ "$pkg_status" = "install ok installed" ]; then
+ echo "Pass: pkg-nonexistent is installed"
+ else
+ echo "Fail: pkg-nonexistent is not installed ($pkg_status)"
+ exit 1
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-triggers-halt/pkg-trigger/DEBIAN/triggers b/tests/t-triggers-halt/pkg-trigger/DEBIAN/triggers
new file mode 100644
index 0000000..3b047af
--- /dev/null
+++ b/tests/t-triggers-halt/pkg-trigger/DEBIAN/triggers
@@ -0,0 +1 @@
+interest /test/trigger
diff --git a/tests/t-triggers-path/Makefile b/tests/t-triggers-path/Makefile
new file mode 100644
index 0000000..c211204
--- /dev/null
+++ b/tests/t-triggers-path/Makefile
@@ -0,0 +1,26 @@
+TESTS_DEB := pkg-interest pkg-trigger-conffile pkg-trigger-cmd
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-interest.deb
+
+ # Test that the trigger gets activated on conffile installation
+ $(DPKG_UNPACK) pkg-trigger-conffile.deb
+ test -e "$(DPKG_INSTDIR)/test-triggered-cmd" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/test-triggered-cmd"
+ $(DPKG_CONFIGURE) pkg-trigger-conffile
+ test -e "$(DPKG_INSTDIR)/test-triggered-file" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/test-triggered-file"
+ $(DPKG_PURGE) pkg-trigger-conffile
+
+ # Test that the trigger gets activated on explicit file request
+ $(DPKG_INSTALL) pkg-trigger-cmd.deb
+ test -e "$(DPKG_INSTDIR)/test-triggered-cmd" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/test-triggered-cmd"
+ $(DPKG_PURGE) pkg-trigger-cmd
+
+ # Cleanup.
+ $(DPKG_PURGE) pkg-interest
+
+test-clean:
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/test-triggered-cmd" "$(DPKG_INSTDIR)/test-triggered-file"
+ -$(DPKG_PURGE) pkg-interest
+ -$(DPKG_PURGE) pkg-trigger-conffile pkg-trigger-cmd
diff --git a/tests/t-triggers-path/pkg-interest/DEBIAN/control b/tests/t-triggers-path/pkg-interest/DEBIAN/control
new file mode 100644
index 0000000..e5a1833
--- /dev/null
+++ b/tests/t-triggers-path/pkg-interest/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-interest
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - interested in files under /test/
diff --git a/tests/t-triggers-path/pkg-interest/DEBIAN/postinst b/tests/t-triggers-path/pkg-interest/DEBIAN/postinst
new file mode 100755
index 0000000..3968b80
--- /dev/null
+++ b/tests/t-triggers-path/pkg-interest/DEBIAN/postinst
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ triggered)
+ if [ -e "$DPKG_ROOT/test/trigger/test-file" ]; then
+ touch "$DPKG_ROOT/test-triggered-file"
+ else
+ touch "$DPKG_ROOT/test-triggered-cmd"
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-triggers-path/pkg-interest/DEBIAN/triggers b/tests/t-triggers-path/pkg-interest/DEBIAN/triggers
new file mode 100644
index 0000000..b88b9d1
--- /dev/null
+++ b/tests/t-triggers-path/pkg-interest/DEBIAN/triggers
@@ -0,0 +1 @@
+interest /test
diff --git a/tests/t-triggers-path/pkg-trigger-cmd/DEBIAN/control b/tests/t-triggers-path/pkg-trigger-cmd/DEBIAN/control
new file mode 100644
index 0000000..de4f335
--- /dev/null
+++ b/tests/t-triggers-path/pkg-trigger-cmd/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-trigger-cmd
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - package to be configured
diff --git a/tests/t-triggers-path/pkg-trigger-cmd/DEBIAN/postinst b/tests/t-triggers-path/pkg-trigger-cmd/DEBIAN/postinst
new file mode 100755
index 0000000..8ee3e60
--- /dev/null
+++ b/tests/t-triggers-path/pkg-trigger-cmd/DEBIAN/postinst
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -e
+
+dpkg-trigger /test/trigger/trig-cmd
diff --git a/tests/t-triggers-path/pkg-trigger-conffile/DEBIAN/conffiles b/tests/t-triggers-path/pkg-trigger-conffile/DEBIAN/conffiles
new file mode 100644
index 0000000..2b0ad40
--- /dev/null
+++ b/tests/t-triggers-path/pkg-trigger-conffile/DEBIAN/conffiles
@@ -0,0 +1 @@
+/test/trigger/test-file
diff --git a/tests/t-triggers-path/pkg-trigger-conffile/DEBIAN/control b/tests/t-triggers-path/pkg-trigger-conffile/DEBIAN/control
new file mode 100644
index 0000000..23b2840
--- /dev/null
+++ b/tests/t-triggers-path/pkg-trigger-conffile/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-trigger-conffile
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provides a conffile under /test/trigger/
diff --git a/tests/t-triggers-path/pkg-trigger-conffile/test/trigger/test-file b/tests/t-triggers-path/pkg-trigger-conffile/test/trigger/test-file
new file mode 100644
index 0000000..fb67027
--- /dev/null
+++ b/tests/t-triggers-path/pkg-trigger-conffile/test/trigger/test-file
@@ -0,0 +1 @@
+sample file
diff --git a/tests/t-triggers-selfcycle/Makefile b/tests/t-triggers-selfcycle/Makefile
new file mode 100644
index 0000000..cd916f8
--- /dev/null
+++ b/tests/t-triggers-selfcycle/Makefile
@@ -0,0 +1,25 @@
+TESTS_DEB := pkg-trigger-unpack pkg-trigger-activate
+
+include ../Test.mk
+
+test-case:
+ # Self trigger cycles cannot happen with unpacked files.
+ $(DPKG_INSTALL) pkg-trigger-unpack.deb
+ $(DPKG_UNPACK) pkg-trigger-unpack.deb
+ $(DPKG_CONFIGURE) pkg-trigger-unpack
+ $(DPKG_CONFIGURE) --pending
+ $(DPKG_PURGE) pkg-trigger-unpack
+
+ # Self trigger cycles cannot happen with activate directives.
+ $(DPKG_INSTALL) pkg-trigger-activate.deb
+ $(DPKG_UNPACK) pkg-trigger-activate.deb
+ $(DPKG_CONFIGURE) pkg-trigger-activate
+ $(DPKG_CONFIGURE) --pending
+ $(DPKG_PURGE) pkg-trigger-activate
+
+ # Cleanup.
+ $(DPKG_PURGE) pkg-trigger-unpack
+ $(DPKG_PURGE) pkg-trigger-activate
+
+test-clean:
+ -$(DPKG_PURGE) pkg-trigger-unpack pkg-trigger-activate
diff --git a/tests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/control b/tests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/control
new file mode 100644
index 0000000..30a26fa
--- /dev/null
+++ b/tests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-trigger-activate
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - interested in files on /test/trigger/
diff --git a/tests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/postinst b/tests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/postinst
new file mode 100755
index 0000000..4039f5b
--- /dev/null
+++ b/tests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/postinst
@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ triggered)
+ echo "Pass: triggers processed"
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/triggers b/tests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/triggers
new file mode 100644
index 0000000..9ca0c8c
--- /dev/null
+++ b/tests/t-triggers-selfcycle/pkg-trigger-activate/DEBIAN/triggers
@@ -0,0 +1,2 @@
+interest /test/trigger
+activate /test/trigger
diff --git a/tests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/control b/tests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/control
new file mode 100644
index 0000000..45b7d2a
--- /dev/null
+++ b/tests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-trigger-unpack
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - interested in files on /test/trigger/
diff --git a/tests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/postinst b/tests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/postinst
new file mode 100755
index 0000000..4039f5b
--- /dev/null
+++ b/tests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/postinst
@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+
+case "$1" in
+ triggered)
+ echo "Pass: triggers processed"
+ ;;
+esac
+
+exit 0
diff --git a/tests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/triggers b/tests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/triggers
new file mode 100644
index 0000000..3b047af
--- /dev/null
+++ b/tests/t-triggers-selfcycle/pkg-trigger-unpack/DEBIAN/triggers
@@ -0,0 +1 @@
+interest /test/trigger
diff --git a/tests/t-triggers-selfcycle/pkg-trigger-unpack/test/trigger/test-file b/tests/t-triggers-selfcycle/pkg-trigger-unpack/test/trigger/test-file
new file mode 100644
index 0000000..647063d
--- /dev/null
+++ b/tests/t-triggers-selfcycle/pkg-trigger-unpack/test/trigger/test-file
@@ -0,0 +1 @@
+activating file
diff --git a/tests/t-triggers/Makefile b/tests/t-triggers/Makefile
new file mode 100644
index 0000000..48cd8b6
--- /dev/null
+++ b/tests/t-triggers/Makefile
@@ -0,0 +1,365 @@
+TESTS_DEB := pkg-triggers pkg-triggers-await pkg-triggers-noawait \
+ pkg-trig-file pkg-trig-explicit pkg-trig-cmd
+
+include ../Test.mk
+
+TEST_CASES += test-trigger-file
+TEST_CASES += test-trigger-explicit
+TEST_CASES += test-trigger-cmd
+TEST_CASES += test-trigger-await-file
+TEST_CASES += test-trigger-await-cmd
+TEST_CASES += test-trigger-noawait-file
+TEST_CASES += test-trigger-noawait-explicit
+TEST_CASES += test-trigger-noawait-cmd
+TEST_CASES += test-internal-db
+
+test-case: $(TEST_CASES)
+
+test-trigger-file test-trigger-await-file:
+ if [ "$@" = "test-trigger-file" ]; then \
+ $(DPKG_UNPACK) pkg-triggers.deb; \
+ else \
+ $(DPKG_UNPACK) pkg-triggers-await.deb; \
+ fi
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok" "$(DPKG_INSTDIR)/triggers/ok"
+ # When unpacked, triggers are not active
+ $(DPKG_INSTALL) --no-triggers pkg-trig-file.deb
+ $(call pkg_is_installed,pkg-trig-file)
+ $(call pkg_status_is,pkg-triggers,install ok unpacked)
+ $(call pkg_field_is,pkg-triggers,Triggers-Pending,)
+ ! test -f "$(DPKG_INSTDIR)/triggers/ok"
+ $(DPKG_CONFIGURE) --no-triggers pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ ! test -f "$(DPKG_INSTDIR)/triggers/ok"
+ # When installed, triggers can be activated
+ $(DPKG_INSTALL) --no-triggers pkg-trig-file.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_field_is,pkg-triggers,Triggers-Pending, /triggers)
+ $(call pkg_status_is,pkg-trig-file,install ok triggers-awaited)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ $(call pkg_is_installed,pkg-trig-file)
+ test -f "$(DPKG_INSTDIR)/triggers/ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/triggers/ok"
+ # Try other ways to run the triggers
+ $(DPKG_INSTALL) --no-triggers pkg-trig-file.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-file,install ok triggers-awaited)
+ $(BEROOT) $(DPKG) --triggers-only --pending
+ $(call pkg_is_installed,pkg-trig-file)
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/triggers/ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/triggers/ok"
+ # Again
+ $(DPKG_INSTALL) --no-triggers pkg-trig-file.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-file,install ok triggers-awaited)
+ $(DPKG_CONFIGURE) --pending
+ $(call pkg_is_installed,pkg-trig-file)
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/triggers/ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/triggers/ok"
+ # Again, but we're unpacking instead of installing
+ $(DPKG_UNPACK) --no-triggers pkg-trig-file.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-file,install ok unpacked)
+ $(DPKG_CONFIGURE) pkg-trig-file
+ # FIXME: Remove ifdef during dpkg 1.18.x cycle, after the apt
+ # workaround has been reverted.
+ifdef DPKG_HAS_CONFIGURE_WITH_IMPLICIT_TRIGGER_PENDING
+ $(call pkg_status_is,pkg-trig-file,install ok triggers-awaited)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+endif
+ $(call pkg_is_installed,pkg-trig-file)
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/triggers/ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/triggers/ok"
+ # Cleanup
+ $(DPKG_PURGE) pkg-triggers
+ $(DPKG_PURGE) pkg-trig-file
+
+test-trigger-noawait-file:
+ $(DPKG_UNPACK) pkg-triggers-noawait.deb
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok" "$(DPKG_INSTDIR)/triggers/ok"
+ # When unpacked, triggers are not active
+ $(DPKG_INSTALL) --no-triggers pkg-trig-file.deb
+ $(call pkg_is_installed,pkg-trig-file)
+ $(call pkg_status_is,pkg-triggers,install ok unpacked)
+ $(call pkg_field_is,pkg-triggers,Triggers-Pending,)
+ ! test -f "$(DPKG_INSTDIR)/triggers/ok"
+ $(DPKG_CONFIGURE) --no-triggers pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ ! test -f "$(DPKG_INSTDIR)/triggers/ok"
+ # When installed, triggers can be activated
+ $(DPKG_INSTALL) --no-triggers pkg-trig-file.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_field_is,pkg-triggers,Triggers-Pending, /triggers)
+ $(call pkg_is_installed,pkg-trig-file)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/triggers/ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/triggers/ok"
+ # Try other ways to run the triggers
+ $(DPKG_INSTALL) --no-triggers pkg-trig-file.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_is_installed,pkg-trig-file)
+ $(BEROOT) $(DPKG) --triggers-only --pending
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/triggers/ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/triggers/ok"
+ # Again
+ $(DPKG_INSTALL) --no-triggers pkg-trig-file.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_is_installed,pkg-trig-file)
+ $(DPKG_CONFIGURE) --pending
+ $(call pkg_is_installed,pkg-trig-file)
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/triggers/ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/triggers/ok"
+ # Again, but we're unpacking instead of installing
+ $(DPKG_UNPACK) --no-triggers pkg-trig-file.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-file,install ok unpacked)
+ $(DPKG_CONFIGURE) --no-triggers pkg-trig-file
+ $(call pkg_is_installed,pkg-trig-file)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/triggers/ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/triggers/ok"
+ # Cleanup
+ $(DPKG_PURGE) pkg-triggers
+ $(DPKG_PURGE) pkg-trig-file
+
+test-trigger-explicit:
+ $(DPKG_UNPACK) pkg-triggers.deb
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok" "$(DPKG_INSTDIR)/triggers/ok"
+ # When unpacked, triggers are not active
+ $(DPKG_INSTALL) --no-triggers pkg-trig-explicit.deb
+ $(call pkg_is_installed,pkg-trig-explicit)
+ $(call pkg_status_is,pkg-triggers,install ok unpacked)
+ $(call pkg_field_is,pkg-triggers,Triggers-Pending,)
+ ! test -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(DPKG_CONFIGURE) --no-triggers pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ ! test -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ # When installed, triggers can be activated
+ $(DPKG_INSTALL) --no-triggers pkg-trig-explicit.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_field_is,pkg-triggers,Triggers-Pending, a-trigger)
+ $(call pkg_status_is,pkg-trig-explicit,install ok triggers-awaited)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ $(call pkg_is_installed,pkg-trig-explicit)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ # Try other ways to run the triggers
+ $(DPKG_INSTALL) --no-triggers pkg-trig-explicit.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-explicit,install ok triggers-awaited)
+ $(BEROOT) $(DPKG) --triggers-only --pending
+ $(call pkg_is_installed,pkg-trig-explicit)
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ # Again
+ $(DPKG_INSTALL) --no-triggers pkg-trig-explicit.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-explicit,install ok triggers-awaited)
+ $(DPKG_CONFIGURE) --pending
+ $(call pkg_is_installed,pkg-trig-explicit)
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ # Again, but we're unpacking instead of installing
+ $(DPKG_UNPACK) --no-triggers pkg-trig-explicit.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-explicit,install ok unpacked)
+ $(DPKG_CONFIGURE) pkg-trig-explicit
+ $(call pkg_is_installed,pkg-trig-explicit)
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ # Verify the trigger is activated on each status change
+ $(DPKG_UNPACK) --no-triggers pkg-trig-explicit.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-explicit,install ok unpacked)
+ $(call pkg_field_is,pkg-trig-explicit,Triggers-Awaited, pkg-triggers)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ $(call pkg_field_is,pkg-trig-explicit,Triggers-Awaited,)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(DPKG_CONFIGURE) --no-triggers pkg-trig-explicit
+ $(call pkg_status_is,pkg-trig-explicit,install ok triggers-awaited)
+ $(call pkg_field_is,pkg-trig-explicit,Triggers-Awaited, pkg-triggers)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-trig-explicit)
+ $(call pkg_is_installed,pkg-triggers)
+ # Cleanup
+ $(DPKG_PURGE) pkg-triggers
+ $(DPKG_PURGE) pkg-trig-explicit
+
+test-trigger-noawait-explicit:
+ $(DPKG_INSTALL) pkg-triggers-noawait.deb
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok" "$(DPKG_INSTDIR)/triggers/ok"
+ # When installed, triggers can be activated
+ $(DPKG_INSTALL) --no-triggers pkg-trig-explicit.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_field_is,pkg-triggers,Triggers-Pending, a-trigger)
+ $(call pkg_is_installed,pkg-trig-explicit)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ # Again, but we're unpacking instead of installing
+ $(DPKG_UNPACK) --no-triggers pkg-trig-explicit.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-explicit,install ok unpacked)
+ $(call pkg_field_is,pkg-trig-explicit,Triggers-Awaited,)
+ $(DPKG_CONFIGURE) --no-triggers pkg-trig-explicit
+ $(call pkg_is_installed,pkg-trig-explicit)
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(DPKG_CONFIGURE) --pending
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ # Verify the trigger is activated on each status change
+ $(DPKG_UNPACK) --no-triggers pkg-trig-explicit.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-explicit,install ok unpacked)
+ $(call pkg_field_is,pkg-trig-explicit,Triggers-Awaited,)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(DPKG_CONFIGURE) --no-triggers pkg-trig-explicit
+ $(call pkg_is_installed,pkg-trig-explicit)
+ $(call pkg_field_is,pkg-trig-explicit,Triggers-Awaited,)
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ # Cleanup
+ $(DPKG_PURGE) pkg-triggers
+ $(DPKG_PURGE) pkg-trig-explicit
+
+test-trigger-cmd test-trigger-await-cmd:
+ if [ "$@" = "test-trigger-await-cmd" ]; then \
+ $(BEROOT) touch "$(DPKG_INSTDIR)/trigger-await"; \
+ fi
+ $(DPKG_UNPACK) pkg-triggers.deb
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok" "$(DPKG_INSTDIR)/triggers/ok"
+ # When unpacked, triggers are not active
+ $(BEROOT) touch "$(DPKG_INSTDIR)/trigger-postinst" "$(DPKG_INSTDIR)/trigger-preinst" "$(DPKG_INSTDIR)/trigger-postrm" "$(DPKG_INSTDIR)/trigger-prerm"
+ $(DPKG_INSTALL) --no-triggers pkg-trig-cmd.deb
+ $(call pkg_is_installed,pkg-trig-cmd)
+ $(call pkg_status_is,pkg-triggers,install ok unpacked)
+ $(call pkg_field_is,pkg-triggers,Triggers-Pending,)
+ ! test -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(DPKG_CONFIGURE) --no-triggers pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ ! test -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ # When installed, triggers can be activated
+ $(DPKG_INSTALL) --no-triggers pkg-trig-cmd.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_field_is,pkg-triggers,Triggers-Pending, a-trigger)
+ $(call pkg_status_is,pkg-trig-cmd,install ok triggers-awaited)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ $(call pkg_is_installed,pkg-trig-cmd)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-postinst" "$(DPKG_INSTDIR)/trigger-preinst" "$(DPKG_INSTDIR)/trigger-postrm" "$(DPKG_INSTDIR)/trigger-prerm"
+ # Call dpkg-trigger in the preinst
+ $(BEROOT) touch "$(DPKG_INSTDIR)/trigger-preinst"
+ $(DPKG_UNPACK) --no-triggers pkg-trig-cmd.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-cmd,install ok unpacked)
+ $(call pkg_field_is,pkg-trig-cmd,Triggers-Awaited, pkg-triggers)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_field_is,pkg-trig-cmd,Triggers-Awaited,)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-preinst"
+ # Call dpkg-trigger in the postinst
+ $(BEROOT) touch "$(DPKG_INSTDIR)/trigger-postinst"
+ $(DPKG_CONFIGURE) --no-triggers pkg-trig-cmd
+ $(call pkg_status_is,pkg-trig-cmd,install ok triggers-awaited)
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ $(call pkg_is_installed,pkg-trig-cmd)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-postinst"
+ # Call dpkg-trigger in the prerm
+ $(BEROOT) touch "$(DPKG_INSTDIR)/trigger-prerm"
+ $(DPKG_UNPACK) --no-triggers pkg-trig-cmd.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-cmd,install ok unpacked)
+ $(call pkg_field_is,pkg-trig-cmd,Triggers-Awaited, pkg-triggers)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_field_is,pkg-trig-cmd,Triggers-Awaited,)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-prerm"
+ # Call dpkg-trigger in the postrm
+ $(BEROOT) touch "$(DPKG_INSTDIR)/trigger-postrm"
+ $(DPKG_UNPACK) --no-triggers pkg-trig-cmd.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-cmd,install ok unpacked)
+ $(call pkg_field_is,pkg-trig-cmd,Triggers-Awaited, pkg-triggers)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_field_is,pkg-trig-cmd,Triggers-Awaited,)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-postrm"
+ # Cleanup
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-await"
+ $(DPKG_PURGE) pkg-triggers
+ $(DPKG_PURGE) pkg-trig-cmd
+
+test-trigger-noawait-cmd:
+ $(BEROOT) touch "$(DPKG_INSTDIR)/trigger-noawait"
+ $(DPKG_UNPACK) pkg-triggers.deb
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok" "$(DPKG_INSTDIR)/triggers/ok"
+ # When unpacked, triggers are not active
+ $(BEROOT) touch "$(DPKG_INSTDIR)/trigger-postinst" "$(DPKG_INSTDIR)/trigger-preinst" "$(DPKG_INSTDIR)/trigger-postrm" "$(DPKG_INSTDIR)/trigger-prerm"
+ $(DPKG_INSTALL) --no-triggers pkg-trig-cmd.deb
+ $(call pkg_is_installed,pkg-trig-cmd)
+ $(call pkg_status_is,pkg-triggers,install ok unpacked)
+ $(call pkg_field_is,pkg-triggers,Triggers-Pending,)
+ ! test -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(DPKG_CONFIGURE) --no-triggers pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ ! test -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ # When installed, triggers can be activated
+ $(DPKG_INSTALL) --no-triggers pkg-trig-cmd.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_field_is,pkg-triggers,Triggers-Pending, a-trigger)
+ $(call pkg_is_installed,pkg-trig-cmd)
+ $(call pkg_field_is,pkg-trig-cmd,Triggers-Awaited,)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-postinst" "$(DPKG_INSTDIR)/trigger-preinst" "$(DPKG_INSTDIR)/trigger-postrm" "$(DPKG_INSTDIR)/trigger-prerm"
+ # Call dpkg-trigger in the preinst
+ $(BEROOT) touch "$(DPKG_INSTDIR)/trigger-preinst"
+ $(DPKG_UNPACK) --no-triggers pkg-trig-cmd.deb
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(call pkg_status_is,pkg-trig-cmd,install ok unpacked)
+ $(call pkg_field_is,pkg-trig-cmd,Triggers-Awaited,)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-preinst"
+ # Call dpkg-trigger in the postinst
+ $(BEROOT) touch "$(DPKG_INSTDIR)/trigger-postinst"
+ $(DPKG_CONFIGURE) --no-triggers pkg-trig-cmd
+ $(call pkg_is_installed,pkg-trig-cmd)
+ $(call pkg_status_is,pkg-triggers,install ok triggers-pending)
+ $(BEROOT) $(DPKG) --triggers-only pkg-triggers
+ $(call pkg_is_installed,pkg-triggers)
+ test -f "$(DPKG_INSTDIR)/a-trigger-ok" && $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok"
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-postinst"
+ # Cleanup
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-noawait"
+ $(DPKG_PURGE) pkg-triggers
+ $(DPKG_PURGE) pkg-trig-cmd
+
+test-internal-db:
+ # test that installing triggers creates the corresponding files
+ $(DPKG_INSTALL) pkg-triggers.deb
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/a-trigger",pkg-triggers)
+ grep -q "^/triggers pkg-triggers$$" "$(DPKG_ADMINDIR)/triggers/File"
+ $(DPKG_INSTALL) pkg-triggers-noawait.deb
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/a-trigger",pkg-triggers/noawait)
+ grep -q "^/triggers pkg-triggers/noawait$$" "$(DPKG_ADMINDIR)/triggers/File"
+ # Test that removal cleans up the triggers files
+ $(DPKG_PURGE) pkg-triggers
+ ! test -e "$(DPKG_ADMINDIR)/triggers/a-trigger"
+ ! test -e "$(DPKG_ADMINDIR)/triggers/File"
+
+test-clean:
+ $(DPKG_PURGE) pkg-triggers pkg-trig-file pkg-trig-explicit pkg-trig-cmd
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/a-trigger-ok" "$(DPKG_INSTDIR)/triggers/ok"
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-postinst" "$(DPKG_INSTDIR)/trigger-preinst" "$(DPKG_INSTDIR)/trigger-postrm" "$(DPKG_INSTDIR)/trigger-prerm"
+ $(BEROOT) rm -f "$(DPKG_INSTDIR)/trigger-noawait"
+
diff --git a/tests/t-triggers/pkg-trig-cmd/DEBIAN/control b/tests/t-triggers/pkg-trig-cmd/DEBIAN/control
new file mode 100644
index 0000000..196c8a8
--- /dev/null
+++ b/tests/t-triggers/pkg-trig-cmd/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-trig-cmd
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - running dpkg-trigger in maintainer scripts
+
diff --git a/tests/t-triggers/pkg-trig-cmd/DEBIAN/postinst b/tests/t-triggers/pkg-trig-cmd/DEBIAN/postinst
new file mode 100755
index 0000000..3975be0
--- /dev/null
+++ b/tests/t-triggers/pkg-trig-cmd/DEBIAN/postinst
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+
+if [ -e "$DPKG_ROOT/trigger-$DPKG_MAINTSCRIPT_NAME" ]; then
+ if [ -e "$DPKG_ROOT/trigger-noawait" ]; then
+ echo "Executing 'dpkg-trigger --no-await a-trigger' from '$0 $1'"
+ dpkg-trigger --no-await a-trigger
+ elif [ -e "$DPKG_ROOT/trigger-await" ]; then
+ echo "Executing 'dpkg-trigger --await a-trigger' from '$0 $1'"
+ dpkg-trigger --await a-trigger
+ else
+ echo "Executing 'dpkg-trigger a-trigger' from '$0 $1'"
+ dpkg-trigger a-trigger
+ fi
+fi
+
diff --git a/tests/t-triggers/pkg-trig-cmd/DEBIAN/postrm b/tests/t-triggers/pkg-trig-cmd/DEBIAN/postrm
new file mode 100755
index 0000000..3975be0
--- /dev/null
+++ b/tests/t-triggers/pkg-trig-cmd/DEBIAN/postrm
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+
+if [ -e "$DPKG_ROOT/trigger-$DPKG_MAINTSCRIPT_NAME" ]; then
+ if [ -e "$DPKG_ROOT/trigger-noawait" ]; then
+ echo "Executing 'dpkg-trigger --no-await a-trigger' from '$0 $1'"
+ dpkg-trigger --no-await a-trigger
+ elif [ -e "$DPKG_ROOT/trigger-await" ]; then
+ echo "Executing 'dpkg-trigger --await a-trigger' from '$0 $1'"
+ dpkg-trigger --await a-trigger
+ else
+ echo "Executing 'dpkg-trigger a-trigger' from '$0 $1'"
+ dpkg-trigger a-trigger
+ fi
+fi
+
diff --git a/tests/t-triggers/pkg-trig-cmd/DEBIAN/preinst b/tests/t-triggers/pkg-trig-cmd/DEBIAN/preinst
new file mode 100755
index 0000000..3975be0
--- /dev/null
+++ b/tests/t-triggers/pkg-trig-cmd/DEBIAN/preinst
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+
+if [ -e "$DPKG_ROOT/trigger-$DPKG_MAINTSCRIPT_NAME" ]; then
+ if [ -e "$DPKG_ROOT/trigger-noawait" ]; then
+ echo "Executing 'dpkg-trigger --no-await a-trigger' from '$0 $1'"
+ dpkg-trigger --no-await a-trigger
+ elif [ -e "$DPKG_ROOT/trigger-await" ]; then
+ echo "Executing 'dpkg-trigger --await a-trigger' from '$0 $1'"
+ dpkg-trigger --await a-trigger
+ else
+ echo "Executing 'dpkg-trigger a-trigger' from '$0 $1'"
+ dpkg-trigger a-trigger
+ fi
+fi
+
diff --git a/tests/t-triggers/pkg-trig-cmd/DEBIAN/prerm b/tests/t-triggers/pkg-trig-cmd/DEBIAN/prerm
new file mode 100755
index 0000000..3975be0
--- /dev/null
+++ b/tests/t-triggers/pkg-trig-cmd/DEBIAN/prerm
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+
+if [ -e "$DPKG_ROOT/trigger-$DPKG_MAINTSCRIPT_NAME" ]; then
+ if [ -e "$DPKG_ROOT/trigger-noawait" ]; then
+ echo "Executing 'dpkg-trigger --no-await a-trigger' from '$0 $1'"
+ dpkg-trigger --no-await a-trigger
+ elif [ -e "$DPKG_ROOT/trigger-await" ]; then
+ echo "Executing 'dpkg-trigger --await a-trigger' from '$0 $1'"
+ dpkg-trigger --await a-trigger
+ else
+ echo "Executing 'dpkg-trigger a-trigger' from '$0 $1'"
+ dpkg-trigger a-trigger
+ fi
+fi
+
diff --git a/tests/t-triggers/pkg-trig-explicit/DEBIAN/control b/tests/t-triggers/pkg-trig-explicit/DEBIAN/control
new file mode 100644
index 0000000..8fdfeca
--- /dev/null
+++ b/tests/t-triggers/pkg-trig-explicit/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-trig-explicit
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - activate trigger "a-trigger"
+
diff --git a/tests/t-triggers/pkg-trig-explicit/DEBIAN/triggers b/tests/t-triggers/pkg-trig-explicit/DEBIAN/triggers
new file mode 100644
index 0000000..cc71459
--- /dev/null
+++ b/tests/t-triggers/pkg-trig-explicit/DEBIAN/triggers
@@ -0,0 +1 @@
+activate a-trigger
diff --git a/tests/t-triggers/pkg-trig-file/DEBIAN/control b/tests/t-triggers/pkg-trig-file/DEBIAN/control
new file mode 100644
index 0000000..ef3663a
--- /dev/null
+++ b/tests/t-triggers/pkg-trig-file/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-trig-file
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - install a file in /triggers
+
diff --git a/tests/t-triggers/pkg-trig-file/triggers/a-file b/tests/t-triggers/pkg-trig-file/triggers/a-file
new file mode 100644
index 0000000..4dd1ef7
--- /dev/null
+++ b/tests/t-triggers/pkg-trig-file/triggers/a-file
@@ -0,0 +1 @@
+This is a file.
diff --git a/tests/t-triggers/pkg-triggers-await/DEBIAN/control b/tests/t-triggers/pkg-triggers-await/DEBIAN/control
new file mode 100644
index 0000000..dc27453
--- /dev/null
+++ b/tests/t-triggers/pkg-triggers-await/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-triggers
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - providing triggers
diff --git a/tests/t-triggers/pkg-triggers-await/DEBIAN/postinst b/tests/t-triggers/pkg-triggers-await/DEBIAN/postinst
new file mode 100755
index 0000000..5269ac4
--- /dev/null
+++ b/tests/t-triggers/pkg-triggers-await/DEBIAN/postinst
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ "$1" = "triggered" ]; then
+ case " $2 " in
+ *" a-trigger "*)
+ touch "$DPKG_ROOT/a-trigger-ok"
+ ;;
+ *" /triggers "*)
+ touch "$DPKG_ROOT/triggers/ok"
+ ;;
+ esac
+fi
+
diff --git a/tests/t-triggers/pkg-triggers-await/DEBIAN/triggers b/tests/t-triggers/pkg-triggers-await/DEBIAN/triggers
new file mode 100644
index 0000000..9ce7f67
--- /dev/null
+++ b/tests/t-triggers/pkg-triggers-await/DEBIAN/triggers
@@ -0,0 +1,2 @@
+interest-await a-trigger
+interest-await /triggers
diff --git a/tests/t-triggers/pkg-triggers-noawait/DEBIAN/control b/tests/t-triggers/pkg-triggers-noawait/DEBIAN/control
new file mode 100644
index 0000000..ff9d5d5
--- /dev/null
+++ b/tests/t-triggers/pkg-triggers-noawait/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-triggers
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - providing triggers
+
diff --git a/tests/t-triggers/pkg-triggers-noawait/DEBIAN/postinst b/tests/t-triggers/pkg-triggers-noawait/DEBIAN/postinst
new file mode 100755
index 0000000..5269ac4
--- /dev/null
+++ b/tests/t-triggers/pkg-triggers-noawait/DEBIAN/postinst
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ "$1" = "triggered" ]; then
+ case " $2 " in
+ *" a-trigger "*)
+ touch "$DPKG_ROOT/a-trigger-ok"
+ ;;
+ *" /triggers "*)
+ touch "$DPKG_ROOT/triggers/ok"
+ ;;
+ esac
+fi
+
diff --git a/tests/t-triggers/pkg-triggers-noawait/DEBIAN/triggers b/tests/t-triggers/pkg-triggers-noawait/DEBIAN/triggers
new file mode 100644
index 0000000..13d2512
--- /dev/null
+++ b/tests/t-triggers/pkg-triggers-noawait/DEBIAN/triggers
@@ -0,0 +1,2 @@
+interest-noawait a-trigger
+interest-noawait /triggers
diff --git a/tests/t-triggers/pkg-triggers/DEBIAN/control b/tests/t-triggers/pkg-triggers/DEBIAN/control
new file mode 100644
index 0000000..ff9d5d5
--- /dev/null
+++ b/tests/t-triggers/pkg-triggers/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-triggers
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - providing triggers
+
diff --git a/tests/t-triggers/pkg-triggers/DEBIAN/postinst b/tests/t-triggers/pkg-triggers/DEBIAN/postinst
new file mode 100755
index 0000000..5269ac4
--- /dev/null
+++ b/tests/t-triggers/pkg-triggers/DEBIAN/postinst
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ "$1" = "triggered" ]; then
+ case " $2 " in
+ *" a-trigger "*)
+ touch "$DPKG_ROOT/a-trigger-ok"
+ ;;
+ *" /triggers "*)
+ touch "$DPKG_ROOT/triggers/ok"
+ ;;
+ esac
+fi
+
diff --git a/tests/t-triggers/pkg-triggers/DEBIAN/triggers b/tests/t-triggers/pkg-triggers/DEBIAN/triggers
new file mode 100644
index 0000000..daa582c
--- /dev/null
+++ b/tests/t-triggers/pkg-triggers/DEBIAN/triggers
@@ -0,0 +1,2 @@
+interest a-trigger
+interest /triggers
diff --git a/tests/t-unpack-device/Makefile b/tests/t-unpack-device/Makefile
new file mode 100644
index 0000000..0dcb3ca
--- /dev/null
+++ b/tests/t-unpack-device/Makefile
@@ -0,0 +1,26 @@
+PKG := pkg-device
+
+TESTS_DEB := $(PKG)
+
+include ../Test.mk
+
+$(PKG)/test-null:
+ $(BEROOT) mknod $@ c 1 3
+
+$(PKG)/test-ram0:
+ $(BEROOT) mknod $@ b 1 0
+
+build-hook: $(PKG)/test-null $(PKG)/test-ram0
+
+clean-hook:
+ rm -f $(PKG)/test-null
+ rm -f $(PKG)/test-ram0
+
+test-case:
+ # test unpacking device files
+ $(DPKG_INSTALL) pkg-device.deb
+ $(call pkg_is_installed,pkg-device)
+
+test-clean:
+ $(DPKG_PURGE) pkg-device
+
diff --git a/tests/t-unpack-device/pkg-device/DEBIAN/control b/tests/t-unpack-device/pkg-device/DEBIAN/control
new file mode 100644
index 0000000..e5d5399
--- /dev/null
+++ b/tests/t-unpack-device/pkg-device/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-device
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - devices unpack
+
diff --git a/tests/t-unpack-divert-hardlink/Makefile b/tests/t-unpack-divert-hardlink/Makefile
new file mode 100644
index 0000000..75287f7
--- /dev/null
+++ b/tests/t-unpack-divert-hardlink/Makefile
@@ -0,0 +1,31 @@
+PKG := pkg-hardlink
+
+TESTS_DEB := $(PKG)
+
+include ../Test.mk
+
+$(PKG)/test-hardlink:
+ link $(PKG)/test-file $@
+
+build-hook: $(PKG)/test-hardlink
+
+clean-hook:
+ rm -f $(PKG)/test-hardlink
+
+test-case:
+ $(DPKG_DIVERT_ADD) /test-file
+ $(DPKG_DIVERT_ADD) /test-hardlink
+ # test if unpack can divert a hardlink
+ $(DPKG_INSTALL) pkg-hardlink.deb
+ $(call pkg_is_installed,pkg-hardlink)
+ test -f '$(DPKG_INSTDIR)/test-file.distrib'
+ test -f '$(DPKG_INSTDIR)/test-hardlink.distrib'
+ cmp '$(DPKG_INSTDIR)/test-file.distrib' \
+ '$(DPKG_INSTDIR)/test-hardlink.distrib'
+ test "`stat -c '%i' '$(DPKG_INSTDIR)/test-file.distrib'`" = \
+ "`stat -c '%i' '$(DPKG_INSTDIR)/test-hardlink.distrib'`"
+
+test-clean:
+ $(DPKG_PURGE) pkg-hardlink
+ $(DPKG_DIVERT_DEL) /test-file
+ $(DPKG_DIVERT_DEL) /test-hardlink
diff --git a/tests/t-unpack-divert-hardlink/pkg-hardlink/DEBIAN/control b/tests/t-unpack-divert-hardlink/pkg-hardlink/DEBIAN/control
new file mode 100644
index 0000000..da36e99
--- /dev/null
+++ b/tests/t-unpack-divert-hardlink/pkg-hardlink/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-hardlink
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - provide two hard linked files
diff --git a/tests/t-unpack-divert-hardlink/pkg-hardlink/test-file b/tests/t-unpack-divert-hardlink/pkg-hardlink/test-file
new file mode 100644
index 0000000..94e47d3
--- /dev/null
+++ b/tests/t-unpack-divert-hardlink/pkg-hardlink/test-file
@@ -0,0 +1 @@
+test diverted
diff --git a/tests/t-unpack-divert-nowarn/Makefile b/tests/t-unpack-divert-nowarn/Makefile
new file mode 100644
index 0000000..aa56877
--- /dev/null
+++ b/tests/t-unpack-divert-nowarn/Makefile
@@ -0,0 +1,10 @@
+TESTS_DEB := pkg-files pkg-divert-unpacking
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-files.deb
+ $(DPKG_UNPACK) pkg-divert-unpacking.deb
+
+test-clean:
+ $(DPKG_PURGE) pkg-files pkg-divert-unpacking
diff --git a/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/control b/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/control
new file mode 100644
index 0000000..d677e02
--- /dev/null
+++ b/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-divert-unpacking
+Version: 0
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - divert a file w/o having ever unpacked
+ This should not result in any warning.
diff --git a/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/postrm b/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/postrm
new file mode 100755
index 0000000..8d834a5
--- /dev/null
+++ b/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/postrm
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "purge" ]; then
+ dpkg-divert --quiet --remove --rename /test-file
+fi
diff --git a/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/preinst b/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/preinst
new file mode 100755
index 0000000..a61ad11
--- /dev/null
+++ b/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/DEBIAN/preinst
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "install" ] || [ "$1" = "upgrade" ]; then
+ dpkg-divert --quiet --package pkg-divert-unpacking --rename \
+ --divert /test-file.diverted --add /test-file 2>&1 | \
+ grep "warning: " && echo "Fail: warning in output" && exit 1 ||
+ echo Pass
+fi
diff --git a/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/test-file b/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/test-file
new file mode 100644
index 0000000..94e47d3
--- /dev/null
+++ b/tests/t-unpack-divert-nowarn/pkg-divert-unpacking/test-file
@@ -0,0 +1 @@
+test diverted
diff --git a/tests/t-unpack-divert-nowarn/pkg-files/DEBIAN/control b/tests/t-unpack-divert-nowarn/pkg-files/DEBIAN/control
new file mode 100644
index 0000000..b616257
--- /dev/null
+++ b/tests/t-unpack-divert-nowarn/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-nowarn/pkg-files/test-file b/tests/t-unpack-divert-nowarn/pkg-files/test-file
new file mode 100644
index 0000000..6fbc8b5
--- /dev/null
+++ b/tests/t-unpack-divert-nowarn/pkg-files/test-file
@@ -0,0 +1 @@
+test init
diff --git a/tests/t-unpack-fifo/Makefile b/tests/t-unpack-fifo/Makefile
new file mode 100644
index 0000000..eaa848a
--- /dev/null
+++ b/tests/t-unpack-fifo/Makefile
@@ -0,0 +1,22 @@
+PKG := pkg-fifo
+
+TESTS_DEB := pkg-fifo
+
+include ../Test.mk
+
+$(PKG)/test-fifo:
+ mkfifo $@
+
+build-hook: $(PKG)/test-fifo
+
+clean-hook:
+ rm -f $(PKG)/test-fifo
+
+test-case:
+ # test unpacking a fifo
+ $(DPKG_INSTALL) pkg-fifo.deb
+ $(call pkg_is_installed,pkg-fifo)
+
+test-clean:
+ $(DPKG_PURGE) pkg-fifo
+
diff --git a/tests/t-unpack-fifo/pkg-fifo/DEBIAN/control b/tests/t-unpack-fifo/pkg-fifo/DEBIAN/control
new file mode 100644
index 0000000..8087b89
--- /dev/null
+++ b/tests/t-unpack-fifo/pkg-fifo/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-fifo
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - unpacking fifo
+
diff --git a/tests/t-unpack-hardlink/Makefile b/tests/t-unpack-hardlink/Makefile
new file mode 100644
index 0000000..3412ca5
--- /dev/null
+++ b/tests/t-unpack-hardlink/Makefile
@@ -0,0 +1,56 @@
+PKG := pkg-hardlink
+
+TESTS_DEB := $(PKG)
+
+include ../Test.mk
+
+$(PKG)/test-conffile-link0:
+ echo "test hard linked conffile" >$@
+ link $@ $(PKG)/test-conffile-link1
+
+$(PKG)/test-file-link0:
+ echo "test hard linked file" >$@
+ link $@ $(PKG)/test-file-link1
+
+$(PKG)/test-fifo-link0:
+ mkfifo $@
+ link $@ $(PKG)/test-fifo-link1
+
+$(PKG)/test-null-link0:
+ $(BEROOT) mknod $@ c 1 3
+ $(BEROOT) link $@ $(PKG)/test-null-link1
+
+$(PKG)/test-ram0-link0:
+ $(BEROOT) mknod $@ b 1 0
+ $(BEROOT) link $@ $(PKG)/test-ram0-link1
+
+TEST_LINKS := \
+ $(PKG)/test-conffile-link0 \
+ $(PKG)/test-file-link0 \
+ $(PKG)/test-fifo-link0 \
+ # EOL
+
+ifdef DPKG_AS_ROOT
+TEST_LINKS += \
+ $(PKG)/test-null-link0 \
+ $(PKG)/test-ram0-link0 \
+ # EOL
+endif
+
+build-hook: $(TEST_LINKS)
+
+clean-hook:
+ rm -f $(PKG)/test-conffile-link0 $(PKG)/test-conffile-link1
+ rm -f $(PKG)/test-file-link0 $(PKG)/test-file-link1
+ rm -f $(PKG)/test-fifo-link0 $(PKG)/test-fifo-link1
+ rm -f $(PKG)/test-null-link0 $(PKG)/test-null-link1
+ rm -f $(PKG)/test-ram0-link0 $(PKG)/test-ram0-link1
+
+test-case:
+ # test unpacking hardlinks
+ $(DPKG_INSTALL) pkg-hardlink.deb
+ $(call pkg_is_installed,pkg-hardlink)
+
+test-clean:
+ $(DPKG_PURGE) pkg-hardlink
+
diff --git a/tests/t-unpack-hardlink/pkg-hardlink/DEBIAN/conffiles b/tests/t-unpack-hardlink/pkg-hardlink/DEBIAN/conffiles
new file mode 100644
index 0000000..4634045
--- /dev/null
+++ b/tests/t-unpack-hardlink/pkg-hardlink/DEBIAN/conffiles
@@ -0,0 +1,2 @@
+/test-conffile-link0
+/test-conffile-link1
diff --git a/tests/t-unpack-hardlink/pkg-hardlink/DEBIAN/control b/tests/t-unpack-hardlink/pkg-hardlink/DEBIAN/control
new file mode 100644
index 0000000..c513f9c
--- /dev/null
+++ b/tests/t-unpack-hardlink/pkg-hardlink/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-hardlink
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - unpack hardlinks
+
diff --git a/tests/t-unpack-symlink/Makefile b/tests/t-unpack-symlink/Makefile
new file mode 100644
index 0000000..09287f4
--- /dev/null
+++ b/tests/t-unpack-symlink/Makefile
@@ -0,0 +1,12 @@
+TESTS_DEB := pkg-symlink
+
+include ../Test.mk
+
+test-case:
+ # test unpacking symlinks
+ $(DPKG_INSTALL) pkg-symlink.deb
+ $(call pkg_is_installed,pkg-symlink)
+
+test-clean:
+ $(DPKG_PURGE) pkg-symlink
+
diff --git a/tests/t-unpack-symlink/pkg-symlink/DEBIAN/control b/tests/t-unpack-symlink/pkg-symlink/DEBIAN/control
new file mode 100644
index 0000000..f57852f
--- /dev/null
+++ b/tests/t-unpack-symlink/pkg-symlink/DEBIAN/control
@@ -0,0 +1,8 @@
+Package: pkg-symlink
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - unpack symlink
+
diff --git a/tests/t-unpack-symlink/pkg-symlink/test-file b/tests/t-unpack-symlink/pkg-symlink/test-file
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-unpack-symlink/pkg-symlink/test-file
diff --git a/tests/t-unpack-symlink/pkg-symlink/test-symlink b/tests/t-unpack-symlink/pkg-symlink/test-symlink
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-unpack-symlink/pkg-symlink/test-symlink
diff --git a/tests/t-verify/Makefile b/tests/t-verify/Makefile
new file mode 100644
index 0000000..2763e84
--- /dev/null
+++ b/tests/t-verify/Makefile
@@ -0,0 +1,13 @@
+TESTS_DEB := pkg-verify
+
+include ../Test.mk
+
+test-case:
+ $(DPKG_INSTALL) pkg-verify.deb
+ $(call pkg_is_installed,pkg-verify)
+ $(call stdout_is,$(DPKG_VERIFY) pkg-verify,)
+ $(BEROOT) sh -c "echo 'MODIFIED' >>'$(DPKG_INSTDIR)/test-dir/test-data'"
+ $(call stdout_has,$(DPKG_VERIFY) pkg-verify,^\?\?5\?\?\?\?\?\? /test-dir/test-data$)
+
+test-clean:
+ $(DPKG_PURGE) pkg-verify
diff --git a/tests/t-verify/pkg-verify/DEBIAN/control b/tests/t-verify/pkg-verify/DEBIAN/control
new file mode 100644
index 0000000..5d383a2
--- /dev/null
+++ b/tests/t-verify/pkg-verify/DEBIAN/control
@@ -0,0 +1,7 @@
+Package: pkg-verify
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Description: test package - verify
diff --git a/tests/t-verify/pkg-verify/test-dir/test-data b/tests/t-verify/pkg-verify/test-dir/test-data
new file mode 100644
index 0000000..f2f6d87
--- /dev/null
+++ b/tests/t-verify/pkg-verify/test-dir/test-data
@@ -0,0 +1 @@
+some other data
diff --git a/tests/t-verify/pkg-verify/test-dir/test-digits b/tests/t-verify/pkg-verify/test-dir/test-digits
new file mode 100644
index 0000000..0ff3bbb
--- /dev/null
+++ b/tests/t-verify/pkg-verify/test-dir/test-digits
@@ -0,0 +1,20 @@
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
diff --git a/tests/t-verify/pkg-verify/test-file b/tests/t-verify/pkg-verify/test-file
new file mode 100644
index 0000000..7a1c613
--- /dev/null
+++ b/tests/t-verify/pkg-verify/test-file
@@ -0,0 +1 @@
+some file