Use rpm -e instead of dnf for cleaning old kernels

If the running kernel of the system building the image
matches the kernel that is to be removed dnf will fail.

Repalce use use of dnf with rpm -e.

Closes-Bug: #1623409
Change-Id: Ie2481ea8a02b7b0720e46fa179f24badf4aa25c5
This commit is contained in:
Harald Jensås 2020-03-19 22:27:51 +01:00
parent c113703050
commit 1ac31afd62
2 changed files with 9 additions and 1 deletions

View File

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

View File

@ -0,0 +1,8 @@
---
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>`_.