]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-kernel-helper-autoremove
copy ReadWrite-error to the bottom to make clang happy
[apt.git] / test / integration / test-kernel-helper-autoremove
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
6setupenvironment
7configarchitecture 'amd64'
8
9# the executed script would use the installed apt-config,
10# which is outside of our control
11msgtest 'Check that the installed apt-config supports' '--no-empty'
12if /usr/bin/apt-config dump --no-empty >/dev/null 2>&1; then
13 msgpass
14else
15 msgskip
16 exit 0
17fi
18
19CURRENTKERNEL="linux-image-$(uname -r)"
20insertinstalledpackage "$CURRENTKERNEL" 'amd64' '1'
21insertinstalledpackage 'linux-image-1.0.0-2-generic' 'amd64' '1.0.0-2'
22insertinstalledpackage 'linux-image-100.0.0-1-generic' 'amd64' '100.0.0-1'
23insertinstalledpackage 'linux-image-amd64' 'amd64' '100.0.0-1'
24# ensure that the '.' is really a dot and not a wildcard
25insertinstalledpackage 'linux-headers-1000000-1-generic' 'amd64' '100.0.0-1'
26
27testsuccess aptmark auto "$CURRENTKERNEL" 'linux-image-1.0.0-2-generic' 'linux-image-100.0.0-1-generic' 'linux-headers-1000000-1-generic'
28
29# install fake-dpkg into it
30catfail() {
31 echo >&2
32 echo >&2 '### List of protected kernels:'
33 cat >&2 protected.list
34 msgfail
35}
36
37testprotected() {
38 rm -f rootdir/etc/apt/apt.conf.d/01autoremove-kernels protected.list
39
40 testsuccess runapt sh ${TESTDIR}/../../debian/apt.auto-removal.sh "$@"
41
42 msgtest 'Check kernel autoremoval protection list' 'is created'
43 test -e rootdir/etc/apt/apt.conf.d/01autoremove-kernels && msgpass || msgfail
44
45 msgtest 'Check kernel autoremoval protection list' 'can be dumped'
46 aptconfig dump --no-empty --format '%v%n' 'APT::NeverAutoRemove' >protected.list 2>&1 && msgpass || catfail
47
48 msgtest 'Check kernel autoremoval protection list' 'can be parsed'
49 grep -q '^[A-Z]: ' protected.list && catfail || msgpass
50
51 msgtest 'Check kernel autoremoval protection list includes' 'most recent kernel'
52 grep -q '^\^linux-image-100\\\.0\\\.0-1-generic\$$' protected.list && msgpass || catfail
53
54 msgtest 'Check kernel autoremoval protection list includes' 'running kernel'
55 grep -q "^\\^linux-image-$(uname -r | sed -e 's#\.#\\\\.#g')\\\$\$" protected.list && msgpass || catfail
56}
57
58testsuccessequal "Reading package lists...
59Building dependency tree...
60Reading state information...
61The following packages were automatically installed and are no longer required:
62 linux-headers-1000000-1-generic (100.0.0-1)
63 linux-image-1.0.0-2-generic (1.0.0-2)
64 linux-image-100.0.0-1-generic (100.0.0-1)
65 $CURRENTKERNEL (1)
66Use 'apt-get autoremove' to remove them.
670 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV
68testequal "Reading package lists...
69Building dependency tree...
70Reading state information...
714 packages were automatically installed and are no longer required.
72Use 'apt-get autoremove' to remove them.
730 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small
74testequal "Reading package lists...
75Building dependency tree...
76Reading state information...
77The following packages will be REMOVED:
78 linux-headers-1000000-1-generic (100.0.0-1)
79 linux-image-1.0.0-2-generic (1.0.0-2)
80 linux-image-100.0.0-1-generic (100.0.0-1)
81 $CURRENTKERNEL (1)
820 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
83Remv linux-headers-1000000-1-generic [100.0.0-1]
84Remv linux-image-1.0.0-2-generic [1.0.0-2]
85Remv linux-image-100.0.0-1-generic [100.0.0-1]
86Remv $CURRENTKERNEL [1]" aptget autoremove -sV
87
88testprotected
89msgtest 'Check kernel autoremoval protection list does not include' 'old kernel'
90grep -q '^\^linux-image-1\\\.0\\\.0-2-generic\$$' protected.list && catfail || msgpass
91
92testsuccessequal 'Reading package lists...
93Building dependency tree...
94Reading state information...
95The following packages will be REMOVED:
96 linux-headers-1000000-1-generic linux-image-1.0.0-2-generic
970 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
98Remv linux-headers-1000000-1-generic [100.0.0-1]
99Remv linux-image-1.0.0-2-generic [1.0.0-2]' aptget autoremove -s
100
101testprotected 1.0.0-2-generic
102msgtest 'Check kernel autoremoval protection list includes' 'installed kernel'
103grep -q '^\^linux-image-1\\\.0\\\.0-2-generic\$$' protected.list && msgpass || catfail
104testsuccessequal 'Reading package lists...
105Building dependency tree...
106Reading state information...
107The following packages will be REMOVED:
108 linux-headers-1000000-1-generic
1090 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
110Remv linux-headers-1000000-1-generic [100.0.0-1]' aptget autoremove -s