Blob Blame History Raw
From 4460416abcb420588d189dd5bac6860c79b67ab5 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Tue, 16 Apr 2013 13:33:40 +0200
Subject: [PATCH] lsinitrd.sh: do not output filename for a single file

---
 lsinitrd.sh | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/lsinitrd.sh b/lsinitrd.sh
index 0481975..cd58529 100755
--- a/lsinitrd.sh
+++ b/lsinitrd.sh
@@ -119,23 +119,34 @@ case $bin in
         ;;
 esac
 
-if (( ${#filenames[@]} > 0 )); then
-    $CAT $image | cpio --extract --verbose --quiet --to-stdout ${!filenames[@]} 2>/dev/null
-    exit $?
-fi
-
 ret=0
 
-echo "$image: $(du -h $image | while read a b; do echo $a;done)"
-echo "========================================================================"
-$CAT "$image" | cpio --extract --verbose --quiet --to-stdout '*lib/dracut/dracut-*' 2>/dev/null
-((ret+=$?))
-echo "========================================================================"
-if [ "$sorted" -eq 1 ]; then
-    $CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
+if (( ${#filenames[@]} > 0 )); then
+    (( ${#filenames[@]} == 1 )) && nofileinfo=1
+    for f in ${!filenames[@]}; do
+        [[ $nofileinfo ]] || echo "initramfs:/$f"
+        [[ $nofileinfo ]] || echo "========================================================================"
+        $CAT $image | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
+        ((ret+=$?))
+        [[ $nofileinfo ]] || echo "========================================================================"
+        [[ $nofileinfo ]] || echo
+    done
 else
-    $CAT "$image" | cpio --extract --verbose --quiet --list | sort -k9
+    echo "Image: $image: $(du -h $image | while read a b; do echo $a;done)"
+    echo "========================================================================"
+    version=$($CAT "$image" | cpio --extract --verbose --quiet --to-stdout '*lib/dracut/dracut-*' 2>/dev/null)
+    ((ret+=$?))
+    echo "$version with dracut modules:"
+    $CAT "$image" | cpio --extract --verbose --quiet --to-stdout 'usr/lib/dracut/modules.txt' 2>/dev/null
+    ((ret+=$?))
+    echo "========================================================================"
+    if [ "$sorted" -eq 1 ]; then
+        $CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
+    else
+        $CAT "$image" | cpio --extract --verbose --quiet --list | sort -k9
+    fi
+    ((ret+=$?))
+    echo "========================================================================"
 fi
-((ret+=$?))
-echo "========================================================================"
+
 exit $ret