From 5229fe4f01991b1450117650a0e275c0c1f11007 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 2 Jul 2019 16:00:49 +0200 Subject: [PATCH] - fix /tmp being deleted when kernel-core is installed in a container (#1726286) The kernel-install script created unconditionally a $BOOT_DIR_ABS directory that was used by the sd-boot bootloader. The kernel-install plugins checked the existence of that directory to decide whether the BLS snippets would be created in the path expected by sd-boot or the one expected by zipl. But the $BOOT_DIR_ABS contains the machine ID that's set in the environment variable $KERNEL_INSTALL_MACHINE_ID. If there's no machine ID set, then the $BOOT_DIR_ABS is set to a temporary directory that's removed after all the kernel-install plugins exit. The $KERNEL_INSTALL_MACHINE_ID isn't set for example when kernel-install is executed in a container since there won't be an /etc/machine-id file. This causes 20-zipl-kernel.install script to wrongly remove the /tmp directory. So if $KERNEL_INSTALL_MACHINE_ID isn't set, just exit the script since the BLS snippets can't be installed anyways since their filename also contain the machine ID. Also, don't attempt to remove $BOOT_DIR_ABS because kernel-install doesn't create this directory anymore and instead is created only when sd-boot is installed. --- 20-zipl-kernel.install | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/20-zipl-kernel.install b/20-zipl-kernel.install index 794d4cd..33b7d11 100755 --- a/20-zipl-kernel.install +++ b/20-zipl-kernel.install @@ -1,5 +1,9 @@ #!/bin/bash +if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then + exit 0 +fi + [[ -f /etc/sysconfig/kernel ]] && . /etc/sysconfig/kernel COMMAND="$1" @@ -11,9 +15,6 @@ KERNEL_DIR="${KERNEL_IMAGE%/*}" MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID -# Remove it, since for zipl the images are always installed in /boot -rm -rf "${BOOT_DIR_ABS%/*}" - BLS_DIR="/boot/loader/entries" CMDLINE_LINUX_DEBUG=" systemd.log_level=debug systemd.log_target=kmsg" LINUX_DEBUG_VERSION_POSTFIX="_with_debugging"