Revert "Use rpm -e instead of dnf for cleaning old kernels"

Using rpm -e to remove old kernels fails when other packages also
depend on the removed kernel.

This change reverts back to using dnf to remove the kernel, but also
sets the config value protect_running_kernel=False to avoid the issue
where the build host kernel version matches the version of the package
being deleted.

reverts commit 1ac31afd62.

Change-Id: Ie58630c23a34f2db34f3934abbd0c1076ab9d835
This commit is contained in:
Steve Baker 2022-02-02 09:11:14 +13:00 committed by Ian Wienand
parent 2aa151b295
commit 19ecc16d97
2 changed files with 1 additions and 9 deletions

View File

@ -18,7 +18,7 @@ if [[ ${YUM} == "dnf" ]]; then
# http://dnf.readthedocs.org/en/latest/cli_vs_yum.html # http://dnf.readthedocs.org/en/latest/cli_vs_yum.html
_old_kernels="$(dnf repoquery --installonly --latest-limit=-1 -q)" _old_kernels="$(dnf repoquery --installonly --latest-limit=-1 -q)"
if [[ -n "${_old_kernels}" ]]; then if [[ -n "${_old_kernels}" ]]; then
rpm -e ${_old_kernels} dnf remove -y --setopt=protect_running_kernel=False ${_old_kernels}
fi fi
else else
install-packages yum-utils install-packages yum-utils

View File

@ -1,8 +0,0 @@
---
fixes:
- |
Fixed an issue where cleaning old kernels on systems runing ``dnf`` would
fail in case the kernel packages being removed matches the running kernel
of the system building the image. See Bug: `1623409
<https://bugs.launchpad.net/diskimage-builder/+bug/1623409>`_.