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