]> git.saurik.com Git - apt.git/blame - test/integration/test-kernel-helper-autoremove
tests: try to support spaces in TMPDIR
[apt.git] / test / integration / test-kernel-helper-autoremove
CommitLineData
e5bdcc87 1#!/bin/sh
e5bdcc87
MV
2set -e
3
e5bdcc87
MV
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
b9b0f622 6setupenvironment
33677a0c 7configarchitecture 'amd64'
e5bdcc87 8
33677a0c 9CURRENTKERNEL="linux-image-$(uname -r)"
3196dae8
DK
10insertinstalledpackage "$CURRENTKERNEL" 'amd64' '5-1'
11# debug packages do not need our protection
12insertinstalledpackage "${CURRENTKERNEL}-dbg" 'amd64' '5-1'
13# but other kernel flavours should be protected
14insertinstalledpackage "${CURRENTKERNEL}-686-pae" 'i386' '5-1'
15insertinstalledpackage "${CURRENTKERNEL}-rt" 'amd64' '5-1'
16# some more versions
33677a0c
DK
17insertinstalledpackage 'linux-image-1.0.0-2-generic' 'amd64' '1.0.0-2'
18insertinstalledpackage 'linux-image-100.0.0-1-generic' 'amd64' '100.0.0-1'
3196dae8
DK
19# kernel metapackages should be ignored
20insertinstalledpackage 'linux-image-amd64' 'amd64' '200-1'
21insertinstalledpackage 'linux-image-686-pae' 'i386' '300-1'
7ce1ac85
DK
22# ensure that the '.' is really a dot and not a wildcard
23insertinstalledpackage 'linux-headers-1000000-1-generic' 'amd64' '100.0.0-1'
33677a0c 24
3196dae8
DK
25testsuccess aptmark auto "$CURRENTKERNEL" "${CURRENTKERNEL}-dbg" "${CURRENTKERNEL}-686-pae:i386" "${CURRENTKERNEL}-rt" \
26 'linux-image-1.0.0-2-generic' 'linux-image-100.0.0-1-generic' 'linux-headers-1000000-1-generic'
27testsuccess aptmark hold "${CURRENTKERNEL}-rt"
e5bdcc87 28
b9b0f622
DK
29testprotected() {
30 rm -f rootdir/etc/apt/apt.conf.d/01autoremove-kernels protected.list
e5bdcc87 31
63c71412 32 testsuccess runapt sh "${TESTDIR}/../../debian/apt.auto-removal.sh" "$@"
3196dae8 33 testfailure test -s rootdir/tmp/testsuccess.output
c6918c16 34
b9b0f622 35 msgtest 'Check kernel autoremoval protection list' 'is created'
3196dae8
DK
36 testsuccess --nomsg test -e rootdir/etc/apt/apt.conf.d/01autoremove-kernels
37 testfilestats 'rootdir/etc/apt/apt.conf.d/01autoremove-kernels' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:444"
c6918c16 38
b9b0f622 39 msgtest 'Check kernel autoremoval protection list' 'can be dumped'
3196dae8
DK
40 testsuccess --nomsg aptconfig dump --no-empty --format '%v%n' 'APT::NeverAutoRemove'
41 cp rootdir/tmp/testsuccess.output protected.list
e5bdcc87 42
b9b0f622 43 msgtest 'Check kernel autoremoval protection list' 'can be parsed'
3196dae8 44 testfailure --nomsg grep '^[A-Z]: ' protected.list
d269b88d 45
b9b0f622 46 msgtest 'Check kernel autoremoval protection list includes' 'most recent kernel'
3196dae8 47 testsuccess --nomsg grep '^\^linux-image-100\\\.0\\\.0-1-generic\$$' protected.list
b9b0f622
DK
48
49 msgtest 'Check kernel autoremoval protection list includes' 'running kernel'
3196dae8
DK
50 testsuccess --nomsg grep "^\\^linux-image-$(uname -r | sed -e 's#\.#\\\\.#g')\\\$\$" protected.list
51
52 msgtest 'Check kernel autoremoval protection list does not include' 'metapackages'
53 testfailure --nomsg grep -e '^\^linux-image-amd64\$$' -e '^\^linux-image-686-pae\$$' -e ':i386' protected.list
b9b0f622
DK
54}
55
25b86db1 56testsuccessequal "Reading package lists...
33677a0c
DK
57Building dependency tree...
58Reading state information...
a0c19a21
DK
59The following packages were automatically installed and are no longer required:
60 linux-headers-1000000-1-generic (100.0.0-1)
61 linux-image-1.0.0-2-generic (1.0.0-2)
62 linux-image-100.0.0-1-generic (100.0.0-1)
3196dae8
DK
63 $CURRENTKERNEL (5-1)
64 ${CURRENTKERNEL}-686-pae:i386 (5-1)
65 ${CURRENTKERNEL}-dbg (5-1)
a0c19a21
DK
66Use 'apt-get autoremove' to remove them.
670 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV
3196dae8
DK
68testsuccessequal "Reading package lists...
69Building dependency tree...
70Reading state information...
71The following packages were automatically installed and are no longer required:
72 linux-headers-1000000-1-generic (100.0.0-1)
73 linux-image-1.0.0-2-generic (1.0.0-2)
74 linux-image-100.0.0-1-generic (100.0.0-1)
75 $CURRENTKERNEL (5-1)
76 ${CURRENTKERNEL}-686-pae:i386 (5-1)
77 ${CURRENTKERNEL}-dbg (5-1)
78 ${CURRENTKERNEL}-rt (5-1)
79Use 'apt-get autoremove' to remove them.
800 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV --ignore-hold
a0c19a21
DK
81testequal "Reading package lists...
82Building dependency tree...
83Reading state information...
3196dae8 846 packages were automatically installed and are no longer required.
a0c19a21
DK
85Use 'apt-get autoremove' to remove them.
860 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small
87testequal "Reading package lists...
88Building dependency tree...
89Reading state information...
33677a0c 90The following packages will be REMOVED:
7ce1ac85 91 linux-headers-1000000-1-generic (100.0.0-1)
33677a0c
DK
92 linux-image-1.0.0-2-generic (1.0.0-2)
93 linux-image-100.0.0-1-generic (100.0.0-1)
3196dae8
DK
94 $CURRENTKERNEL (5-1)
95 ${CURRENTKERNEL}-686-pae:i386 (5-1)
96 ${CURRENTKERNEL}-dbg (5-1)
970 upgraded, 0 newly installed, 6 to remove and 0 not upgraded.
7ce1ac85 98Remv linux-headers-1000000-1-generic [100.0.0-1]
33677a0c
DK
99Remv linux-image-1.0.0-2-generic [1.0.0-2]
100Remv linux-image-100.0.0-1-generic [100.0.0-1]
3196dae8
DK
101Remv $CURRENTKERNEL [5-1]
102Remv ${CURRENTKERNEL}-686-pae:i386 [5-1]
103Remv ${CURRENTKERNEL}-dbg [5-1]" aptget autoremove -sV
33677a0c 104
3196dae8 105msgmsg "run without parameter"
b9b0f622
DK
106testprotected
107msgtest 'Check kernel autoremoval protection list does not include' 'old kernel'
3196dae8
DK
108testfailure --nomsg grep '^\^linux-image-1\\\.0\\\.0-2-generic\$$' protected.list
109testsuccessequal "Reading package lists...
110Building dependency tree...
111Reading state information...
112The following packages will be REMOVED:
113 linux-headers-1000000-1-generic linux-image-1.0.0-2-generic
114 ${CURRENTKERNEL}-dbg
1150 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
116Remv linux-headers-1000000-1-generic [100.0.0-1]
117Remv linux-image-1.0.0-2-generic [1.0.0-2]
118Remv ${CURRENTKERNEL}-dbg [5-1]" aptget autoremove -s
d269b88d 119
3196dae8
DK
120msgmsg "install unknown kernel"
121# even if installed/uname reports a kernel which we can't find via dpkg,
122# ensure that we still protect it just in case as these are kernels we
123# know for sure without complicated detection mechanisms
124testprotected 1.0.0-2-ungeneric
125msgtest 'Check kernel autoremoval protection list does not include' 'old kernel'
126testfailure --nomsg grep '^\^linux-image-1\\\.0\\\.0-2-generic\$$' protected.list
127msgtest 'Check kernel autoremoval protection list does include' 'unknown installed kernel'
128testsuccess --nomsg grep '^\^linux-image-1\\\.0\\\.0-2-ungeneric\$$' protected.list
129testsuccessequal "Reading package lists...
33677a0c
DK
130Building dependency tree...
131Reading state information...
132The following packages will be REMOVED:
7ce1ac85 133 linux-headers-1000000-1-generic linux-image-1.0.0-2-generic
3196dae8
DK
134 ${CURRENTKERNEL}-dbg
1350 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
7ce1ac85 136Remv linux-headers-1000000-1-generic [100.0.0-1]
3196dae8
DK
137Remv linux-image-1.0.0-2-generic [1.0.0-2]
138Remv ${CURRENTKERNEL}-dbg [5-1]" aptget autoremove -s
33677a0c 139
3196dae8 140msgmsg "install an old kernel"
b9b0f622
DK
141testprotected 1.0.0-2-generic
142msgtest 'Check kernel autoremoval protection list includes' 'installed kernel'
3196dae8
DK
143testsuccess --nomsg grep '^\^linux-image-1\\\.0\\\.0-2-generic\$$' protected.list
144testsuccessequal "Reading package lists...
145Building dependency tree...
146Reading state information...
147The following packages will be REMOVED:
148 linux-headers-1000000-1-generic ${CURRENTKERNEL}-dbg
1490 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
150Remv linux-headers-1000000-1-generic [100.0.0-1]
151Remv ${CURRENTKERNEL}-dbg [5-1]" aptget autoremove -s
152
153# rt kernel was put on hold while the protected list was generated
154testsuccess aptmark unhold "${CURRENTKERNEL}-rt"
155testsuccessequal "Reading package lists...
33677a0c
DK
156Building dependency tree...
157Reading state information...
7ce1ac85 158The following packages will be REMOVED:
3196dae8
DK
159 linux-headers-1000000-1-generic ${CURRENTKERNEL}-dbg
1600 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
161Remv linux-headers-1000000-1-generic [100.0.0-1]
162Remv ${CURRENTKERNEL}-dbg [5-1]" aptget autoremove -s