Blame SOURCES/0207-lsinird-Adding-option-m-mod-to-list-dracut-modules-i.patch

18971c
From 564c0c4577dfd676472f4a41798909470fee6744 Mon Sep 17 00:00:00 2001
18971c
From: Hari Bathini <hbathini@linux.vnet.ibm.com>
18971c
Date: Mon, 2 Jun 2014 16:27:37 +0530
18971c
Subject: [PATCH] lsinird: Adding option "-m|--mod" to list dracut modules in
18971c
 the image
18971c
18971c
This patch adds option "-m|--mod" to lsinitrd to list dracut
18971c
modules in the image  because sometimes  having an option to
18971c
only list the dracut modules in the image could be handy.
18971c
18971c
Sample output:
18971c
--------------
18971c
18971c
[hbathini@localhost dracut]$ sudo ./lsinitrd.sh initramfs-3.11.10-100.fc18.x86_64.img -m
18971c
Image: initramfs-3.11.10-100.fc18.x86_64.img: 33M
18971c
========================================================================
18971c
Version: dracut-029-1.fc18.2
18971c
18971c
dracut modules:
18971c
i18n
18971c
network
18971c
ifcfg
18971c
drm
18971c
plymouth
18971c
btrfs
18971c
crypt
18971c
dm
18971c
dmraid
18971c
kernel-modules
18971c
lvm
18971c
mdraid
18971c
cifs
18971c
iscsi
18971c
nfs
18971c
resume
18971c
rootfs-block
18971c
terminfo
18971c
udev-rules
18971c
biosdevname
18971c
systemd
18971c
usrmount
18971c
base
18971c
fs-lib
18971c
shutdown
18971c
========================================================================
18971c
18971c
Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
18971c
(cherry picked from commit 05d2a14526042417a4a2b1b3d003738b51ab3df7)
18971c
---
18971c
 lsinitrd.sh | 29 ++++++++++++++++++++++++-----
18971c
 1 file changed, 24 insertions(+), 5 deletions(-)
18971c
18971c
diff --git a/lsinitrd.sh b/lsinitrd.sh
18971c
index b36b34e2..b086a635 100755
18971c
--- a/lsinitrd.sh
18971c
+++ b/lsinitrd.sh
18971c
@@ -27,6 +27,7 @@ usage()
18971c
         echo
18971c
         echo "-h, --help                  print a help message and exit."
18971c
         echo "-s, --size                  sort the contents of the initramfs by size."
18971c
+        echo "-m, --mod                   list modules."
18971c
         echo "-f, --file <filename>       print the contents of <filename>."
18971c
         echo "-k, --kver <kernel version> inspect the initramfs of <kernel version>."
18971c
         echo
18971c
@@ -37,13 +38,15 @@ usage()
18971c
 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
18971c
 
18971c
 sorted=0
18971c
+modules=0
18971c
 declare -A filenames
18971c
 
18971c
 unset POSIXLY_CORRECT
18971c
 TEMP=$(getopt \
18971c
-    -o "shf:k:" \
18971c
+    -o "shmf:k:" \
18971c
     --long kver: \
18971c
     --long file: \
18971c
+    --long mod \
18971c
     --long help \
18971c
     --long size \
18971c
     -- "$@")
18971c
@@ -61,6 +64,7 @@ while (($# > 0)); do
18971c
         -f|--file)  filenames[${2#/}]=1; shift;;
18971c
         -s|--size)  sorted=1;;
18971c
         -h|--help)  usage; exit 0;;
18971c
+        -m|--mod)   modules=1;;
18971c
         --)         shift;break;;
18971c
         *)          usage; exit 1;;
18971c
     esac
18971c
@@ -119,6 +123,13 @@ extract_files()
18971c
     done
18971c
 }
18971c
 
18971c
+list_modules()
18971c
+{
18971c
+    echo "dracut modules:"
18971c
+    $CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/modules.txt' 'usr/lib/dracut/modules.txt' 2>/dev/null
18971c
+    ((ret+=$?))
18971c
+}
18971c
+
18971c
 list_files()
18971c
 {
18971c
     echo "========================================================================"
18971c
@@ -211,10 +222,18 @@ if (( ${#filenames[@]} > 0 )); then
18971c
 else
18971c
     version=$($CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/dracut-*' 'usr/lib/dracut/dracut-*' 2>/dev/null)
18971c
     ((ret+=$?))
18971c
-    echo "$version with dracut modules:"
18971c
-    $CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- '*lib/dracut/modules.txt' 2>/dev/null
18971c
-    ((ret+=$?))
18971c
-    list_files
18971c
+    echo "Version: $version"
18971c
+    echo
18971c
+    if [ "$modules" -eq 1 ]; then
18971c
+        list_modules
18971c
+        echo "========================================================================"
18971c
+    else
18971c
+        echo -n "Arguments: "
18971c
+        $CAT "$image" | cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/build-parameter.txt' 'usr/lib/dracut/build-parameter.txt' 2>/dev/null
18971c
+        echo
18971c
+        list_modules
18971c
+        list_files
18971c
+    fi
18971c
 fi
18971c
 
18971c
 exit $ret