diff --git a/elements/redhat-common/README.rst b/elements/redhat-common/README.rst index 28757b00e..f099695c5 100644 --- a/elements/redhat-common/README.rst +++ b/elements/redhat-common/README.rst @@ -22,3 +22,10 @@ DIB_LOCAL_IMAGE by diskimage-builder. It should be a full disk image, not just a filesystem image. :Example: ``DIB_LOCAL_IMAGE=rhel-guest-image-7.1-20150224.0.x86_64.qcow2`` + +DIB_DISABLE_KERNEL_CLEANUP + :Required: No + :Default: 0 + :Description: Specify if kernel needs to be cleaned up or not. When set to + true, the bits that cleanup old kernels will not be executed. + :Example: DIB_DISABLE_KERNEL_CLEANUP=1 diff --git a/elements/redhat-common/environment.d/50-redhat-common b/elements/redhat-common/environment.d/50-redhat-common new file mode 100755 index 000000000..255f18555 --- /dev/null +++ b/elements/redhat-common/environment.d/50-redhat-common @@ -0,0 +1 @@ +export DIB_DISABLE_KERNEL_CLEANUP=${DIB_DISABLE_KERNEL_CLEANUP:-0} diff --git a/elements/redhat-common/finalise.d/01-clean-old-kernels b/elements/redhat-common/finalise.d/01-clean-old-kernels index 60c7b0fea..48f835bfe 100755 --- a/elements/redhat-common/finalise.d/01-clean-old-kernels +++ b/elements/redhat-common/finalise.d/01-clean-old-kernels @@ -6,6 +6,11 @@ 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