diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2020-12-17 13:24:56 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2021-01-04 10:46:48 +0100 |
commit | 04085f46dea9a95dd86123ac00187a63cc4ba2c0 (patch) | |
tree | 654ce33cec489562c663ddcf77dcd8a6a2b3f428 /test/integration | |
parent | 290a4cf9455f45895718ed698147061fcd0a2dcb (diff) |
Determine autoremovable kernels at run-time
Our kernel autoremoval helper script protects the currently booted
kernel, but it only runs whenever we install or remove a kernel,
causing it to protect the kernel that was booted at that point in time,
which is not necessarily the same kernel as the one that is running
right now.
Reimplement the logic in C++ such that we can calculate it at run-time:
Provide a function to produce a regular expression that matches all
kernels that need protecting, and by changing the default root set
function in the DepCache to make use of that expression.
Note that the code groups the kernels by versions as before, and then
marks all kernel packages with the same version.
This optimized version inserts a virtual package $kernel into the cache
when building it to avoid having to iterate over all packages in the
cache to find the installed ones, significantly improving performance at
a minor cost when building the cache.
LP: #1615381
Diffstat (limited to 'test/integration')
-rwxr-xr-x | test/integration/test-kernel-helper-autoremove | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index 9cc978645..8dac44b93 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -38,9 +38,8 @@ testprotected() { testsuccess --nomsg test -e rootdir/etc/apt/apt.conf.d/01autoremove-kernels testfilestats 'rootdir/etc/apt/apt.conf.d/01autoremove-kernels' '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:444" - msgtest 'Check kernel autoremoval protection list' 'can be dumped' - testsuccess --nomsg aptconfig dump --no-empty --format '%v%n' 'APT::NeverAutoRemove' - cp rootdir/tmp/testsuccess.output protected.list + testsuccess --nomsg apt -o Debug::PkgAutoRemove=1 autoremove -s + grep "Kernel protection regex" rootdir/tmp/testsuccess.output | cut -f2- -d: | tr '|' '\n' | sed 's/\s*//g' | sort -u > protected.list msgtest 'Check kernel autoremoval protection list' 'can be parsed' testfailure --nomsg grep '^[A-Z]: ' protected.list @@ -71,7 +70,7 @@ The following packages were automatically installed and are no longer required: ${CURRENTKERNEL}-686-pae:i386 (5-1) ${CURRENTKERNEL}-dbg (5-1) Use '$AUTOREMOVE' to remove them. -0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV -o APT::Protect-Kernels=0 testsuccessequal "Reading package lists... Building dependency tree... Reading state information... @@ -85,13 +84,13 @@ The following packages were automatically installed and are no longer required: ${CURRENTKERNEL}-dbg (5-1) ${CURRENTKERNEL}-rt (5-1) Use '$AUTOREMOVE' to remove them. -0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV --ignore-hold +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -sV --ignore-hold -o APT::Protect-Kernels=0 testequal "Reading package lists... Building dependency tree... Reading state information... 7 packages were automatically installed and are no longer required. Use '$AUTOREMOVE' to remove them. -0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget install -s -o APT::Get::HideAutoRemove=small -o APT::Protect-Kernels=0 testequal "Reading package lists... Building dependency tree... Reading state information... @@ -110,7 +109,7 @@ Remv linux-image-100.0.0-1-generic [100.0.0-1] Remv $CURRENTKERNEL [5-1] Remv ${CURRENTKERNEL}+variant [5-1] Remv ${CURRENTKERNEL}-686-pae:i386 [5-1] -Remv ${CURRENTKERNEL}-dbg [5-1]" aptget autoremove -sV +Remv ${CURRENTKERNEL}-dbg [5-1]" aptget autoremove -sV -o APT::Protect-Kernels=0 msgmsg "run without parameter" testprotected @@ -168,7 +167,7 @@ Remv ${CURRENTKERNEL}-dbg [5-1]" aptget autoremove -s unset COLUMNS # rt kernel was put on hold while the protected list was generated -testsuccess aptmark unhold "${CURRENTKERNEL}-rt" +testsuccess aptmark hold "${CURRENTKERNEL}-rt" export COLUMNS=99999 testsuccessequal "Reading package lists... Building dependency tree... |