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