Blame 0031-lsinitrd.sh-do-not-output-filename-for-a-single-file.patch

Harald Hoyer adf00e
From 4460416abcb420588d189dd5bac6860c79b67ab5 Mon Sep 17 00:00:00 2001
Harald Hoyer adf00e
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer adf00e
Date: Tue, 16 Apr 2013 13:33:40 +0200
Harald Hoyer adf00e
Subject: [PATCH] lsinitrd.sh: do not output filename for a single file
Harald Hoyer adf00e
Harald Hoyer adf00e
---
Harald Hoyer adf00e
 lsinitrd.sh | 41 ++++++++++++++++++++++++++---------------
Harald Hoyer adf00e
 1 file changed, 26 insertions(+), 15 deletions(-)
Harald Hoyer adf00e
Harald Hoyer adf00e
diff --git a/lsinitrd.sh b/lsinitrd.sh
Harald Hoyer adf00e
index 0481975..cd58529 100755
Harald Hoyer adf00e
--- a/lsinitrd.sh
Harald Hoyer adf00e
+++ b/lsinitrd.sh
Harald Hoyer adf00e
@@ -119,23 +119,34 @@ case $bin in
Harald Hoyer adf00e
         ;;
Harald Hoyer adf00e
 esac
Harald Hoyer adf00e
 
Harald Hoyer adf00e
-if (( ${#filenames[@]} > 0 )); then
Harald Hoyer adf00e
-    $CAT $image | cpio --extract --verbose --quiet --to-stdout ${!filenames[@]} 2>/dev/null
Harald Hoyer adf00e
-    exit $?
Harald Hoyer adf00e
-fi
Harald Hoyer adf00e
-
Harald Hoyer adf00e
 ret=0
Harald Hoyer adf00e
 
Harald Hoyer adf00e
-echo "$image: $(du -h $image | while read a b; do echo $a;done)"
Harald Hoyer adf00e
-echo "========================================================================"
Harald Hoyer adf00e
-$CAT "$image" | cpio --extract --verbose --quiet --to-stdout '*lib/dracut/dracut-*' 2>/dev/null
Harald Hoyer adf00e
-((ret+=$?))
Harald Hoyer adf00e
-echo "========================================================================"
Harald Hoyer adf00e
-if [ "$sorted" -eq 1 ]; then
Harald Hoyer adf00e
-    $CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
Harald Hoyer adf00e
+if (( ${#filenames[@]} > 0 )); then
Harald Hoyer adf00e
+    (( ${#filenames[@]} == 1 )) && nofileinfo=1
Harald Hoyer adf00e
+    for f in ${!filenames[@]}; do
Harald Hoyer adf00e
+        [[ $nofileinfo ]] || echo "initramfs:/$f"
Harald Hoyer adf00e
+        [[ $nofileinfo ]] || echo "========================================================================"
Harald Hoyer adf00e
+        $CAT $image | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
Harald Hoyer adf00e
+        ((ret+=$?))
Harald Hoyer adf00e
+        [[ $nofileinfo ]] || echo "========================================================================"
Harald Hoyer adf00e
+        [[ $nofileinfo ]] || echo
Harald Hoyer adf00e
+    done
Harald Hoyer adf00e
 else
Harald Hoyer adf00e
-    $CAT "$image" | cpio --extract --verbose --quiet --list | sort -k9
Harald Hoyer adf00e
+    echo "Image: $image: $(du -h $image | while read a b; do echo $a;done)"
Harald Hoyer adf00e
+    echo "========================================================================"
Harald Hoyer adf00e
+    version=$($CAT "$image" | cpio --extract --verbose --quiet --to-stdout '*lib/dracut/dracut-*' 2>/dev/null)
Harald Hoyer adf00e
+    ((ret+=$?))
Harald Hoyer adf00e
+    echo "$version with dracut modules:"
Harald Hoyer adf00e
+    $CAT "$image" | cpio --extract --verbose --quiet --to-stdout 'usr/lib/dracut/modules.txt' 2>/dev/null
Harald Hoyer adf00e
+    ((ret+=$?))
Harald Hoyer adf00e
+    echo "========================================================================"
Harald Hoyer adf00e
+    if [ "$sorted" -eq 1 ]; then
Harald Hoyer adf00e
+        $CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
Harald Hoyer adf00e
+    else
Harald Hoyer adf00e
+        $CAT "$image" | cpio --extract --verbose --quiet --list | sort -k9
Harald Hoyer adf00e
+    fi
Harald Hoyer adf00e
+    ((ret+=$?))
Harald Hoyer adf00e
+    echo "========================================================================"
Harald Hoyer adf00e
 fi
Harald Hoyer adf00e
-((ret+=$?))
Harald Hoyer adf00e
-echo "========================================================================"
Harald Hoyer adf00e
+
Harald Hoyer adf00e
 exit $ret