- 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.
This commit is contained in:
Javier Martinez Canillas 2019-07-02 16:00:49 +02:00 committed by Dan Horák
parent 81aaf37c09
commit 5229fe4f01
1 changed files with 4 additions and 3 deletions

View File

@ -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"