From 0180749d82540d6105d5bf4a5180fac03b60311a Mon Sep 17 00:00:00 2001 From: Itxaka Date: Tue, 1 Oct 2024 14:45:22 +0200 Subject: [PATCH] Fail if dracut cant install required binaries (#382) --- dracut/28immucore/module-setup.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/dracut/28immucore/module-setup.sh b/dracut/28immucore/module-setup.sh index ee675a0..e7637b9 100755 --- a/dracut/28immucore/module-setup.sh +++ b/dracut/28immucore/module-setup.sh @@ -1,31 +1,43 @@ #!/bin/bash -# called by dracut +# check() is called by dracut to evaluate the inclusion of a dracut module in the initramfs. +# we always want to have this module so we return 0 check() { return 0 } -# called by dracut +# The function depends() should echo all other dracut module names the module depends on depends() { echo rootfs-block dm fs-lib lvm return 0 } -# called by dracut +# In installkernel() all kernel related files should be installed installkernel() { instmods overlay } -# called by dracut +# custom function to check if binaries exist before calling inst_multiple +inst_check_multiple() { + for bin in "$@"; do + if ! command -v "$bin" >/dev/null 2>&1; then + derror "Required binary $bin not found!" + exit 1 + fi + done + inst_multiple "$@" +} + + +# The install() function is called to install everything non-kernel related. install() { declare moddir=${moddir} declare systemdutildir=${systemdutildir} declare systemdsystemunitdir=${systemdsystemunitdir} - inst_multiple immucore - inst_multiple kairos-agent + inst_check_multiple immucore kairos-agent # add utils used by yip stages - inst_multiple partprobe sync udevadm parted mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.vfat mkfs.fat blkid lsblk e2fsck resize2fs mount umount sgdisk rsync cryptsetup growpart sfdisk gawk awk + inst_check_multiple partprobe sync udevadm parted mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.vfat mkfs.fat blkid lsblk e2fsck resize2fs mount umount sgdisk rsync cryptsetup growpart sfdisk gawk awk # Install libraries needed by gawk inst_libdir_file "libsigsegv.so*"