lsinitrd.sh: do not output filename for a single file
authorHarald Hoyer <harald@redhat.com>
Tue, 16 Apr 2013 11:33:40 +0000 (13:33 +0200)
committerHarald Hoyer <harald@redhat.com>
Tue, 16 Apr 2013 11:36:04 +0000 (13:36 +0200)
lsinitrd.sh

index 0481975..cd58529 100755 (executable)
@@ -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