From dc7d8c54ed698845d24bb009ff07d64cf9acfb51 Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Tue, 12 Aug 2025 16:09:54 +0200 Subject: [PATCH] refactor(dracut): introduce cpio_extract function In preparation to support 3cpio as alternative archive tool, move the cpio extraction call into `cpio_extract`. --- dracut.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dracut.sh b/dracut.sh index 663753dde..3db80c4ed 100755 --- a/dracut.sh +++ b/dracut.sh @@ -2301,6 +2301,13 @@ for d in $(ldconfig_paths); do rmdir -p --ignore-fail-on-non-empty "$initdir/$d" > /dev/null 2>&1 done +# Takes a cpio file and optional pattern arguments +cpio_extract() { + local file="$1" + shift + cpio --extract --file "$file" --quiet -- "$@" +} + if [[ $early_microcode == yes ]]; then dinfo "*** Generating early-microcode cpio image ***" ucode_dir=(amd-ucode intel-ucode) @@ -2350,7 +2357,7 @@ if [[ $early_microcode == yes ]]; then for _ucodedir in "${early_microcode_image_dir[@]}"; do for _ucodename in "${early_microcode_image_name[@]}"; do [[ -e "$_ucodedir/$_ucodename" ]] \ - && cpio --extract --file "$_ucodedir/$_ucodename" --quiet \ + && cpio_extract "$_ucodedir/$_ucodename" \ "kernel/x86/microcode/${ucode_dest[$idx]}" if [[ -e "$_dest_dir/${ucode_dest[$idx]}" ]]; then dinfo "*** Using microcode found in '$_ucodedir/$_ucodename' ***" -- 2.47.2