Debian Codegraph @

debian/tests/1065494-futureproofing

raw symbols SCIP
1 #!/bin/sh
2 # Copyright 2024 Simon McVittie
3 # SPDX-License-Identifier: LGPL-2.1-or-later
4
5 # Ensure that if the content of libgtk-3-0t64 is taken over by some
6 # other package libgtk-3-0xyz, then that other package will not trigger
7 # a bug equivalent to #1065494.
8
9 set -eux
10
11 # Machine-readable TAP on fd 3, human-readable diagnostics on fds 1 and 2
12 exec 3>&1 >&2
13
14 export DEBIAN_FRONTEND=noninteractive
15 n=0
16 failed=0
17 binary_package="libgtk-3-0t64"
18 future_binary_package="libgtk-3-0xyz"
19 srcdir="$(pwd)"
20 tmpdir="$(mktemp -d)"
21 cd "$tmpdir"
22
23 assert () {
24 n=$(( n + 1 ))
25
26 if "$@"; then
27 echo "ok $n - $*" >&3
28 else
29 echo "not ok $n - $* exit status $?" >&3
30 failed=1
31 fi
32 }
33
34 assert_not () {
35 n=$(( n + 1 ))
36
37 if ! "$@"; then
38 echo "ok $n - unsuccessful as expected: $*" >&3
39 else
40 echo "not ok $n - should not have succeeded: $*" >&3
41 failed=1
42 fi
43 }
44
45 # Add a deb822-formatted apt source at this location if you are testing a
46 # locally-built gtk+3.0 before upload
47 if [ -e "$srcdir/debian/tests/manual/local-1065494.sources" ]; then
48 install -m644 -t /etc/apt/sources.list.d/ -D \
49 "$srcdir/debian/tests/manual/local-1065494.sources"
50 fi
51
52 # For more convenient manual testing
53 if ! dpkg-query -W dpkg-repack; then
54 apt-get -y update
55 apt-get -y install "$binary_package"
56 apt-get -y install dpkg-dev dpkg-repack
57 fi
58
59 this_tuple="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
60
61 # This assumes that libgtk-3-0t64 has at least one each of Breaks, Provides
62 # and Replaces, and will need to be adjusted if that assumption is broken in
63 # the future for whatever reason.
64 dpkg-query -s "$binary_package"
65 # The $ substitution is to be expanded by dpkg-query:
66 # shellcheck disable=SC2016
67 binary_version="$(dpkg-query -W -f '${Version}' "$binary_package")"
68 dpkg-repack --generate "$binary_package"
69 grep -q '^Breaks:' dpkg-repack.*/DEBIAN/control
70 grep -q '^Provides:' dpkg-repack.*/DEBIAN/control
71 grep -q '^Replaces:' dpkg-repack.*/DEBIAN/control
72 # The $ substitutions in the Perl expressions are to be expanded by Perl,
73 # not by the shell, so:
74 # shellcheck disable=SC2016
75 env \
76 binary_package="$binary_package" \
77 binary_version="$binary_version" \
78 future_binary_package="$future_binary_package" \
79 perl -p -i \
80 -e 's/^Package:.*$/Package: $ENV{future_binary_package}/;' \
81 -e 's/^(Breaks:.*)$/$1, $ENV{binary_package}/;' \
82 -e 's/^(Provides:.*)$/$1, $ENV{binary_package} (= $ENV{binary_version})/;' \
83 -e 's/^(Replaces:.*)$/$1, $ENV{binary_package}/;' \
84 dpkg-repack.*/DEBIAN/control
85 dpkg-deb --build dpkg-repack.* "$future_binary_package.deb"
86 dpkg-deb --info "$future_binary_package.deb"
87 dpkg-deb --contents "$future_binary_package.deb"
88 apt-get -y install ./"$future_binary_package.deb"
89
90 assert test -e "/usr/lib/$this_tuple/gtk-3.0/3.0.0/immodules.cache"
91 assert test -s "/usr/lib/$this_tuple/gtk-3.0/3.0.0/immodules.cache"
92
93 # Purging the "old" (pre-transition) binary package does not destroy the
94 # IM modules cache
95 apt-get -y purge "$binary_package"
96
97 assert test -e "/usr/lib/$this_tuple/gtk-3.0/3.0.0/immodules.cache"
98 assert test -s "/usr/lib/$this_tuple/gtk-3.0/3.0.0/immodules.cache"
99
100 # Purging the "new" (post-transition) binary package still *does* destroy the
101 # IM modules cache
102 apt-get -y purge "$future_binary_package"
103
104 assert_not test -e "/usr/lib/$this_tuple/gtk-3.0/3.0.0/immodules.cache"
105 assert_not test -s "/usr/lib/$this_tuple/gtk-3.0/3.0.0/immodules.cache"
106
107 echo "1..$n" >&3
108 exit "$failed"
109
110 # vim:set sw=4 sts=4 et: