From: Benjamin Drung Date: Fri, 23 Jan 2026 21:59:26 +0000 (+0100) Subject: feat: warn in case 3cpio is present but not suitable X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbd9f0ee2c624e592a74b60080977b01307655c5;p=thirdparty%2Fdracut-ng.git feat: warn in case 3cpio is present but not suitable In case the 3cpio call fails, dracut will silently fall back to cpio. This makes debugging harder. So print a warning in case calling 3cpio fails. Print an info in case 3cpio does not support `--create`. See also https://bugs.debian.org/1126301 --- diff --git a/dracut.sh b/dracut.sh index 1f1de4df9..99ac4543d 100755 --- a/dracut.sh +++ b/dracut.sh @@ -2076,8 +2076,19 @@ elif [[ -n $persistent_policy && ! -d "/dev/disk/${persistent_policy}" ]]; then fi CPIO=cpio -if 3cpio --help 2> /dev/null | grep -q -- --create; then - CPIO=3cpio +if command -v 3cpio > /dev/null; then + if help_output=$(3cpio --help); then + if echo "$help_output" | grep -q -- --create; then + CPIO=3cpio + else + dinfo "3cpio does not support --create. Falling back to cpio." + fi + elif command -v cpio > /dev/null; then + dwarning "Calling '3cpio --help' failed. Cannot check if 3cpio supports --create. Falling back to cpio." + else + dwarning "Calling '3cpio --help' failed. Cannot check if 3cpio supports --create." + CPIO=3cpio + fi fi if [[ $enhanced_cpio == "yes" ]]; then diff --git a/lsinitrd.sh b/lsinitrd.sh index 7162e6d29..32ee28dd4 100755 --- a/lsinitrd.sh +++ b/lsinitrd.sh @@ -97,8 +97,17 @@ while (($# > 0)); do done CPIO=cpio -if 3cpio --help 2> /dev/null | grep -q -- --make-directories; then - CPIO=3cpio +if command -v 3cpio > /dev/null; then + if help_output=$(3cpio --help); then + if echo "$help_output" | grep -q -- --make-directories; then + CPIO=3cpio + fi + elif command -v cpio > /dev/null; then + echo "Warning: Calling '3cpio --help' failed. Cannot check if 3cpio supports --make-directories. Falling back to cpio." + else + echo "Warning: Calling '3cpio --help' failed. Cannot check if 3cpio supports --make-directories." + CPIO=3cpio + fi fi if ! [[ $KERNEL_VERSION ]]; then