summaryrefslogtreecommitdiffstats
path: root/tests/t-triggers
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:35:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:35:28 +0000
commitea314d2f45c40a006c0104157013ab4b857f665f (patch)
tree3ef2971cb3675c318b8d9effd987854ad3f6d3e8 /tests/t-triggers
parentInitial commit. (diff)
downloaddpkg-ea314d2f45c40a006c0104157013ab4b857f665f.tar.xz
dpkg-ea314d2f45c40a006c0104157013ab4b857f665f.zip
Adding upstream version 1.22.4.upstream/1.22.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-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-db/Makefile50
-rw-r--r--tests/t-triggers-db/pkg-triggers-foreign/DEBIAN/control9
-rw-r--r--tests/t-triggers-db/pkg-triggers-foreign/DEBIAN/triggers2
-rw-r--r--tests/t-triggers-db/pkg-triggers-native/DEBIAN/control8
-rw-r--r--tests/t-triggers-db/pkg-triggers-native/DEBIAN/triggers2
-rw-r--r--tests/t-triggers-db/pkg-triggers-same/DEBIAN/control9
-rw-r--r--tests/t-triggers-db/pkg-triggers-same/DEBIAN/triggers2
-rw-r--r--tests/t-triggers-db/tmpl-db-foreign/arch2
-rw-r--r--tests/t-triggers-db/tmpl-db-foreign/info/format1
-rw-r--r--tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.list1
-rw-r--r--tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.md5sums0
-rw-r--r--tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.triggers2
-rw-r--r--tests/t-triggers-db/tmpl-db-foreign/status10
-rw-r--r--tests/t-triggers-db/tmpl-db-foreign/triggers/File1
-rw-r--r--tests/t-triggers-db/tmpl-db-foreign/triggers/a-trigger1
-rw-r--r--tests/t-triggers-db/tmpl-db-native/arch2
-rw-r--r--tests/t-triggers-db/tmpl-db-native/info/format1
-rw-r--r--tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.list1
-rw-r--r--tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.md5sums0
-rw-r--r--tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.triggers2
-rw-r--r--tests/t-triggers-db/tmpl-db-native/status10
-rw-r--r--tests/t-triggers-db/tmpl-db-native/triggers/File1
-rw-r--r--tests/t-triggers-db/tmpl-db-native/triggers/a-trigger1
-rw-r--r--tests/t-triggers-db/tmpl-db-same/arch2
-rw-r--r--tests/t-triggers-db/tmpl-db-same/info/format1
-rw-r--r--tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.list1
-rw-r--r--tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.md5sums0
-rw-r--r--tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.triggers2
-rw-r--r--tests/t-triggers-db/tmpl-db-same/status10
-rw-r--r--tests/t-triggers-db/tmpl-db-same/triggers/File1
-rw-r--r--tests/t-triggers-db/tmpl-db-same/triggers/a-trigger1
-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
116 files changed, 1264 insertions, 0 deletions
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-db/Makefile b/tests/t-triggers-db/Makefile
new file mode 100644
index 0000000..c0766d6
--- /dev/null
+++ b/tests/t-triggers-db/Makefile
@@ -0,0 +1,50 @@
+TESTS_DEB := pkg-triggers-native pkg-triggers-foreign pkg-triggers-same
+
+include ../Test.mk
+
+TEST_CASES += test-trigger-db-native-to-same
+TEST_CASES += test-trigger-db-foreign-to-same
+TEST_CASES += test-trigger-db-same-to-same
+
+test-case: $(TEST_CASES)
+
+test-trigger-db-native-to-same: override DPKG_ADMINDIR = db-native
+test-trigger-db-native-to-same:
+ cp -a tmpl-$(DPKG_ADMINDIR) $(DPKG_ADMINDIR)
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/a-trigger",pkg-triggers)
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/File",/triggers pkg-triggers)
+ $(DPKG_INSTALL) pkg-triggers-native.deb
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/a-trigger",pkg-triggers/noawait)
+ grep -q "^/triggers pkg-triggers/noawait$$" "$(DPKG_ADMINDIR)/triggers/File"
+ $(DPKG_INSTALL) pkg-triggers-same.deb
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/a-trigger",pkg-triggers:amd64/noawait)
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/File",/triggers pkg-triggers:amd64/noawait)
+ $(DPKG_PURGE) pkg-triggers
+
+test-trigger-db-foreign-to-same: override DPKG_ADMINDIR = db-foreign
+test-trigger-db-foreign-to-same:
+ cp -a tmpl-$(DPKG_ADMINDIR) $(DPKG_ADMINDIR)
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/a-trigger",pkg-triggers:other)
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/File",/triggers pkg-triggers:other)
+ : # The db needs to be reproducible, so it gets normalized on upgrade.
+ $(DPKG_INSTALL) pkg-triggers-foreign.deb
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/a-trigger",pkg-triggers/noawait)
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/File",/triggers pkg-triggers/noawait)
+ $(DPKG_INSTALL) pkg-triggers-same.deb
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/a-trigger",pkg-triggers:amd64/noawait)
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/File",/triggers pkg-triggers:amd64/noawait)
+ $(DPKG_PURGE) pkg-triggers
+
+test-trigger-db-same-to-same: override DPKG_ADMINDIR = db-same
+test-trigger-db-same-to-same:
+ cp -a tmpl-$(DPKG_ADMINDIR) $(DPKG_ADMINDIR)
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/a-trigger",pkg-triggers:amd64)
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/File",/triggers pkg-triggers:amd64)
+ $(DPKG_INSTALL) pkg-triggers-same.deb
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/a-trigger",pkg-triggers:amd64/noawait)
+ $(call stdout_is,cat "$(DPKG_ADMINDIR)/triggers/File",/triggers pkg-triggers:amd64/noawait)
+ $(DPKG_PURGE) pkg-triggers
+
+test-clean:
+ $(DPKG_PURGE) pkg-triggers
+ $(RM) -r db-native db-foreign db-same
diff --git a/tests/t-triggers-db/pkg-triggers-foreign/DEBIAN/control b/tests/t-triggers-db/pkg-triggers-foreign/DEBIAN/control
new file mode 100644
index 0000000..a10bb5c
--- /dev/null
+++ b/tests/t-triggers-db/pkg-triggers-foreign/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-triggers
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Multi-Arch: foreign
+Architecture: other
+Description: test package - providing triggers
+
diff --git a/tests/t-triggers-db/pkg-triggers-foreign/DEBIAN/triggers b/tests/t-triggers-db/pkg-triggers-foreign/DEBIAN/triggers
new file mode 100644
index 0000000..13d2512
--- /dev/null
+++ b/tests/t-triggers-db/pkg-triggers-foreign/DEBIAN/triggers
@@ -0,0 +1,2 @@
+interest-noawait a-trigger
+interest-noawait /triggers
diff --git a/tests/t-triggers-db/pkg-triggers-native/DEBIAN/control b/tests/t-triggers-db/pkg-triggers-native/DEBIAN/control
new file mode 100644
index 0000000..ff9d5d5
--- /dev/null
+++ b/tests/t-triggers-db/pkg-triggers-native/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-db/pkg-triggers-native/DEBIAN/triggers b/tests/t-triggers-db/pkg-triggers-native/DEBIAN/triggers
new file mode 100644
index 0000000..13d2512
--- /dev/null
+++ b/tests/t-triggers-db/pkg-triggers-native/DEBIAN/triggers
@@ -0,0 +1,2 @@
+interest-noawait a-trigger
+interest-noawait /triggers
diff --git a/tests/t-triggers-db/pkg-triggers-same/DEBIAN/control b/tests/t-triggers-db/pkg-triggers-same/DEBIAN/control
new file mode 100644
index 0000000..6fbb5cf
--- /dev/null
+++ b/tests/t-triggers-db/pkg-triggers-same/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: pkg-triggers
+Version: 0.0-1
+Section: test
+Priority: extra
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Multi-Arch: same
+Architecture: amd64
+Description: test package - providing triggers
+
diff --git a/tests/t-triggers-db/pkg-triggers-same/DEBIAN/triggers b/tests/t-triggers-db/pkg-triggers-same/DEBIAN/triggers
new file mode 100644
index 0000000..13d2512
--- /dev/null
+++ b/tests/t-triggers-db/pkg-triggers-same/DEBIAN/triggers
@@ -0,0 +1,2 @@
+interest-noawait a-trigger
+interest-noawait /triggers
diff --git a/tests/t-triggers-db/tmpl-db-foreign/arch b/tests/t-triggers-db/tmpl-db-foreign/arch
new file mode 100644
index 0000000..8dfbb4b
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-foreign/arch
@@ -0,0 +1,2 @@
+amd64
+other
diff --git a/tests/t-triggers-db/tmpl-db-foreign/info/format b/tests/t-triggers-db/tmpl-db-foreign/info/format
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-foreign/info/format
@@ -0,0 +1 @@
+1
diff --git a/tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.list b/tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.list
new file mode 100644
index 0000000..90ad5c9
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.list
@@ -0,0 +1 @@
+/.
diff --git a/tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.md5sums b/tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.md5sums
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.md5sums
diff --git a/tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.triggers b/tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.triggers
new file mode 100644
index 0000000..daa582c
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-foreign/info/pkg-triggers.triggers
@@ -0,0 +1,2 @@
+interest a-trigger
+interest /triggers
diff --git a/tests/t-triggers-db/tmpl-db-foreign/status b/tests/t-triggers-db/tmpl-db-foreign/status
new file mode 100644
index 0000000..d2adcec
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-foreign/status
@@ -0,0 +1,10 @@
+Package: pkg-triggers
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: other
+Multi-Arch: foreign
+Version: 0.0-1
+Description: test package - providing triggers
+
diff --git a/tests/t-triggers-db/tmpl-db-foreign/triggers/File b/tests/t-triggers-db/tmpl-db-foreign/triggers/File
new file mode 100644
index 0000000..d3cdd00
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-foreign/triggers/File
@@ -0,0 +1 @@
+/triggers pkg-triggers:other
diff --git a/tests/t-triggers-db/tmpl-db-foreign/triggers/a-trigger b/tests/t-triggers-db/tmpl-db-foreign/triggers/a-trigger
new file mode 100644
index 0000000..fd04699
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-foreign/triggers/a-trigger
@@ -0,0 +1 @@
+pkg-triggers:other
diff --git a/tests/t-triggers-db/tmpl-db-native/arch b/tests/t-triggers-db/tmpl-db-native/arch
new file mode 100644
index 0000000..8dfbb4b
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-native/arch
@@ -0,0 +1,2 @@
+amd64
+other
diff --git a/tests/t-triggers-db/tmpl-db-native/info/format b/tests/t-triggers-db/tmpl-db-native/info/format
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-native/info/format
@@ -0,0 +1 @@
+1
diff --git a/tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.list b/tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.list
new file mode 100644
index 0000000..90ad5c9
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.list
@@ -0,0 +1 @@
+/.
diff --git a/tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.md5sums b/tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.md5sums
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.md5sums
diff --git a/tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.triggers b/tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.triggers
new file mode 100644
index 0000000..daa582c
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-native/info/pkg-triggers.triggers
@@ -0,0 +1,2 @@
+interest a-trigger
+interest /triggers
diff --git a/tests/t-triggers-db/tmpl-db-native/status b/tests/t-triggers-db/tmpl-db-native/status
new file mode 100644
index 0000000..43ea531
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-native/status
@@ -0,0 +1,10 @@
+Package: pkg-triggers
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: all
+Multi-Arch: foreign
+Version: 0.0-1
+Description: test package - providing triggers
+
diff --git a/tests/t-triggers-db/tmpl-db-native/triggers/File b/tests/t-triggers-db/tmpl-db-native/triggers/File
new file mode 100644
index 0000000..8311952
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-native/triggers/File
@@ -0,0 +1 @@
+/triggers pkg-triggers
diff --git a/tests/t-triggers-db/tmpl-db-native/triggers/a-trigger b/tests/t-triggers-db/tmpl-db-native/triggers/a-trigger
new file mode 100644
index 0000000..e61fd5f
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-native/triggers/a-trigger
@@ -0,0 +1 @@
+pkg-triggers
diff --git a/tests/t-triggers-db/tmpl-db-same/arch b/tests/t-triggers-db/tmpl-db-same/arch
new file mode 100644
index 0000000..8dfbb4b
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-same/arch
@@ -0,0 +1,2 @@
+amd64
+other
diff --git a/tests/t-triggers-db/tmpl-db-same/info/format b/tests/t-triggers-db/tmpl-db-same/info/format
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-same/info/format
@@ -0,0 +1 @@
+1
diff --git a/tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.list b/tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.list
new file mode 100644
index 0000000..90ad5c9
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.list
@@ -0,0 +1 @@
+/.
diff --git a/tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.md5sums b/tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.md5sums
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.md5sums
diff --git a/tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.triggers b/tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.triggers
new file mode 100644
index 0000000..daa582c
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-same/info/pkg-triggers:amd64.triggers
@@ -0,0 +1,2 @@
+interest a-trigger
+interest /triggers
diff --git a/tests/t-triggers-db/tmpl-db-same/status b/tests/t-triggers-db/tmpl-db-same/status
new file mode 100644
index 0000000..f8c4918
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-same/status
@@ -0,0 +1,10 @@
+Package: pkg-triggers
+Status: install ok installed
+Priority: extra
+Section: test
+Maintainer: Dpkg Developers <debian-dpkg@lists.debian.org>
+Architecture: amd64
+Multi-Arch: same
+Version: 0.0-1
+Description: test package - providing triggers
+
diff --git a/tests/t-triggers-db/tmpl-db-same/triggers/File b/tests/t-triggers-db/tmpl-db-same/triggers/File
new file mode 100644
index 0000000..567acba
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-same/triggers/File
@@ -0,0 +1 @@
+/triggers pkg-triggers:amd64
diff --git a/tests/t-triggers-db/tmpl-db-same/triggers/a-trigger b/tests/t-triggers-db/tmpl-db-same/triggers/a-trigger
new file mode 100644
index 0000000..37c2cf7
--- /dev/null
+++ b/tests/t-triggers-db/tmpl-db-same/triggers/a-trigger
@@ -0,0 +1 @@
+pkg-triggers:amd64
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..9e2ed78
--- /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
+ # TODO: 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