19ecc16d97
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
27 lines
610 B
Bash
Executable File
27 lines
610 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
if [ $DIB_DISABLE_KERNEL_CLEANUP -ne 0 ]; then
|
|
echo "Skipping kernel cleanup as configured"
|
|
exit 0
|
|
fi
|
|
|
|
YUM=${YUM:-yum}
|
|
|
|
if [[ ${YUM} == "dnf" ]]; then
|
|
# cribbed from
|
|
# 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 --setopt=protect_running_kernel=False ${_old_kernels}
|
|
fi
|
|
else
|
|
install-packages yum-utils
|
|
package-cleanup --oldkernels -y --count=1
|
|
fi
|