]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
refactor(dracut): introduce cpio_extract function main
authorBenjamin Drung <benjamin.drung@canonical.com>
Tue, 12 Aug 2025 14:09:54 +0000 (16:09 +0200)
committerLaszlo <laszlo.gombos@gmail.com>
Sat, 6 Sep 2025 11:17:29 +0000 (07:17 -0400)
In preparation to support 3cpio as alternative archive tool, move the
cpio extraction call into `cpio_extract`.

dracut.sh

index 663753dded9cc237fe25814feaa7c3abd7984184..3db80c4edf39f0b9e85d2ad2104e323b5f604b3c 100755 (executable)
--- 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' ***"