1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
From: Benjamin Drung <benjamin.drung@canonical.com>
Date: Wed, 6 Aug 2025 18:57:15 +0200
Subject: refactor(lsinitrd): introduce cpio_extract function
In preparation to support 3cpio as alternative archive tool, move the
cpio extraction call into `cpio_extract`.
Forwarded: https://github.com/dracut-ng/dracut-ng/pull/1530
---
lsinitrd.sh | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lsinitrd.sh b/lsinitrd.sh
index 2de972a..e6b9120 100755
--- a/lsinitrd.sh
+++ b/lsinitrd.sh
@@ -189,6 +189,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
@@ -334,13 +339,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
|