We don't necessarily have to always rebuild the initramfs when
extra_modules is set, instead just detect if any module is updated
and only rebuild initramfs if found any updated kernel module.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdumpctl | 38 +++++++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 3f80ba4..f2e2b76 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -486,6 +486,34 @@ check_wdt_modified()
return 1
}
+# Check if any extra kernel is changed
+check_kmodules_modified()
+{
+ local _extra_modules="$(grep ^extra_modules $KDUMP_CONFIG_FILE | sed
's/^extra_modules\s*//')"
+ local _modified_modules
+
+ # Check for any updated module
+ for _module in $_extra_modules; do
+ _module_file="$(modinfo -k "$kdump_kver" -n "$_module"
2>/dev/null)"
+ if [[ -n "$_module_file" ]]; then
+ _time_stamp="$(stat -c "%Y" "$_module_file")"
+ if [ "$_time_stamp" -gt "$image_time" ]; then
+ _modified_modules+="$_module "
+ fi
+ fi
+ done
+
+ if [[ -n "$_modified_modules" ]]; then
+ echo "Detected change(s) of following kernel modules:"
+ for _module in $_modified_modules; do
+ echo "$_module"
+ done
+ return 1
+ fi
+
+ return 0
+}
+
# returns 0 if system is not modified
# returns 1 if system is modified
# returns 2 if system modification is invalid
@@ -513,12 +541,16 @@ check_system_modified()
return 1
fi
+ check_kmodules_modified
+ if [ $? -ne 0 ]; then
+ return 1
+ fi
+
return 0
}
check_rebuild()
{
- local extra_modules
local capture_capable_initrd="1"
local _force_rebuild force_rebuild="0"
local _force_no_rebuild force_no_rebuild="0"
@@ -558,10 +590,6 @@ check_rebuild()
return 0
fi
- #will rebuild every time if extra_modules are specified
- extra_modules=`grep ^extra_modules $KDUMP_CONFIG_FILE`
- [ -n "$extra_modules" ] && force_rebuild="1"
-
#check to see if dependent files has been modified
#since last build of the image file
if [ -f $TARGET_INITRD ]; then
--
2.20.1