From c1bac651cb33dd3e9163592e4cee980d52d5de47 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Mota Date: Thu, 11 Aug 2016 13:29:29 +0200 Subject: [PATCH] Allow to skip kernel cleanup For some use cases, it can be useful to keep all the kernels and not just keep the latest one. Add a parameter that allows it, and continue cleaning up kernels by default. Change-Id: Ia6e6c1fa18e3724c1eb89226151d81e9e748b793 --- elements/redhat-common/README.rst | 7 +++++++ elements/redhat-common/environment.d/50-redhat-common | 1 + elements/redhat-common/finalise.d/01-clean-old-kernels | 5 +++++ 3 files changed, 13 insertions(+) create mode 100755 elements/redhat-common/environment.d/50-redhat-common diff --git a/elements/redhat-common/README.rst b/elements/redhat-common/README.rst index 28757b00..f099695c 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 00000000..255f1855 --- /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 60c7b0fe..48f835bf 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