]>
git.saurik.com Git - apt.git/blob - test/integration/test-kernel-helper-autoremove
4 TESTDIR
=$(readlink -f $(dirname $0))
7 configarchitecture
'amd64'
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'
12 if apt
-config dump
--no-empty >/dev
/null
2>&1; then
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'
23 # ensure that the '.' is really a dot and not a wildcard
24 insertinstalledpackage
'linux-headers-1000000-1-generic' 'amd64' '100.0.0-1'
26 testsuccess aptmark auto
"$CURRENTKERNEL" 'linux-image-1.0.0-2-generic' 'linux-image-100.0.0-1-generic' 'linux-headers-1000000-1-generic'
28 cat > .
/fake
-dpkg <<EOF
30 exec $(aptconfig dump --no-empty --format='%v ' 'DPKG::options') "\$@"
33 echo 'Dir::Bin::dpkg "./fake-dpkg";' > rootdir
/etc
/apt
/apt.conf.d
/99fakedpkg
35 # install fake-dpkg into it
38 echo >&2 '### List of protected kernels:'
39 cat >&2 protected.list
44 rm -f rootdir
/etc
/apt
/apt.conf.d
/01autoremove
-kernels protected.list
46 testsuccess runapt sh
${TESTDIR}/..
/..
/debian
/apt.auto
-removal.sh
"$@"
48 msgtest
'Check kernel autoremoval protection list' 'is created'
49 test -e rootdir
/etc
/apt
/apt.conf.d
/01autoremove
-kernels && msgpass
|| msgfail
51 msgtest
'Check kernel autoremoval protection list' 'can be dumped'
52 aptconfig dump
--no-empty --format '%v%n' 'APT::NeverAutoRemove' >protected.list
2>&1 && msgpass
|| catfail
54 msgtest
'Check kernel autoremoval protection list' 'can be parsed'
55 grep -q '^[A-Z]: ' protected.list
&& catfail
|| msgpass
57 msgtest
'Check kernel autoremoval protection list includes' 'most recent kernel'
58 grep -q '^\^linux-image-100\\\.0\\\.0-1-generic\$$' protected.list
&& msgpass
|| catfail
60 msgtest
'Check kernel autoremoval protection list includes' 'running kernel'
61 grep -q "^\\^linux-image-$(uname -r | sed -e 's#\.#\\\\.#g')\\\$\$" protected.list
&& msgpass
|| catfail
64 testequal
"Reading package lists...
65 Building dependency tree...
66 Reading state information...
67 The following packages will be REMOVED:
68 linux-headers-1000000-1-generic (100.0.0-1)
69 linux-image-1.0.0-2-generic (1.0.0-2)
70 linux-image-100.0.0-1-generic (100.0.0-1)
72 0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
73 Remv linux-headers-1000000-1-generic [100.0.0-1]
74 Remv linux-image-1.0.0-2-generic [1.0.0-2]
75 Remv linux-image-100.0.0-1-generic [100.0.0-1]
76 Remv $CURRENTKERNEL [1]" aptget autoremove
-sV
79 msgtest
'Check kernel autoremoval protection list does not include' 'old kernel'
80 grep -q '^\^linux-image-1\\\.0\\\.0-2-generic\$$' protected.list
&& catfail
|| msgpass
82 testequal
'Reading package lists...
83 Building dependency tree...
84 Reading state information...
85 The following packages will be REMOVED:
86 linux-headers-1000000-1-generic linux-image-1.0.0-2-generic
87 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
88 Remv linux-headers-1000000-1-generic [100.0.0-1]
89 Remv linux-image-1.0.0-2-generic [1.0.0-2]' aptget autoremove
-s
91 testprotected
1.0.0-2-generic
92 msgtest
'Check kernel autoremoval protection list includes' 'installed kernel'
93 grep -q '^\^linux-image-1\\\.0\\\.0-2-generic\$$' protected.list
&& msgpass
|| catfail
94 testequal
'Reading package lists...
95 Building dependency tree...
96 Reading state information...
97 The following packages will be REMOVED:
98 linux-headers-1000000-1-generic
99 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
100 Remv linux-headers-1000000-1-generic [100.0.0-1]' aptget autoremove
-s