]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
refactor(lsinitrd): introduce cpio_extract function
authorBenjamin Drung <benjamin.drung@canonical.com>
Wed, 6 Aug 2025 16:57:15 +0000 (18:57 +0200)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Mon, 11 Aug 2025 16:43:08 +0000 (09:43 -0700)
In preparation to support 3cpio as alternative archive tool, move the
cpio extraction call into `cpio_extract`.

lsinitrd.sh

index 393e892be25252c4eba78f3da13db24dcab3d8f3..d1bb67d35bc0647272c8da1e73e0b2f5906e05ff 100755 (executable)
@@ -187,6 +187,11 @@ dracutlibdirs() {
 SQUASH_TMPFILE=""
 SQUASH_EXTRACT="$TMPDIR/squash-extract"
 
+# Takes optional pattern arguments
+cpio_extract() {
+    $CAT "$image" 2> /dev/null | cpio -id --quiet $verbose -- "$@"
+}
+
 extract_squash_img() {
     local _img _tmp
 
@@ -332,13 +337,13 @@ unpack_files() {
                     cp -rf "$SQUASH_EXTRACT/$f" "$f"
                     ;;
                 *)
-                    $CAT "$image" 2> /dev/null | cpio -id --quiet $verbose "$f"
+                    cpio_extract "$f"
                     ((ret += $?))
                     ;;
             esac
         done
     else
-        $CAT "$image" 2> /dev/null | cpio -id --quiet $verbose
+        cpio_extract
         ((ret += $?))
 
         extract_squash_img || return 0