File: refactor-lsinitrd-introduce-cpio_list-function.patch

package info (click to toggle)
dracut 108-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,400 kB
  • sloc: sh: 25,008; ansic: 5,202; makefile: 348; perl: 186; python: 28; javascript: 19
file content (49 lines) | stat: -rw-r--r-- 1,975 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
From: Benjamin Drung <benjamin.drung@canonical.com>
Date: Wed, 6 Aug 2025 19:50:49 +0200
Subject: refactor(lsinitrd): introduce cpio_list function

In preparation to support 3cpio as alternative archive tool, move the
cpio listing call into `cpio_list`.

Forwarded: https://github.com/dracut-ng/dracut-ng/pull/1530
---
 lsinitrd.sh | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lsinitrd.sh b/lsinitrd.sh
index 0d45731..c06763a 100755
--- a/lsinitrd.sh
+++ b/lsinitrd.sh
@@ -199,6 +199,11 @@ cpio_extract_to_stdout() {
     $CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --to-stdout -- "$@" 2> /dev/null
 }
 
+# Takes optional pattern arguments
+cpio_list() {
+    $CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --list -- "$@"
+}
+
 extract_squash_img() {
     local _img _tmp
 
@@ -276,9 +281,9 @@ list_modules() {
 list_files() {
     echo "========================================================================"
     if [ "$sorted" -eq 1 ]; then
-        $CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --list | sort -n -k5
+        cpio_list | sort -n -k5
     else
-        $CAT "$image" 2> /dev/null | cpio --extract --verbose --quiet --list | sort -k9
+        cpio_list | sort -k9
     fi
     ((ret += $?))
     echo "========================================================================"
@@ -411,7 +416,7 @@ case $bin in
         CAT="cat --"
         is_early=$(cpio_extract_to_stdout early_cpio 2> /dev/null)
         # Debian mkinitramfs does not create the file 'early_cpio', so let's check if firmware files exist
-        [[ "$is_early" ]] || is_early=$(cpio --list --verbose --quiet --to-stdout -- 'kernel/*/microcode/*.bin' < "$image" 2> /dev/null)
+        [[ "$is_early" ]] || is_early=$(cpio_list 'kernel/*/microcode/*.bin' 2> /dev/null)
         if [[ "$is_early" ]]; then
             if [[ -n $unpack ]]; then
                 # should use --unpackearly for early CPIO