diff options
Diffstat (limited to 't/recipes/checks/scripts/scripts-diversions/build-spec')
10 files changed, 114 insertions, 0 deletions
diff --git a/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/install b/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/install new file mode 100644 index 0000000..bf6447b --- /dev/null +++ b/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/install @@ -0,0 +1,5 @@ +orphan usr/share/scripts +some-file usr/share/scripts +file.1 usr/share/scripts +foo usr/bin +foo.1p usr/share/man/man1 diff --git a/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/postinst b/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/postinst new file mode 100644 index 0000000..f397e7d --- /dev/null +++ b/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/postinst @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# This isn't a diversion we create anywhere, but we're allowed to do this in +# postinst in case we're cleaning up after a previous version. +if [ configure = "$1" ] && dpkg-divert --list '*old-file' >/dev/null ; then + dpkg-divert --package scripts-diversions --remove --rename \ + /usr/share/scripts/old-file +fi + +#DEBHELPER# diff --git a/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/postrm b/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/postrm new file mode 100644 index 0000000..26128e9 --- /dev/null +++ b/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/postrm @@ -0,0 +1,34 @@ +#!/bin/sh +set -e + +if [ remove = "$1" ]; then + # Clean up the correct diversion from preinst. + dpkg-divert --package scripts-diversions --remove --rename \ + --divert /usr/share/scripts/some-file.real \ + /usr/share/scripts/some-file + + # Clean up some other diversion that we didn't create. + dpkg-divert --package scripts-diversions --remove --rename \ + /usr/share/scripts/old-file + + # Clean up a diversion we did create for a non-existent file. + dpkg-divert --remove --package scripts-diversions --rename \ + --divert /usr/share/scripts/no-such-file.real \ + /usr/share/scripts/no-such-file + + # Regression test for diversions ending in numbers (Bug#534942) + dpkg-divert --remove --package scripts-diversions \ + --divert /usr/share/scripts/file.1.real \ + /usr/share/scripts/file.1 > /dev/null + + # Clean up the diversion for a binary man page. + dpkg-divert --remove --package scripts-diversions \ + --divert /usr/share/man/man1/foo.real.1.gz \ + /usr/share/man/man1/foo.1.gz + + # Clean up a local diversion. + dpkg-divert --local --remove --divert /usr/share/scripts/other-file.real \ + /usr/share/scripts/other-file +fi + +#DEBHELPER# diff --git a/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/preinst b/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/preinst new file mode 100644 index 0000000..b590f9d --- /dev/null +++ b/t/recipes/checks/scripts/scripts-diversions/build-spec/debian/preinst @@ -0,0 +1,53 @@ +#!/bin/sh +set -e + +if [ install = "$1" ]; then + # This is a correct diversion. + dpkg-divert --package scripts-diversions --add --rename \ + --divert /usr/share/scripts/some-file.real \ + /usr/share/scripts/some-file + + # This is broken -- can't use local. + dpkg-divert --local --add --divert /usr/share/scripts/other-file.real \ + /usr/share/scripts/other-file + + # This was broken until dpkg 1.16.0 (Wheezy), see #679132 + dpkg-divert --add --divert /usr/share/scripts/another-file.real \ + /usr/share/scripts/another-file + + # This is also correct, but we're not going to clean it up. While we're + # at it, make sure we strip trailing redirections. + dpkg-divert --package scripts-diversions --add --rename \ + --divert /usr/share/scripts/orphan.real \ + /usr/share/scripts/orphan > /dev/null + + # The same one again, but with a different redirection. + dpkg-divert --package scripts-diversions --add --rename \ + --divert /usr/share/scripts/orphan.real \ + /usr/share/scripts/orphan 2> /dev/null + + # This is broken because the file doesn't exist. + dpkg-divert --add --package scripts-diversions --rename \ + --divert /usr/share/scripts/no-such-file.real \ + /usr/share/scripts/no-such-file + + # Regression test for diversions ending in numbers (Bug#534942) + dpkg-divert --add --rename --package scripts-diversions \ + --divert /usr/share/scripts/file.1.real \ + /usr/share/scripts/file.1 > /dev/null + + # We're allowed to divert a man page to install another man page in a + # different section but the same numeric section. (Bug#543781) + dpkg-divert --add --rename --package scripts-diversions \ + --divert /usr/share/man/man1/foo.real.1.gz \ + /usr/share/man/man1/foo.1.gz +fi + +# This isn't a diversion we create anywhere, but we're allowed to do this in +# preinst in case we're cleaning up after a previous version. +if [ upgrade = "$1" ] && dpkg-divert --list '*old-file' >/dev/null ; then + dpkg-divert --package scripts-diversions --remove --rename \ + /usr/share/scripts/old-file +fi + +#DEBHELPER# diff --git a/t/recipes/checks/scripts/scripts-diversions/build-spec/fill-values b/t/recipes/checks/scripts/scripts-diversions/build-spec/fill-values new file mode 100644 index 0000000..df30405 --- /dev/null +++ b/t/recipes/checks/scripts/scripts-diversions/build-spec/fill-values @@ -0,0 +1,3 @@ +Skeleton: upload-native +Testname: scripts-diversions +Description: Tests of dpkg-divert checks diff --git a/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/file.1 b/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/file.1 new file mode 100644 index 0000000..a58ae6c --- /dev/null +++ b/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/file.1 @@ -0,0 +1 @@ +Some file ending in a number. diff --git a/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/foo b/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/foo new file mode 100755 index 0000000..adff45d --- /dev/null +++ b/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/foo @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'Fake foo binary' diff --git a/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/foo.1p b/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/foo.1p new file mode 100644 index 0000000..c3088fd --- /dev/null +++ b/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/foo.1p @@ -0,0 +1,3 @@ +.TH foo 1p +.SH NAME +foo \- a fake man page for a foo diff --git a/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/orphan b/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/orphan new file mode 100644 index 0000000..934fd74 --- /dev/null +++ b/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/orphan @@ -0,0 +1 @@ +Some file that we're going to divert and not clean up. diff --git a/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/some-file b/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/some-file new file mode 100644 index 0000000..649e369 --- /dev/null +++ b/t/recipes/checks/scripts/scripts-diversions/build-spec/orig/some-file @@ -0,0 +1 @@ +Some random file that we're going to install after diverting. |