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