diskimage-builder/elements/redhat-common/finalise.d/01-clean-old-kernels

22 lines
461 B
Text
Raw Normal View History

#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
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 ${_old_kernels}
fi
else
install-packages yum-utils
package-cleanup --oldkernels -y --count=1
fi