From b8049daa454d647bb2732dbb9f6f155b01a4a05b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 12 Apr 2024 21:39:50 +0200 Subject: [PATCH] [bootloader] Factor out running "which" in target which is an actual program, drop the round-about via shell --- src/modules/bootloader/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index fe4ba2a1a..6fe01f8bc 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -125,6 +125,11 @@ def is_zfs_root(partition): return partition["mountPoint"] == "/" and partition["fs"] == "zfs" +def have_program_in_target(program : str): + """Returns @c True if @p program is in path in the target""" + return libcalamares.utils.target_env_call(["/usr/bin/which", program]) == 0 + + def get_kernel_params(uuid): kernel_params = libcalamares.job.configuration.get("kernelParams", ["quiet"]) @@ -135,8 +140,8 @@ def get_kernel_params(uuid): cryptdevice_params = [] - has_plymouth = libcalamares.utils.target_env_call(["sh", "-c", "which plymouth"]) == 0 - has_dracut = libcalamares.utils.target_env_call(["sh", "-c", "which dracut"]) == 0 + has_plymouth = have_program_in_target("plymouth") + has_dracut = have_program_in_target("dracut") uses_systemd_hook = libcalamares.utils.target_env_call(["sh", "-c", "grep -q \"^HOOKS.*systemd\" /etc/mkinitcpio.conf"]) == 0 use_systemd_naming = has_dracut or uses_systemd_hook