From 9ca4b52e0a886d77c5064570b8b8bc272c9a4b66 Mon Sep 17 00:00:00 2001 From: Antonio Alvarez Feijoo Date: Mon, 25 Mar 2024 10:37:31 +0100 Subject: [PATCH] feat(dracut): add option to disable automatic guessing of output file This patch allows forcing the input of the file path for the generated initramfs image (disabling automatic guessing of the location) using a new configuration option `force_output_file=yes`. --- dracut.sh | 7 +++++++ man/dracut.conf.5.asc | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/dracut.sh b/dracut.sh index 3b292910f3..e1b0f6c523 100755 --- a/dracut.sh +++ b/dracut.sh @@ -946,6 +946,13 @@ for f in $(dropindirs_sort ".conf" "$confdir" "$dracutbasedir/dracut.conf.d"); d [[ -e $f ]] && . "$f" done +# check if automatic guessing of the output file is disabled. +if [[ $force_output_file == "yes" && -z $outfile ]]; then + printf "%s\n" "dracut[F]: dracut is configured with force_output_file=yes" >&2 + printf "%s\n" "dracut[F]: so it is required to specify the file path of the generated initramfs image." >&2 + exit 1 +fi + # regenerate_all shouldn't be set in conf files regenerate_all=$regenerate_all_l if [[ $parallel_l == "yes" ]]; then diff --git a/man/dracut.conf.5.asc b/man/dracut.conf.5.asc index f1705ce18a..4c73221dde 100644 --- a/man/dracut.conf.5.asc +++ b/man/dracut.conf.5.asc @@ -320,6 +320,13 @@ Logging levels: If set to _yes_, try to execute tasks in parallel (currently only supported for _--regenerate-all_). +*force_output_file=*"__{yes|no}__":: + If set to _yes_, require to specify a file path for the generated initramfs + image, disabling automatic guessing of the location (default=no). + In some complex scenarios, distribution owners may want to disable the logic + for guessing the location of the output file, to prevent users from calling + dracut directly to create useless initramfs that won't be used at boot. + Files ----- _/etc/dracut.conf_::