From 1ac31afd6297c2a9a0673b0cde17e18230c3b977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Jens=C3=A5s?= Date: Thu, 19 Mar 2020 22:27:51 +0100 Subject: [PATCH] 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 --- .../redhat-common/finalise.d/01-clean-old-kernels | 2 +- ...-to-erase-in-case-running-kernel-0401f78d63daca77.yaml | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-dnf-clean-old-kernels-use-rpm-to-erase-in-case-running-kernel-0401f78d63daca77.yaml diff --git a/diskimage_builder/elements/redhat-common/finalise.d/01-clean-old-kernels b/diskimage_builder/elements/redhat-common/finalise.d/01-clean-old-kernels index 5d8393f2..23d8619e 100755 --- a/diskimage_builder/elements/redhat-common/finalise.d/01-clean-old-kernels +++ b/diskimage_builder/elements/redhat-common/finalise.d/01-clean-old-kernels @@ -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 diff --git a/releasenotes/notes/fix-dnf-clean-old-kernels-use-rpm-to-erase-in-case-running-kernel-0401f78d63daca77.yaml b/releasenotes/notes/fix-dnf-clean-old-kernels-use-rpm-to-erase-in-case-running-kernel-0401f78d63daca77.yaml new file mode 100644 index 00000000..970eeadf --- /dev/null +++ b/releasenotes/notes/fix-dnf-clean-old-kernels-use-rpm-to-erase-in-case-running-kernel-0401f78d63daca77.yaml @@ -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 + `_. +