From 6cd5205adedcb8a04c8dc6eef19c0cecffdfac12 Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Fri, 11 Oct 2024 10:17:03 +0800 Subject: [PATCH] Rebase to upstream v1.0.45 Upstream: Fedora Conflict: None Resolves: RHEL-59863 Resolves: RHEL-29941 Signed-off-by: Lichen Liu --- .gitignore | 1 + 0001-editorconfig-set-indent_size-8.patch | 36 - ...e-sub-directories-for-dracut-modules.patch | 187 --- ...-dracut-fix-coding-style-using-shfmt.patch | 1306 ----------------- 0004-99kdumpbase-drop-unnecessary-2-1.patch | 47 - ...-99kdumpbase-fix-shellcheck-warnings.patch | 247 ---- ...99earlykdump-fix-shellcheck-warnings.patch | 86 -- ...z-fadumpinit-fix-shellcheck-warnings.patch | 51 - 0008-kdumpctl-fix-shellcheck-warnings.patch | 75 - 0009-mkdumprd-fix-shellcheck-warnings.patch | 53 - 0010-mkfadumprd-fix-shellcheck-warnings.patch | 44 - ...implify-handling-of-dracut-arguments.patch | 136 -- ...mkdumprd-drop-extra_modules-variable.patch | 47 - ...-check-for-lvmthinpool-monitor-modul.patch | 34 - ...eck-for-dracut-option-squash-compres.patch | 49 - ...xplicitly-add-dracut-99squash-module.patch | 111 -- ...umprd-add-support-for-95squash-erofs.patch | 88 -- kdump-utils.spec | 61 +- sources | 1 + 19 files changed, 5 insertions(+), 2655 deletions(-) delete mode 100644 0001-editorconfig-set-indent_size-8.patch delete mode 100644 0002-dracut-create-sub-directories-for-dracut-modules.patch delete mode 100644 0003-dracut-fix-coding-style-using-shfmt.patch delete mode 100644 0004-99kdumpbase-drop-unnecessary-2-1.patch delete mode 100644 0005-99kdumpbase-fix-shellcheck-warnings.patch delete mode 100644 0006-99earlykdump-fix-shellcheck-warnings.patch delete mode 100644 0007-99zz-fadumpinit-fix-shellcheck-warnings.patch delete mode 100644 0008-kdumpctl-fix-shellcheck-warnings.patch delete mode 100644 0009-mkdumprd-fix-shellcheck-warnings.patch delete mode 100644 0010-mkfadumprd-fix-shellcheck-warnings.patch delete mode 100644 0011-mkdumprd-simplify-handling-of-dracut-arguments.patch delete mode 100644 0012-mkdumprd-drop-extra_modules-variable.patch delete mode 100644 0013-99kdumpbase-drop-check-for-lvmthinpool-monitor-modul.patch delete mode 100644 0014-mkdumprd-drop-check-for-dracut-option-squash-compres.patch delete mode 100644 0015-mkdumprd-explicitly-add-dracut-99squash-module.patch delete mode 100644 0016-mkdumprd-add-support-for-95squash-erofs.patch diff --git a/.gitignore b/.gitignore index 5edbb2b..420760d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /kdump-utils-1.0.42.tar.gz /kdump-utils-1.0.43.tar.gz +/kdump-utils-1.0.45.tar.gz diff --git a/0001-editorconfig-set-indent_size-8.patch b/0001-editorconfig-set-indent_size-8.patch deleted file mode 100644 index 9b606ad..0000000 --- a/0001-editorconfig-set-indent_size-8.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 628387661812c74ddd613fcb3ac2203bbd6f1204 Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 13:59:41 +0200 -Subject: [PATCH 01/16] editorconfig: set indent_size=8 - -The indent_size gives the number of spaces an indentation should have. -When combined with indent_style=tab and tab_width=X the leading X spaces -are replaced by a tab. If tab_width is omitted it is set to the value of -indent_size. For the current settings this means that every level of -indentation is indented by a single space which gets replaced by a tab. -The tab again is displayed by a single space, if you set your editor to -follow the editconfig. This is not only barely readable but also impacts -line breaks for over long lines. Thus set indent_size=8 to better match -the way over long lines are broken at the moment. - -Signed-off-by: Philipp Rudo ---- - .editorconfig | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/.editorconfig b/.editorconfig -index b343f27..98bc39a 100644 ---- a/.editorconfig -+++ b/.editorconfig -@@ -11,7 +11,7 @@ shell_variant = posix - insert_final_newline = true - trim_trailing_whitespace = true - indent_style = tab --indent_size = 1 -+indent_size = 8 - switch_case_indent = false - function_next_line = true - binary_next_line = false --- -2.46.1 - diff --git a/0002-dracut-create-sub-directories-for-dracut-modules.patch b/0002-dracut-create-sub-directories-for-dracut-modules.patch deleted file mode 100644 index 83e3ad9..0000000 --- a/0002-dracut-create-sub-directories-for-dracut-modules.patch +++ /dev/null @@ -1,187 +0,0 @@ -From c986a97b64060fdc0f5ae67fb822163a7fd5a884 Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Mon, 1 Jul 2024 15:06:15 +0200 -Subject: [PATCH 02/16] dracut: create sub-directories for dracut modules - -With the introduction of the Makefile it is now easy to move files into -different sub-directories. Thus create a sub-directory for each of the -dracut modules and move their files there. This not only cleans up the -main directory but also simplifies the Makefile and prevents bugs like -the one fixed in 5109f11 ("Makefile: Fix early-kdump file names"). - -One nice site effect by using 'cp' instead of 'install' is that file -permissions from the repo are preserved. So instead of manually setting -the file permissions for each call to 'install' we can now simply change -(and commit) the file permissions in the repo. Like it is done for -99kdumpbase/monitor_dd_progress.sh and 99zz-fadumpinit/module-setup.sh -in this commit. - -Also adjust the .editorconfig to the new structure. - -Signed-off-by: Philipp Rudo ---- - .editorconfig | 10 ---------- - Makefile | 19 +++---------------- - dracut/.editorconfig | 9 +++++++++ - .../99earlykdump/early-kdump.sh | 0 - .../99earlykdump/module-setup.sh | 0 - dracut/99kdumpbase/.editorconfig | 3 +++ - .../99kdumpbase/kdump-capture.service | 0 - .../99kdumpbase/kdump-emergency.service | 0 - .../99kdumpbase/kdump-emergency.target | 0 - .../99kdumpbase/kdump.sh | 0 - .../99kdumpbase/module-setup.sh | 0 - .../99kdumpbase/monitor_dd_progress.sh | 0 - dracut/99zz-fadumpinit/.editorconfig | 3 +++ - .../99zz-fadumpinit/init-fadump.sh | 0 - .../99zz-fadumpinit/module-setup.sh | 0 - 15 files changed, 18 insertions(+), 26 deletions(-) - create mode 100644 dracut/.editorconfig - rename dracut-early-kdump.sh => dracut/99earlykdump/early-kdump.sh (100%) - rename dracut-early-kdump-module-setup.sh => dracut/99earlykdump/module-setup.sh (100%) - create mode 100644 dracut/99kdumpbase/.editorconfig - rename dracut-kdump-capture.service => dracut/99kdumpbase/kdump-capture.service (100%) - rename dracut-kdump-emergency.service => dracut/99kdumpbase/kdump-emergency.service (100%) - rename dracut-kdump-emergency.target => dracut/99kdumpbase/kdump-emergency.target (100%) - rename dracut-kdump.sh => dracut/99kdumpbase/kdump.sh (100%) - rename dracut-module-setup.sh => dracut/99kdumpbase/module-setup.sh (100%) - rename dracut-monitor_dd_progress.sh => dracut/99kdumpbase/monitor_dd_progress.sh (100%) - mode change 100644 => 100755 - create mode 100644 dracut/99zz-fadumpinit/.editorconfig - rename dracut-fadump-init-fadump.sh => dracut/99zz-fadumpinit/init-fadump.sh (100%) - rename dracut-fadump-module-setup.sh => dracut/99zz-fadumpinit/module-setup.sh (100%) - mode change 100644 => 100755 - -diff --git a/.editorconfig b/.editorconfig -index 98bc39a..dd58ec8 100644 ---- a/.editorconfig -+++ b/.editorconfig -@@ -20,13 +20,3 @@ space_redirects = true - # Some scripts will only run with bash - [{mkfadumprd,mkdumprd,kdumpctl,kdump-lib.sh}] - shell_variant = bash -- --# Use dracut code style for *-module-setup.sh --[*-module-setup.sh,dracut-early-kdump.sh] --shell_variant = bash --indent_style = space --indent_size = 4 --switch_case_indent = true --function_next_line = false --binary_next_line = true --space_redirects = true -diff --git a/Makefile b/Makefile -index 538e4f4..5029a59 100644 ---- a/Makefile -+++ b/Makefile -@@ -12,27 +12,14 @@ udevrulesdir ?= ${libdir}/udev/rules.d - systemdsystemunitdir ?= ${libdir}/systemd/system/ - ARCH ?= $(shell uname -m) - dracutmoddir = $(DESTDIR)${libdir}/dracut/modules.d --kdumpbasemoddir = $(dracutmoddir)/99kdumpbase - - dracut-modules: - mkdir -p $(dracutmoddir) -- mkdir -p -m755 $(kdumpbasemoddir) -- -- install -m 755 dracut-kdump.sh $(kdumpbasemoddir)/kdump.sh -- install -m 755 dracut-module-setup.sh $(kdumpbasemoddir)/module-setup.sh -- install -m 755 dracut-monitor_dd_progress.sh $(kdumpbasemoddir)/monitor_dd_progress.sh -- install -m 644 dracut-kdump-emergency.service $(kdumpbasemoddir)/kdump-emergency.service -- install -m 644 dracut-kdump-capture.service $(kdumpbasemoddir)/kdump-capture.service -- install -m 644 dracut-kdump-emergency.target $(kdumpbasemoddir)/kdump-emergency.target -- -- mkdir -p -m755 $(dracutmoddir)/99earlykdump -- install -m 755 dracut-early-kdump.sh $(dracutmoddir)/99earlykdump/early-kdump.sh -- install -m 755 dracut-early-kdump-module-setup.sh $(dracutmoddir)/99earlykdump/module-setup.sh - -+ cp -r dracut/99kdumpbase $(dracutmoddir) -+ cp -r dracut/99earlykdump $(dracutmoddir) - ifeq ($(ARCH), $(filter ppc64le ppc64,$(ARCH))) -- mkdir -p -m755 $(dracutmoddir)/99zz-fadumpinit -- install -m 755 dracut-fadump-init-fadump.sh $(dracutmoddir)/99zz-fadumpinit/init-fadump.sh -- install -m 755 dracut-fadump-module-setup.sh $(dracutmoddir)/99zz-fadumpinit/module-setup.sh -+ cp -r dracut/99zz-fadumpinit $(dracutmoddir) - endif - - kdump-conf: gen-kdump-conf.sh -diff --git a/dracut/.editorconfig b/dracut/.editorconfig -new file mode 100644 -index 0000000..254f870 ---- /dev/null -+++ b/dracut/.editorconfig -@@ -0,0 +1,9 @@ -+# Use dracut code style for dracut modules -+[*] -+shell_variant = bash -+indent_style = space -+indent_size = 4 -+switch_case_indent = true -+function_next_line = false -+binary_next_line = true -+space_redirects = true -diff --git a/dracut-early-kdump.sh b/dracut/99earlykdump/early-kdump.sh -similarity index 100% -rename from dracut-early-kdump.sh -rename to dracut/99earlykdump/early-kdump.sh -diff --git a/dracut-early-kdump-module-setup.sh b/dracut/99earlykdump/module-setup.sh -similarity index 100% -rename from dracut-early-kdump-module-setup.sh -rename to dracut/99earlykdump/module-setup.sh -diff --git a/dracut/99kdumpbase/.editorconfig b/dracut/99kdumpbase/.editorconfig -new file mode 100644 -index 0000000..feb7df2 ---- /dev/null -+++ b/dracut/99kdumpbase/.editorconfig -@@ -0,0 +1,3 @@ -+# These files run in the initrd and need to be posix compliant -+[{monitor_dd_progress.sh,kdump.sh}] -+shell_variant = posix -diff --git a/dracut-kdump-capture.service b/dracut/99kdumpbase/kdump-capture.service -similarity index 100% -rename from dracut-kdump-capture.service -rename to dracut/99kdumpbase/kdump-capture.service -diff --git a/dracut-kdump-emergency.service b/dracut/99kdumpbase/kdump-emergency.service -similarity index 100% -rename from dracut-kdump-emergency.service -rename to dracut/99kdumpbase/kdump-emergency.service -diff --git a/dracut-kdump-emergency.target b/dracut/99kdumpbase/kdump-emergency.target -similarity index 100% -rename from dracut-kdump-emergency.target -rename to dracut/99kdumpbase/kdump-emergency.target -diff --git a/dracut-kdump.sh b/dracut/99kdumpbase/kdump.sh -similarity index 100% -rename from dracut-kdump.sh -rename to dracut/99kdumpbase/kdump.sh -diff --git a/dracut-module-setup.sh b/dracut/99kdumpbase/module-setup.sh -similarity index 100% -rename from dracut-module-setup.sh -rename to dracut/99kdumpbase/module-setup.sh -diff --git a/dracut-monitor_dd_progress.sh b/dracut/99kdumpbase/monitor_dd_progress.sh -old mode 100644 -new mode 100755 -similarity index 100% -rename from dracut-monitor_dd_progress.sh -rename to dracut/99kdumpbase/monitor_dd_progress.sh -diff --git a/dracut/99zz-fadumpinit/.editorconfig b/dracut/99zz-fadumpinit/.editorconfig -new file mode 100644 -index 0000000..fdcbad4 ---- /dev/null -+++ b/dracut/99zz-fadumpinit/.editorconfig -@@ -0,0 +1,3 @@ -+# These files run in the initrd and need to be posix compliant -+[{init-fadump.sh}] -+shell_variant = posix -diff --git a/dracut-fadump-init-fadump.sh b/dracut/99zz-fadumpinit/init-fadump.sh -similarity index 100% -rename from dracut-fadump-init-fadump.sh -rename to dracut/99zz-fadumpinit/init-fadump.sh -diff --git a/dracut-fadump-module-setup.sh b/dracut/99zz-fadumpinit/module-setup.sh -old mode 100644 -new mode 100755 -similarity index 100% -rename from dracut-fadump-module-setup.sh -rename to dracut/99zz-fadumpinit/module-setup.sh --- -2.46.1 - diff --git a/0003-dracut-fix-coding-style-using-shfmt.patch b/0003-dracut-fix-coding-style-using-shfmt.patch deleted file mode 100644 index 4ba2be4..0000000 --- a/0003-dracut-fix-coding-style-using-shfmt.patch +++ /dev/null @@ -1,1306 +0,0 @@ -From c939ce551e1cbd24dd35878f53feef18dae059ad Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 14:43:42 +0200 -Subject: [PATCH 03/16] dracut/*: fix coding style using shfmt - -Commit generated using - $ shfmt -s -w dracut/ - -Signed-off-by: Philipp Rudo ---- - dracut/99earlykdump/early-kdump.sh | 13 +- - dracut/99kdumpbase/kdump.sh | 928 +++++++++++----------- - dracut/99kdumpbase/module-setup.sh | 25 +- - dracut/99kdumpbase/monitor_dd_progress.sh | 12 +- - dracut/99zz-fadumpinit/init-fadump.sh | 74 +- - 5 files changed, 513 insertions(+), 539 deletions(-) - -diff --git a/dracut/99earlykdump/early-kdump.sh b/dracut/99earlykdump/early-kdump.sh -index 4fd8e90..a355010 100755 ---- a/dracut/99earlykdump/early-kdump.sh -+++ b/dracut/99earlykdump/early-kdump.sh -@@ -15,19 +15,17 @@ EARLY_KEXEC_ARGS="" - - # initiate the kdump logger - if ! dlog_init; then -- echo "failed to initiate the kdump logger." -- exit 1 -+ echo "failed to initiate the kdump logger." -+ exit 1 - fi - --prepare_parameters() --{ -+prepare_parameters() { - EARLY_KDUMP_CMDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") - EARLY_KDUMP_KERNEL="/boot/kernel-earlykdump" - EARLY_KDUMP_INITRD="/boot/initramfs-earlykdump" - } - --early_kdump_load() --{ -+early_kdump_load() { - if ! check_kdump_feasibility; then - return 1 - fi -@@ -64,8 +62,7 @@ early_kdump_load() - fi - } - --set_early_kdump() --{ -+set_early_kdump() { - if getargbool 0 rd.earlykdump; then - dinfo "early-kdump is enabled." - early_kdump_load -diff --git a/dracut/99kdumpbase/kdump.sh b/dracut/99kdumpbase/kdump.sh -index 2e078c7..22586b1 100755 ---- a/dracut/99kdumpbase/kdump.sh -+++ b/dracut/99kdumpbase/kdump.sh -@@ -9,8 +9,8 @@ - - #initiate the kdump logger - if ! dlog_init; then -- echo "failed to initiate the kdump logger." -- exit 1 -+ echo "failed to initiate the kdump logger." -+ exit 1 - fi - - KDUMP_PATH="/var/crash" -@@ -41,585 +41,565 @@ DUMP_RETVAL=0 - - kdump_read_conf > $KDUMP_CONF_PARSED - --get_kdump_confs() --{ -- while read -r config_opt config_val; do -- # remove inline comments after the end of a directive. -- case "$config_opt" in -- path) -- KDUMP_PATH="$config_val" -- ;; -- core_collector) -- [ -n "$config_val" ] && CORE_COLLECTOR="$config_val" -- ;; -- sshkey) -- if [ -f "$config_val" ]; then -- SSH_KEY_LOCATION=$config_val -- fi -- ;; -- kdump_pre) -- KDUMP_PRE="$config_val" -- ;; -- kdump_post) -- KDUMP_POST="$config_val" -- ;; -- fence_kdump_args) -- FENCE_KDUMP_ARGS="$config_val" -- ;; -- fence_kdump_nodes) -- FENCE_KDUMP_NODES="$config_val" -- ;; -- failure_action | default) -- case $config_val in -- shell) -- FAILURE_ACTION="kdump_emergency_shell" -- ;; -- reboot) -- FAILURE_ACTION="systemctl reboot -f && exit" -- ;; -- halt) -- FAILURE_ACTION="halt && exit" -- ;; -- poweroff) -- FAILURE_ACTION="systemctl poweroff -f && exit" -- ;; -- dump_to_rootfs) -- FAILURE_ACTION="dump_to_rootfs" -- ;; -- esac -- ;; -- final_action) -- case $config_val in -- reboot) -- FINAL_ACTION="systemctl reboot -f" -- ;; -- halt) -- FINAL_ACTION="halt" -- ;; -- poweroff) -- FINAL_ACTION="systemctl poweroff -f" -- ;; -- esac -- ;; -- esac -- done < "$KDUMP_CONF_PARSED" -- -- if [ -z "$CORE_COLLECTOR" ]; then -- CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR" -- if is_ssh_dump_target || is_raw_dump_target; then -- CORE_COLLECTOR="$CORE_COLLECTOR -F" -- fi -- fi -+get_kdump_confs() { -+ while read -r config_opt config_val; do -+ # remove inline comments after the end of a directive. -+ case "$config_opt" in -+ path) -+ KDUMP_PATH="$config_val" -+ ;; -+ core_collector) -+ [ -n "$config_val" ] && CORE_COLLECTOR="$config_val" -+ ;; -+ sshkey) -+ if [ -f "$config_val" ]; then -+ SSH_KEY_LOCATION=$config_val -+ fi -+ ;; -+ kdump_pre) -+ KDUMP_PRE="$config_val" -+ ;; -+ kdump_post) -+ KDUMP_POST="$config_val" -+ ;; -+ fence_kdump_args) -+ FENCE_KDUMP_ARGS="$config_val" -+ ;; -+ fence_kdump_nodes) -+ FENCE_KDUMP_NODES="$config_val" -+ ;; -+ failure_action | default) -+ case $config_val in -+ shell) -+ FAILURE_ACTION="kdump_emergency_shell" -+ ;; -+ reboot) -+ FAILURE_ACTION="systemctl reboot -f && exit" -+ ;; -+ halt) -+ FAILURE_ACTION="halt && exit" -+ ;; -+ poweroff) -+ FAILURE_ACTION="systemctl poweroff -f && exit" -+ ;; -+ dump_to_rootfs) -+ FAILURE_ACTION="dump_to_rootfs" -+ ;; -+ esac -+ ;; -+ final_action) -+ case $config_val in -+ reboot) -+ FINAL_ACTION="systemctl reboot -f" -+ ;; -+ halt) -+ FINAL_ACTION="halt" -+ ;; -+ poweroff) -+ FINAL_ACTION="systemctl poweroff -f" -+ ;; -+ esac -+ ;; -+ esac -+ done < "$KDUMP_CONF_PARSED" -+ -+ if [ -z "$CORE_COLLECTOR" ]; then -+ CORE_COLLECTOR="$DEFAULT_CORE_COLLECTOR" -+ if is_ssh_dump_target || is_raw_dump_target; then -+ CORE_COLLECTOR="$CORE_COLLECTOR -F" -+ fi -+ fi - } - - # store the kexec kernel log to a file. --save_log() --{ -- # LOG_OP is empty when log can't be saved, eg. raw target -- [ -n "$KDUMP_LOG_OP" ] || return -+save_log() { -+ # LOG_OP is empty when log can't be saved, eg. raw target -+ [ -n "$KDUMP_LOG_OP" ] || return - -- dmesg -T > $KDUMP_LOG_FILE -+ dmesg -T > $KDUMP_LOG_FILE - -- if command -v journalctl > /dev/null; then -- journalctl -ab >> $KDUMP_LOG_FILE -- fi -- chmod 600 $KDUMP_LOG_FILE -+ if command -v journalctl > /dev/null; then -+ journalctl -ab >> $KDUMP_LOG_FILE -+ fi -+ chmod 600 $KDUMP_LOG_FILE - -- dinfo "saving the $KDUMP_LOG_FILE to $KDUMP_LOG_DEST/" -+ dinfo "saving the $KDUMP_LOG_FILE to $KDUMP_LOG_DEST/" - -- eval "$KDUMP_LOG_OP" -+ eval "$KDUMP_LOG_OP" - } - - # $1: dump path, must be a mount point --dump_fs() --{ -- ddebug "dump_fs _mp=$1" -- -- if ! is_mounted "$1"; then -- dinfo "dump path '$1' is not mounted, trying to mount..." -- if ! mount --target "$1"; then -- derror "failed to dump to '$1', it's not a mount point!" -- return 1 -- fi -- fi -- -- # Remove -F in makedumpfile case. We don't want a flat format dump here. -- case $CORE_COLLECTOR in -- *makedumpfile*) -- CORE_COLLECTOR=$(echo "$CORE_COLLECTOR" | sed -e "s/-F//g") -- ;; -- esac -- -- _dump_fs_path=$(echo "$1/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /) -- dinfo "saving to $_dump_fs_path" -- -- # Only remount to read-write mode if the dump target is mounted read-only. -- _dump_mnt_op=$(get_mount_info OPTIONS target "$1" -f) -- case $_dump_mnt_op in -- ro*) -- dinfo "Remounting the dump target in rw mode." -- mount -o remount,rw "$1" || return 1 -- ;; -- esac -- -- mkdir -p "$_dump_fs_path" || return 1 -- -- save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_fs_path" -- save_opalcore_fs "$_dump_fs_path" -- -- dinfo "saving vmcore" -- KDUMP_LOG_DEST=$_dump_fs_path/ -- KDUMP_LOG_OP="mv '$KDUMP_LOG_FILE' '$KDUMP_LOG_DEST/'" -- -- $CORE_COLLECTOR /proc/vmcore "$_dump_fs_path/vmcore-incomplete" -- _dump_exitcode=$? -- if [ $_dump_exitcode -eq 0 ]; then -- sync -f "$_dump_fs_path/vmcore-incomplete" -- _sync_exitcode=$? -- if [ $_sync_exitcode -eq 0 ]; then -- mv "$_dump_fs_path/vmcore-incomplete" "$_dump_fs_path/vmcore" -- dinfo "saving vmcore complete" -- else -- derror "sync vmcore failed, exitcode:$_sync_exitcode" -- return 1 -- fi -- else -- derror "saving vmcore failed, exitcode:$_dump_exitcode" -- return 1 -- fi -- -- # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure -- return 0 -+dump_fs() { -+ ddebug "dump_fs _mp=$1" -+ -+ if ! is_mounted "$1"; then -+ dinfo "dump path '$1' is not mounted, trying to mount..." -+ if ! mount --target "$1"; then -+ derror "failed to dump to '$1', it's not a mount point!" -+ return 1 -+ fi -+ fi -+ -+ # Remove -F in makedumpfile case. We don't want a flat format dump here. -+ case $CORE_COLLECTOR in -+ *makedumpfile*) -+ CORE_COLLECTOR=$(echo "$CORE_COLLECTOR" | sed -e "s/-F//g") -+ ;; -+ esac -+ -+ _dump_fs_path=$(echo "$1/$KDUMP_PATH/$HOST_IP-$DATEDIR/" | tr -s /) -+ dinfo "saving to $_dump_fs_path" -+ -+ # Only remount to read-write mode if the dump target is mounted read-only. -+ _dump_mnt_op=$(get_mount_info OPTIONS target "$1" -f) -+ case $_dump_mnt_op in -+ ro*) -+ dinfo "Remounting the dump target in rw mode." -+ mount -o remount,rw "$1" || return 1 -+ ;; -+ esac -+ -+ mkdir -p "$_dump_fs_path" || return 1 -+ -+ save_vmcore_dmesg_fs ${DMESG_COLLECTOR} "$_dump_fs_path" -+ save_opalcore_fs "$_dump_fs_path" -+ -+ dinfo "saving vmcore" -+ KDUMP_LOG_DEST=$_dump_fs_path/ -+ KDUMP_LOG_OP="mv '$KDUMP_LOG_FILE' '$KDUMP_LOG_DEST/'" -+ -+ $CORE_COLLECTOR /proc/vmcore "$_dump_fs_path/vmcore-incomplete" -+ _dump_exitcode=$? -+ if [ $_dump_exitcode -eq 0 ]; then -+ sync -f "$_dump_fs_path/vmcore-incomplete" -+ _sync_exitcode=$? -+ if [ $_sync_exitcode -eq 0 ]; then -+ mv "$_dump_fs_path/vmcore-incomplete" "$_dump_fs_path/vmcore" -+ dinfo "saving vmcore complete" -+ else -+ derror "sync vmcore failed, exitcode:$_sync_exitcode" -+ return 1 -+ fi -+ else -+ derror "saving vmcore failed, exitcode:$_dump_exitcode" -+ return 1 -+ fi -+ -+ # improper kernel cmdline can cause the failure of echo, we can ignore this kind of failure -+ return 0 - } - - # $1: dmesg collector - # $2: dump path --save_vmcore_dmesg_fs() --{ -- dinfo "saving vmcore-dmesg.txt to $2" -- if $1 /proc/vmcore > "$2/vmcore-dmesg-incomplete.txt"; then -- mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" -- chmod 600 "$2/vmcore-dmesg.txt" -- -- # Make sure file is on disk. There have been instances where later -- # saving vmcore failed and system rebooted without sync and there -- # was no vmcore-dmesg.txt available. -- sync -- dinfo "saving vmcore-dmesg.txt complete" -- else -- if [ -f "$2/vmcore-dmesg-incomplete.txt" ]; then -- chmod 600 "$2/vmcore-dmesg-incomplete.txt" -- fi -- derror "saving vmcore-dmesg.txt failed" -- fi -+save_vmcore_dmesg_fs() { -+ dinfo "saving vmcore-dmesg.txt to $2" -+ if $1 /proc/vmcore > "$2/vmcore-dmesg-incomplete.txt"; then -+ mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" -+ chmod 600 "$2/vmcore-dmesg.txt" -+ -+ # Make sure file is on disk. There have been instances where later -+ # saving vmcore failed and system rebooted without sync and there -+ # was no vmcore-dmesg.txt available. -+ sync -+ dinfo "saving vmcore-dmesg.txt complete" -+ else -+ if [ -f "$2/vmcore-dmesg-incomplete.txt" ]; then -+ chmod 600 "$2/vmcore-dmesg-incomplete.txt" -+ fi -+ derror "saving vmcore-dmesg.txt failed" -+ fi - } - - # $1: dump path --save_opalcore_fs() --{ -- if [ ! -f $OPALCORE ]; then -- # Check if we are on an old kernel that uses a different path -- if [ -f /sys/firmware/opal/core ]; then -- OPALCORE="/sys/firmware/opal/core" -- else -- return 0 -- fi -- fi -- -- dinfo "saving opalcore:$OPALCORE to $1/opalcore" -- if ! cp $OPALCORE "$1/opalcore"; then -- derror "saving opalcore failed" -- return 1 -- fi -- -- sync -- dinfo "saving opalcore complete" -- return 0 -+save_opalcore_fs() { -+ if [ ! -f $OPALCORE ]; then -+ # Check if we are on an old kernel that uses a different path -+ if [ -f /sys/firmware/opal/core ]; then -+ OPALCORE="/sys/firmware/opal/core" -+ else -+ return 0 -+ fi -+ fi -+ -+ dinfo "saving opalcore:$OPALCORE to $1/opalcore" -+ if ! cp $OPALCORE "$1/opalcore"; then -+ derror "saving opalcore failed" -+ return 1 -+ fi -+ -+ sync -+ dinfo "saving opalcore complete" -+ return 0 - } - --dump_to_rootfs() --{ -+dump_to_rootfs() { - -- if [ "$(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p")" = "inactive" ]; then -- dinfo "Trying to bring up initqueue for rootfs mount" -- systemctl start dracut-initqueue -- fi -+ if [ "$(systemctl status dracut-initqueue | sed -n "s/^\s*Active: \(\S*\)\s.*$/\1/p")" = "inactive" ]; then -+ dinfo "Trying to bring up initqueue for rootfs mount" -+ systemctl start dracut-initqueue -+ fi - -- dinfo "Clean up dead systemd services" -- systemctl cancel -- dinfo "Waiting for rootfs mount, will timeout after 90 seconds" -- systemctl start --no-block sysroot.mount -+ dinfo "Clean up dead systemd services" -+ systemctl cancel -+ dinfo "Waiting for rootfs mount, will timeout after 90 seconds" -+ systemctl start --no-block sysroot.mount - -- _loop=0 -- while [ $_loop -lt 90 ] && ! is_mounted /sysroot; do -- sleep 1 -- _loop=$((_loop + 1)) -- done -+ _loop=0 -+ while [ $_loop -lt 90 ] && ! is_mounted /sysroot; do -+ sleep 1 -+ _loop=$((_loop + 1)) -+ done - -- if ! is_mounted /sysroot; then -- derror "Failed to mount rootfs" -- return -- fi -+ if ! is_mounted /sysroot; then -+ derror "Failed to mount rootfs" -+ return -+ fi - -- ddebug "NEWROOT=$NEWROOT" -- dump_fs $NEWROOT -+ ddebug "NEWROOT=$NEWROOT" -+ dump_fs $NEWROOT - } - --kdump_emergency_shell() --{ -- ddebug "Switching to kdump emergency shell..." -- -- [ -f /etc/profile ] && . /etc/profile -- export PS1='kdump:${PWD}# ' -- -- . /lib/dracut-lib.sh -- if [ -f /dracut-state.sh ]; then -- . /dracut-state.sh 2> /dev/null -- fi -- -- source_conf /etc/conf.d -- -- type plymouth > /dev/null 2>&1 && plymouth quit -- -- source_hook "emergency" -- while read -r _tty rest; do -- ( -- echo -- echo -- echo 'Entering kdump emergency mode.' -- echo 'Type "journalctl" to view system logs.' -- echo 'Type "rdsosreport" to generate a sosreport, you can then' -- echo 'save it elsewhere and attach it to a bug report.' -- echo -- echo -- ) > "/dev/$_tty" -- done < /proc/consoles -- sh -i -l -- /bin/rm -f -- /.console_lock -+kdump_emergency_shell() { -+ ddebug "Switching to kdump emergency shell..." -+ -+ [ -f /etc/profile ] && . /etc/profile -+ export PS1='kdump:${PWD}# ' -+ -+ . /lib/dracut-lib.sh -+ if [ -f /dracut-state.sh ]; then -+ . /dracut-state.sh 2> /dev/null -+ fi -+ -+ source_conf /etc/conf.d -+ -+ type plymouth > /dev/null 2>&1 && plymouth quit -+ -+ source_hook "emergency" -+ while read -r _tty rest; do -+ ( -+ echo -+ echo -+ echo 'Entering kdump emergency mode.' -+ echo 'Type "journalctl" to view system logs.' -+ echo 'Type "rdsosreport" to generate a sosreport, you can then' -+ echo 'save it elsewhere and attach it to a bug report.' -+ echo -+ echo -+ ) > "/dev/$_tty" -+ done < /proc/consoles -+ sh -i -l -+ /bin/rm -f -- /.console_lock - } - --do_failure_action() --{ -- dinfo "Executing failure action $FAILURE_ACTION" -- eval $FAILURE_ACTION -+do_failure_action() { -+ dinfo "Executing failure action $FAILURE_ACTION" -+ eval $FAILURE_ACTION - } - --do_final_action() --{ -- dinfo "Executing final action $FINAL_ACTION" -- eval $FINAL_ACTION -+do_final_action() { -+ dinfo "Executing final action $FINAL_ACTION" -+ eval $FINAL_ACTION - } - --do_dump() --{ -- eval $DUMP_INSTRUCTION -- _ret=$? -+do_dump() { -+ eval $DUMP_INSTRUCTION -+ _ret=$? - -- if [ $_ret -ne 0 ]; then -- derror "saving vmcore failed" -- fi -+ if [ $_ret -ne 0 ]; then -+ derror "saving vmcore failed" -+ fi - -- return $_ret -+ return $_ret - } - --do_kdump_pre() --{ -- if [ -n "$KDUMP_PRE" ]; then -- "$KDUMP_PRE" -- _ret=$? -- if [ $_ret -ne 0 ]; then -- derror "$KDUMP_PRE exited with $_ret status" -- return $_ret -- fi -- fi -- -- # if any script fails, it just raises warning and continues -- if [ -d /etc/kdump/pre.d ]; then -- for file in /etc/kdump/pre.d/*; do -- "$file" -- _ret=$? -- if [ $_ret -ne 0 ]; then -- derror "$file exited with $_ret status" -- fi -- done -- fi -- return 0 -+do_kdump_pre() { -+ if [ -n "$KDUMP_PRE" ]; then -+ "$KDUMP_PRE" -+ _ret=$? -+ if [ $_ret -ne 0 ]; then -+ derror "$KDUMP_PRE exited with $_ret status" -+ return $_ret -+ fi -+ fi -+ -+ # if any script fails, it just raises warning and continues -+ if [ -d /etc/kdump/pre.d ]; then -+ for file in /etc/kdump/pre.d/*; do -+ "$file" -+ _ret=$? -+ if [ $_ret -ne 0 ]; then -+ derror "$file exited with $_ret status" -+ fi -+ done -+ fi -+ return 0 - } - --do_kdump_post() --{ -- if [ -d /etc/kdump/post.d ]; then -- for file in /etc/kdump/post.d/*; do -- "$file" "$1" -- _ret=$? -- if [ $_ret -ne 0 ]; then -- derror "$file exited with $_ret status" -- fi -- done -- fi -- -- if [ -n "$KDUMP_POST" ]; then -- "$KDUMP_POST" "$1" -- _ret=$? -- if [ $_ret -ne 0 ]; then -- derror "$KDUMP_POST exited with $_ret status" -- fi -- fi -+do_kdump_post() { -+ if [ -d /etc/kdump/post.d ]; then -+ for file in /etc/kdump/post.d/*; do -+ "$file" "$1" -+ _ret=$? -+ if [ $_ret -ne 0 ]; then -+ derror "$file exited with $_ret status" -+ fi -+ done -+ fi -+ -+ if [ -n "$KDUMP_POST" ]; then -+ "$KDUMP_POST" "$1" -+ _ret=$? -+ if [ $_ret -ne 0 ]; then -+ derror "$KDUMP_POST exited with $_ret status" -+ fi -+ fi - } - - # $1: block target, eg. /dev/sda --dump_raw() --{ -- [ -b "$1" ] || return 1 -+dump_raw() { -+ [ -b "$1" ] || return 1 - -- dinfo "saving to raw disk $1" -+ dinfo "saving to raw disk $1" - -- if ! echo "$CORE_COLLECTOR" | grep -q makedumpfile; then -- _src_size=$(stat --format %s /proc/vmcore) -- _src_size_mb=$((_src_size / 1048576)) -- /kdumpscripts/monitor_dd_progress.sh $_src_size_mb & -- fi -+ if ! echo "$CORE_COLLECTOR" | grep -q makedumpfile; then -+ _src_size=$(stat --format %s /proc/vmcore) -+ _src_size_mb=$((_src_size / 1048576)) -+ /kdumpscripts/monitor_dd_progress.sh $_src_size_mb & -+ fi - -- dinfo "saving vmcore" -- $CORE_COLLECTOR /proc/vmcore | dd of="$1" bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1 -- sync -+ dinfo "saving vmcore" -+ $CORE_COLLECTOR /proc/vmcore | dd of="$1" bs=$DD_BLKSIZE >> /tmp/dd_progress_file 2>&1 || return 1 -+ sync - -- dinfo "saving vmcore complete" -- return 0 -+ dinfo "saving vmcore complete" -+ return 0 - } - - # $1: ssh key file - # $2: ssh address in @ format --dump_ssh() --{ -- _ret=0 -- _ssh_opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes" -- _ssh_dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" -- if is_ipv6_address "$2"; then -- _scp_address=${2%@*}@"[${2#*@}]" -- else -- _scp_address=$2 -- fi -- -- dinfo "saving to $2:$_ssh_dir" -- -- cat /var/lib/random-seed > /dev/urandom -- ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1 -- -- save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir" "$_ssh_opt" "$2" -- -- dinfo "saving vmcore" -- -- KDUMP_LOG_DEST=$2:$_ssh_dir/ -- KDUMP_LOG_OP="scp -q $_ssh_opt '$KDUMP_LOG_FILE' '$_scp_address:$_ssh_dir/'" -- -- save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2" "$_scp_address" -- -- if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then -- scp -q $_ssh_opt /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete" -- _ret=$? -- _vmcore="vmcore" -- else -- $CORE_COLLECTOR /proc/vmcore | ssh $_ssh_opt "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'" -- _ret=$? -- _vmcore="vmcore.flat" -- fi -- -- if [ $_ret -eq 0 ]; then -- ssh $_ssh_opt "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'" -- _ret=$? -- if [ $_ret -ne 0 ]; then -- derror "moving vmcore failed, exitcode:$_ret" -- else -- dinfo "saving vmcore complete" -- fi -- else -- derror "saving vmcore failed, exitcode:$_ret" -- fi -- -- return $_ret -+dump_ssh() { -+ _ret=0 -+ _ssh_opt="-i $1 -o BatchMode=yes -o StrictHostKeyChecking=yes" -+ _ssh_dir="$KDUMP_PATH/$HOST_IP-$DATEDIR" -+ if is_ipv6_address "$2"; then -+ _scp_address=${2%@*}@"[${2#*@}]" -+ else -+ _scp_address=$2 -+ fi -+ -+ dinfo "saving to $2:$_ssh_dir" -+ -+ cat /var/lib/random-seed > /dev/urandom -+ ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1 -+ -+ save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir" "$_ssh_opt" "$2" -+ -+ dinfo "saving vmcore" -+ -+ KDUMP_LOG_DEST=$2:$_ssh_dir/ -+ KDUMP_LOG_OP="scp -q $_ssh_opt '$KDUMP_LOG_FILE' '$_scp_address:$_ssh_dir/'" -+ -+ save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2" "$_scp_address" -+ -+ if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then -+ scp -q $_ssh_opt /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete" -+ _ret=$? -+ _vmcore="vmcore" -+ else -+ $CORE_COLLECTOR /proc/vmcore | ssh $_ssh_opt "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'" -+ _ret=$? -+ _vmcore="vmcore.flat" -+ fi -+ -+ if [ $_ret -eq 0 ]; then -+ ssh $_ssh_opt "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'" -+ _ret=$? -+ if [ $_ret -ne 0 ]; then -+ derror "moving vmcore failed, exitcode:$_ret" -+ else -+ dinfo "saving vmcore complete" -+ fi -+ else -+ derror "saving vmcore failed, exitcode:$_ret" -+ fi -+ -+ return $_ret - } - - # $1: dump path - # $2: ssh opts - # $3: ssh address in @ format - # $4: scp address, similar with ssh address but IPv6 addresses are quoted --save_opalcore_ssh() --{ -- if [ ! -f $OPALCORE ]; then -- # Check if we are on an old kernel that uses a different path -- if [ -f /sys/firmware/opal/core ]; then -- OPALCORE="/sys/firmware/opal/core" -- else -- return 0 -- fi -- fi -- -- dinfo "saving opalcore:$OPALCORE to $3:$1" -- -- if ! scp $2 $OPALCORE "$4:$1/opalcore-incomplete"; then -- derror "saving opalcore failed" -- return 1 -- fi -- -- ssh $2 "$3" mv "$1/opalcore-incomplete" "$1/opalcore" -- dinfo "saving opalcore complete" -- return 0 -+save_opalcore_ssh() { -+ if [ ! -f $OPALCORE ]; then -+ # Check if we are on an old kernel that uses a different path -+ if [ -f /sys/firmware/opal/core ]; then -+ OPALCORE="/sys/firmware/opal/core" -+ else -+ return 0 -+ fi -+ fi -+ -+ dinfo "saving opalcore:$OPALCORE to $3:$1" -+ -+ if ! scp $2 $OPALCORE "$4:$1/opalcore-incomplete"; then -+ derror "saving opalcore failed" -+ return 1 -+ fi -+ -+ ssh $2 "$3" mv "$1/opalcore-incomplete" "$1/opalcore" -+ dinfo "saving opalcore complete" -+ return 0 - } - - # $1: dmesg collector - # $2: dump path - # $3: ssh opts - # $4: ssh address in @ format --save_vmcore_dmesg_ssh() --{ -- dinfo "saving vmcore-dmesg.txt to $4:$2" -- if $1 /proc/vmcore | ssh $3 "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then -- ssh -q $3 "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" -- dinfo "saving vmcore-dmesg.txt complete" -- else -- derror "saving vmcore-dmesg.txt failed" -- fi -+save_vmcore_dmesg_ssh() { -+ dinfo "saving vmcore-dmesg.txt to $4:$2" -+ if $1 /proc/vmcore | ssh $3 "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then -+ ssh -q $3 "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" -+ dinfo "saving vmcore-dmesg.txt complete" -+ else -+ derror "saving vmcore-dmesg.txt failed" -+ fi - } - --wait_online_network() --{ -- # In some cases, network may still not be ready because nm-online is called -- # with "-s" which means to wait for NetworkManager startup to complete, rather -- # than waiting for network connectivity specifically. Wait 10mins more for the -- # network to be truely ready in these cases. -- _loop=0 -- while [ $_loop -lt 600 ]; do -- sleep 1 -- _loop=$((_loop + 1)) -- if _route=$(kdump_get_ip_route "$1" 2> /dev/null); then -- printf "%s" "$_route" -- return -- else -- dwarn "Waiting for network to be ready (${_loop}s / 10min)" -- fi -- done -- -- derror "Oops. The network still isn't ready after waiting 10mins." -- exit 1 -+wait_online_network() { -+ # In some cases, network may still not be ready because nm-online is called -+ # with "-s" which means to wait for NetworkManager startup to complete, rather -+ # than waiting for network connectivity specifically. Wait 10mins more for the -+ # network to be truely ready in these cases. -+ _loop=0 -+ while [ $_loop -lt 600 ]; do -+ sleep 1 -+ _loop=$((_loop + 1)) -+ if _route=$(kdump_get_ip_route "$1" 2> /dev/null); then -+ printf "%s" "$_route" -+ return -+ else -+ dwarn "Waiting for network to be ready (${_loop}s / 10min)" -+ fi -+ done -+ -+ derror "Oops. The network still isn't ready after waiting 10mins." -+ exit 1 - } - --get_host_ip() --{ -+get_host_ip() { - -- if ! is_nfs_dump_target && ! is_ssh_dump_target; then -- return 0 -- fi -+ if ! is_nfs_dump_target && ! is_ssh_dump_target; then -+ return 0 -+ fi - -- _kdump_remote_ip=$(getarg kdump_remote_ip=) -+ _kdump_remote_ip=$(getarg kdump_remote_ip=) - -- if [ -z "$_kdump_remote_ip" ]; then -- derror "failed to get remote IP address!" -- return 1 -- fi -+ if [ -z "$_kdump_remote_ip" ]; then -+ derror "failed to get remote IP address!" -+ return 1 -+ fi - -- if ! _route=$(wait_online_network "$_kdump_remote_ip"); then -- return 1 -- fi -+ if ! _route=$(wait_online_network "$_kdump_remote_ip"); then -+ return 1 -+ fi - -- _netdev=$(kdump_get_ip_route_field "$_route" "dev") -+ _netdev=$(kdump_get_ip_route_field "$_route" "dev") - -- if ! _kdumpip=$(ip addr show dev "$_netdev" | grep '[ ]*inet'); then -- derror "Failed to get IP of $_netdev" -- return 1 -- fi -+ if ! _kdumpip=$(ip addr show dev "$_netdev" | grep '[ ]*inet'); then -+ derror "Failed to get IP of $_netdev" -+ return 1 -+ fi - -- _kdumpip=$(echo "$_kdumpip" | head -n 1 | awk '{print $2}') -- _kdumpip="${_kdumpip%%/*}" -- HOST_IP=$_kdumpip -+ _kdumpip=$(echo "$_kdumpip" | head -n 1 | awk '{print $2}') -+ _kdumpip="${_kdumpip%%/*}" -+ HOST_IP=$_kdumpip - } - --read_kdump_confs() --{ -- if [ ! -f "$KDUMP_CONFIG_FILE" ]; then -- derror "$KDUMP_CONFIG_FILE not found" -- return -- fi -- -- get_kdump_confs -- -- # rescan for add code for dump target -- while read -r config_opt config_val; do -- # remove inline comments after the end of a directive. -- case "$config_opt" in -- dracut_args) -- config_val=$(get_dracut_args_target "$config_val") -- if [ -n "$config_val" ]; then -- config_val=$(get_mntpoint_from_target "$config_val") -- DUMP_INSTRUCTION="dump_fs $config_val" -- fi -- ;; -- ext[234] | xfs | btrfs | minix | nfs | virtiofs) -- config_val=$(get_mntpoint_from_target "$config_val") -- DUMP_INSTRUCTION="dump_fs $config_val" -- ;; -- raw) -- DUMP_INSTRUCTION="dump_raw $config_val" -- ;; -- ssh) -- DUMP_INSTRUCTION="dump_ssh $SSH_KEY_LOCATION $config_val" -- ;; -- esac -- done < "$KDUMP_CONF_PARSED" -+read_kdump_confs() { -+ if [ ! -f "$KDUMP_CONFIG_FILE" ]; then -+ derror "$KDUMP_CONFIG_FILE not found" -+ return -+ fi -+ -+ get_kdump_confs -+ -+ # rescan for add code for dump target -+ while read -r config_opt config_val; do -+ # remove inline comments after the end of a directive. -+ case "$config_opt" in -+ dracut_args) -+ config_val=$(get_dracut_args_target "$config_val") -+ if [ -n "$config_val" ]; then -+ config_val=$(get_mntpoint_from_target "$config_val") -+ DUMP_INSTRUCTION="dump_fs $config_val" -+ fi -+ ;; -+ ext[234] | xfs | btrfs | minix | nfs | virtiofs) -+ config_val=$(get_mntpoint_from_target "$config_val") -+ DUMP_INSTRUCTION="dump_fs $config_val" -+ ;; -+ raw) -+ DUMP_INSTRUCTION="dump_raw $config_val" -+ ;; -+ ssh) -+ DUMP_INSTRUCTION="dump_ssh $SSH_KEY_LOCATION $config_val" -+ ;; -+ esac -+ done < "$KDUMP_CONF_PARSED" - } - --fence_kdump_notify() --{ -- if [ -n "$FENCE_KDUMP_NODES" ]; then -- # shellcheck disable=SC2086 -- $FENCE_KDUMP_SEND $FENCE_KDUMP_ARGS $FENCE_KDUMP_NODES & -- fi -+fence_kdump_notify() { -+ if [ -n "$FENCE_KDUMP_NODES" ]; then -+ # shellcheck disable=SC2086 -+ $FENCE_KDUMP_SEND $FENCE_KDUMP_ARGS $FENCE_KDUMP_NODES & -+ fi - } - - if [ "$1" = "--error-handler" ]; then -- get_kdump_confs -- do_failure_action -- save_log -- do_final_action -+ get_kdump_confs -+ do_failure_action -+ save_log -+ do_final_action - -- exit $? -+ exit $? - fi - - # continue here only if we have to save dump. - if [ -f /etc/fadump.initramfs ] && [ ! -f /proc/device-tree/rtas/ibm,kernel-dump ] && [ ! -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then -- exit 0 -+ exit 0 - fi - - read_kdump_confs - fence_kdump_notify - - if ! get_host_ip; then -- derror "get_host_ip exited with non-zero status!" -- exit 1 -+ derror "get_host_ip exited with non-zero status!" -+ exit 1 - fi - - if [ -z "$DUMP_INSTRUCTION" ]; then -- DUMP_INSTRUCTION="dump_fs $NEWROOT" -+ DUMP_INSTRUCTION="dump_fs $NEWROOT" - fi - - if ! do_kdump_pre; then -- derror "kdump_pre script exited with non-zero status!" -- do_final_action -- # During systemd service to reboot the machine, stop this shell script running -- exit 1 -+ derror "kdump_pre script exited with non-zero status!" -+ do_final_action -+ # During systemd service to reboot the machine, stop this shell script running -+ exit 1 - fi - make_trace_mem "kdump saving vmcore" '1:shortmem' '2+:mem' '3+:slab' - do_dump - DUMP_RETVAL=$? - - if ! do_kdump_post $DUMP_RETVAL; then -- derror "kdump_post script exited with non-zero status!" -+ derror "kdump_post script exited with non-zero status!" - fi - - save_log - - if [ $DUMP_RETVAL -ne 0 ]; then -- exit 1 -+ exit 1 - fi - - do_final_action -diff --git a/dracut/99kdumpbase/module-setup.sh b/dracut/99kdumpbase/module-setup.sh -index 2dd0b6a..8e0bccc 100755 ---- a/dracut/99kdumpbase/module-setup.sh -+++ b/dracut/99kdumpbase/module-setup.sh -@@ -27,7 +27,7 @@ check() { - return 1 - fi - if [[ "$(uname -m)" == "s390x" ]]; then -- require_binaries chzdev || return 1 -+ require_binaries chzdev || return 1 - fi - return 0 - } -@@ -351,7 +351,7 @@ kdump_install_nm_netif_allowlist() { - - for _netif in $1; do - _per_mac=$(kdump_get_perm_addr "$_netif") -- if [[ "$_per_mac" != 'not set' ]]; then -+ if [[ $_per_mac != 'not set' ]]; then - _except_netif="mac:$_per_mac" - else - _except_netif="interface-name:$_netif" -@@ -384,7 +384,7 @@ _get_hpyerv_physical_driver() { - _get_physical_function_driver() { - local _physfn_dir=/sys/class/net/"$1"/device/physfn - -- if [[ -e "$_physfn_dir" ]]; then -+ if [[ -e $_physfn_dir ]]; then - basename "$(readlink -f "$_physfn_dir"/driver)" - fi - } -@@ -488,14 +488,14 @@ kdump_setup_znet() { - fi - - for _netif in $1; do -- chzdev --export "$_tempfile" --active --by-interface "$_netif" \ -- 2>&1 | ddebug -- sed -i -e 's/^\[active /\[persistent /' "$_tempfile" -- ddebug < "$_tempfile" -- chzdev --import "$_tempfile" --persistent --base "/etc=$initdir/etc" \ -- --yes --no-root-update --force 2>&1 | ddebug -- lszdev --configured --persistent --info --by-interface "$_netif" \ -- --base "/etc=$initdir/etc" 2>&1 | ddebug -+ chzdev --export "$_tempfile" --active --by-interface "$_netif" \ -+ 2>&1 | ddebug -+ sed -i -e 's/^\[active /\[persistent /' "$_tempfile" -+ ddebug < "$_tempfile" -+ chzdev --import "$_tempfile" --persistent --base "/etc=$initdir/etc" \ -+ --yes --no-root-update --force 2>&1 | ddebug -+ lszdev --configured --persistent --info --by-interface "$_netif" \ -+ --base "/etc=$initdir/etc" 2>&1 | ddebug - done - rm -f "$_tempfile" - } -@@ -588,7 +588,7 @@ kdump_install_net() { - local _netifs - - _netifs=$(_get_kdump_netifs) -- if [[ -n "$_netifs" ]]; then -+ if [[ -n $_netifs ]]; then - kdump_install_nmconnections - apply_nm_initrd_generator_timeouts - kdump_setup_znet "$_netifs" -@@ -991,7 +991,6 @@ kdump_install_systemd_conf() { - DefaultTimeoutStartSec=300s - EOF - -- - # Forward logs to console directly, and don't read Kmsg, this avoids - # unneccessary memory consumption and make console output more useful. - # Only do so for non fadump image. -diff --git a/dracut/99kdumpbase/monitor_dd_progress.sh b/dracut/99kdumpbase/monitor_dd_progress.sh -index e139d33..f9b03d5 100755 ---- a/dracut/99kdumpbase/monitor_dd_progress.sh -+++ b/dracut/99kdumpbase/monitor_dd_progress.sh -@@ -2,25 +2,23 @@ - - SRC_FILE_MB=$1 - --while true --do -- DD_PID=`pidof dd` -+while true; do -+ DD_PID=$(pidof dd) - if [ -n "$DD_PID" ]; then - break - fi - done - --while true --do -+while true; do - sleep 5 - if [ ! -d /proc/$DD_PID ]; then - break - fi - - kill -s USR1 $DD_PID -- CURRENT_SIZE=`tail -n 1 /tmp/dd_progress_file | sed "s/[^0-9].*//g"` -+ CURRENT_SIZE=$(tail -n 1 /tmp/dd_progress_file | sed "s/[^0-9].*//g") - [ -n "$CURRENT_SIZE" ] && { -- CURRENT_MB=$(($CURRENT_SIZE / 1048576)) -+ CURRENT_MB=$((CURRENT_SIZE / 1048576)) - echo -e "Copied $CURRENT_MB MB / $SRC_FILE_MB MB\r" - } - done -diff --git a/dracut/99zz-fadumpinit/init-fadump.sh b/dracut/99zz-fadumpinit/init-fadump.sh -index 94a3751..933afc0 100755 ---- a/dracut/99zz-fadumpinit/init-fadump.sh -+++ b/dracut/99zz-fadumpinit/init-fadump.sh -@@ -2,47 +2,47 @@ - export PATH=/usr/bin:/usr/sbin - export SYSTEMD_IN_INITRD=lenient - --[ -e /proc/mounts ] || -- (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc) -+[ -e /proc/mounts ] \ -+ || (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc) - --grep -q '^sysfs /sys sysfs' /proc/mounts || -- (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys) -+grep -q '^sysfs /sys sysfs' /proc/mounts \ -+ || (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys) - - grep -q '^none / ' /proc/mounts || grep -q '^rootfs / ' /proc/mounts && ROOTFS_IS_RAMFS=1 - - if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then -- mkdir /newroot -- mount -t ramfs ramfs /newroot -- -- if [ $ROOTFS_IS_RAMFS ]; then -- for FILE in $(ls -A /fadumproot/); do -- mv /fadumproot/$FILE /newroot/ -- done -- exec switch_root /newroot /init -- else -- mkdir /newroot/sys /newroot/proc /newroot/dev /newroot/run /newroot/oldroot -- -- grep -q '^devtmpfs /dev devtmpfs' /proc/mounts && mount --move /dev /newroot/dev -- grep -q '^tmpfs /run tmpfs' /proc/mounts && mount --move /run /newroot/run -- mount --move /sys /newroot/sys -- mount --move /proc /newroot/proc -- -- cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr /fadumproot/. /newroot/ -- cd /newroot && pivot_root . oldroot -- -- loop=1 -- while [ $loop ]; do -- unset loop -- while read -r _ mp _; do -- case $mp in -- /oldroot/*) umount -d "$mp" && loop=1 ;; -- esac -- done -Date: Tue, 13 Aug 2024 14:49:44 +0200 -Subject: [PATCH 04/16] 99kdumpbase: drop unnecessary 2>&1 - -Bash allows to redirect/pipe the stdout and stderr together using -'&>' and '|&'. Make use of this to simplify the code a little bit. - -Signed-off-by: Philipp Rudo ---- - dracut/99kdumpbase/module-setup.sh | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/dracut/99kdumpbase/module-setup.sh b/dracut/99kdumpbase/module-setup.sh -index 8e0bccc..56215e4 100755 ---- a/dracut/99kdumpbase/module-setup.sh -+++ b/dracut/99kdumpbase/module-setup.sh -@@ -488,14 +488,13 @@ kdump_setup_znet() { - fi - - for _netif in $1; do -- chzdev --export "$_tempfile" --active --by-interface "$_netif" \ -- 2>&1 | ddebug -+ chzdev --export "$_tempfile" --active --by-interface "$_netif" |& ddebug - sed -i -e 's/^\[active /\[persistent /' "$_tempfile" - ddebug < "$_tempfile" - chzdev --import "$_tempfile" --persistent --base "/etc=$initdir/etc" \ -- --yes --no-root-update --force 2>&1 | ddebug -+ --yes --no-root-update --force |& ddebug - lszdev --configured --persistent --info --by-interface "$_netif" \ -- --base "/etc=$initdir/etc" 2>&1 | ddebug -+ --base "/etc=$initdir/etc" |& ddebug - done - rm -f "$_tempfile" - } -@@ -888,7 +887,7 @@ is_localhost() { - get_pcs_fence_kdump_nodes() { - local nodes - -- pcs cluster sync > /dev/null 2>&1 && pcs cluster cib-upgrade > /dev/null 2>&1 -+ pcs cluster sync &> /dev/null && pcs cluster cib-upgrade &> /dev/null - # get cluster nodes from cluster cib, get interface and ip address - nodelist=$(pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -) - --- -2.46.1 - diff --git a/0005-99kdumpbase-fix-shellcheck-warnings.patch b/0005-99kdumpbase-fix-shellcheck-warnings.patch deleted file mode 100644 index 942e6e7..0000000 --- a/0005-99kdumpbase-fix-shellcheck-warnings.patch +++ /dev/null @@ -1,247 +0,0 @@ -From 441843d66d25c8c144caeb5d4aa78b38453295e9 Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 16:01:30 +0200 -Subject: [PATCH 05/16] 99kdumpbase: fix shellcheck warnings - -Fix the shellcheck warnings for 99kdumpbase. With this - - $ shellcheck -x dracut/99kdumpbase/*.sh - -now returns without finding. - -Signed-off-by: Philipp Rudo ---- - dracut/99kdumpbase/kdump.sh | 32 +++++++++++------- - dracut/99kdumpbase/module-setup.sh | 40 +++++++++++++++++++++-- - dracut/99kdumpbase/monitor_dd_progress.sh | 6 ++-- - 3 files changed, 62 insertions(+), 16 deletions(-) - -diff --git a/dracut/99kdumpbase/kdump.sh b/dracut/99kdumpbase/kdump.sh -index 22586b1..dea83ee 100755 ---- a/dracut/99kdumpbase/kdump.sh -+++ b/dracut/99kdumpbase/kdump.sh -@@ -3,8 +3,11 @@ - # The main kdump routine in capture kernel, bash may not be the - # default shell. Any code added must be POSIX compliant. - -+# shellcheck source=/dev/null - . /lib/dracut-lib.sh -+# shellcheck source=SCRIPTDIR/../../kdump-logger.sh - . /lib/kdump-logger.sh -+# shellcheck source=SCRIPTDIR/../../kdump-lib-initramfs.sh - . /lib/kdump-lib-initramfs.sh - - #initiate the kdump logger -@@ -262,11 +265,14 @@ dump_to_rootfs() { - kdump_emergency_shell() { - ddebug "Switching to kdump emergency shell..." - -+ # shellcheck source=/dev/null - [ -f /etc/profile ] && . /etc/profile - export PS1='kdump:${PWD}# ' - -+ # shellcheck source=/dev/null - . /lib/dracut-lib.sh - if [ -f /dracut-state.sh ]; then -+ # shellcheck source=/dev/null - . /dracut-state.sh 2> /dev/null - fi - -@@ -293,16 +299,16 @@ kdump_emergency_shell() { - - do_failure_action() { - dinfo "Executing failure action $FAILURE_ACTION" -- eval $FAILURE_ACTION -+ eval "$FAILURE_ACTION" - } - - do_final_action() { - dinfo "Executing final action $FINAL_ACTION" -- eval $FINAL_ACTION -+ eval "$FINAL_ACTION" - } - - do_dump() { -- eval $DUMP_INSTRUCTION -+ eval "$DUMP_INSTRUCTION" - _ret=$? - - if [ $_ret -ne 0 ]; then -@@ -390,7 +396,7 @@ dump_ssh() { - dinfo "saving to $2:$_ssh_dir" - - cat /var/lib/random-seed > /dev/urandom -- ssh -q $_ssh_opt "$2" mkdir -p "$_ssh_dir" || return 1 -+ ssh -q "$_ssh_opt" "$2" mkdir -p "$_ssh_dir" || return 1 - - save_vmcore_dmesg_ssh "$DMESG_COLLECTOR" "$_ssh_dir" "$_ssh_opt" "$2" - -@@ -402,17 +408,19 @@ dump_ssh() { - save_opalcore_ssh "$_ssh_dir" "$_ssh_opt" "$2" "$_scp_address" - - if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then -- scp -q $_ssh_opt /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete" -+ scp -q "$_ssh_opt" /proc/vmcore "$_scp_address:$_ssh_dir/vmcore-incomplete" - _ret=$? - _vmcore="vmcore" - else -- $CORE_COLLECTOR /proc/vmcore | ssh $_ssh_opt "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'" -+ # shellcheck disable=SC2029 -+ $CORE_COLLECTOR /proc/vmcore | ssh "$_ssh_opt" "$2" "umask 0077 && dd bs=512 of='$_ssh_dir/vmcore-incomplete'" - _ret=$? - _vmcore="vmcore.flat" - fi - - if [ $_ret -eq 0 ]; then -- ssh $_ssh_opt "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'" -+ # shellcheck disable=SC2029 -+ ssh "$_ssh_opt" "$2" "mv '$_ssh_dir/vmcore-incomplete' '$_ssh_dir/$_vmcore'" - _ret=$? - if [ $_ret -ne 0 ]; then - derror "moving vmcore failed, exitcode:$_ret" -@@ -442,12 +450,13 @@ save_opalcore_ssh() { - - dinfo "saving opalcore:$OPALCORE to $3:$1" - -- if ! scp $2 $OPALCORE "$4:$1/opalcore-incomplete"; then -+ if ! scp "$2" "$OPALCORE" "$4:$1/opalcore-incomplete"; then - derror "saving opalcore failed" - return 1 - fi - -- ssh $2 "$3" mv "$1/opalcore-incomplete" "$1/opalcore" -+ # shellcheck disable=SC2029 -+ ssh "$2" "$3" mv "$1/opalcore-incomplete" "$1/opalcore" - dinfo "saving opalcore complete" - return 0 - } -@@ -458,8 +467,9 @@ save_opalcore_ssh() { - # $4: ssh address in @ format - save_vmcore_dmesg_ssh() { - dinfo "saving vmcore-dmesg.txt to $4:$2" -- if $1 /proc/vmcore | ssh $3 "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then -- ssh -q $3 "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" -+ # shellcheck disable=SC2029 -+ if "$1" /proc/vmcore | ssh "$3" "$4" "umask 0077 && dd of='$2/vmcore-dmesg-incomplete.txt'"; then -+ ssh -q "$3" "$4" mv "$2/vmcore-dmesg-incomplete.txt" "$2/vmcore-dmesg.txt" - dinfo "saving vmcore-dmesg.txt complete" - else - derror "saving vmcore-dmesg.txt failed" -diff --git a/dracut/99kdumpbase/module-setup.sh b/dracut/99kdumpbase/module-setup.sh -index 56215e4..70dc8ca 100755 ---- a/dracut/99kdumpbase/module-setup.sh -+++ b/dracut/99kdumpbase/module-setup.sh -@@ -11,12 +11,14 @@ _get_kdump_netifs() { - } - - kdump_module_init() { -+ # shellcheck disable=SC2154 - if ! [[ -d "${initdir}/tmp" ]]; then - mkdir -p "${initdir}/tmp" - fi - - mkdir -p "$_DRACUT_KDUMP_NM_TMP_DIR" - -+ # shellcheck source=SCRIPTDIR/../../kdump-lib.sh - . /lib/kdump/kdump-lib.sh - } - -@@ -38,6 +40,7 @@ depends() { - kdump_module_init - - add_opt_module() { -+ # shellcheck disable=SC2154 - [[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1" - } - -@@ -56,7 +59,7 @@ depends() { - fi - - if is_lvm2_thinp_dump_target; then -- if grep -q lvmthinpool-monitor <<< $(dracut --list-modules); then -+ if grep -q lvmthinpool-monitor <<< "$(dracut --list-modules)"; then - add_opt_module lvmthinpool-monitor - else - dwarning "Required lvmthinpool-monitor modules is missing! Please upgrade dracut >= 057." -@@ -481,12 +484,14 @@ kdump_setup_vlan() { - # setup s390 znet - kdump_setup_znet() { - local _netif -- local _tempfile=$(mktemp --tmpdir="$_DRACUT_KDUMP_NM_TMP_DIR" kdump-dracut-zdev.XXXXXX) -+ local _tempfile - - if [[ "$(uname -m)" != "s390x" ]]; then - return - fi - -+ _tempfile=$(mktemp --tmpdir="$_DRACUT_KDUMP_NM_TMP_DIR" kdump-dracut-zdev.XXXXXX) -+ - for _netif in $1; do - chzdev --export "$_tempfile" --active --by-interface "$_netif" |& ddebug - sed -i -e 's/^\[active /\[persistent /' "$_tempfile" -@@ -830,6 +861,7 @@ kdump_check_iscsi_targets() { - # If our prerequisites are not met, fail anyways. - type -P iscsistart > /dev/null || return 1 - -+ # shellcheck disable=SC2317 - kdump_check_setup_iscsi() { - local _dev - _dev=$1 -@@ -896,6 +928,7 @@ get_pcs_fence_kdump_nodes() { - for node in ${nodelist}; do - # convert $node from 'uname="nodeX"' to 'nodeX' - eval "$node" -+ # shellcheck disable=SC2154 - nodename="$uname" - # Skip its own node name - if is_localhost "$nodename"; then -@@ -910,6 +943,7 @@ get_pcs_fence_kdump_nodes() { - # retrieves fence_kdump args from config file - get_pcs_fence_kdump_args() { - if [[ -f $FENCE_KDUMP_CONFIG_FILE ]]; then -+ # shellcheck disable=SC1090 - . "$FENCE_KDUMP_CONFIG_FILE" - echo "$FENCE_KDUMP_OPTS" - fi -@@ -1013,6 +1047,7 @@ install() { - kdump_install_random_seed - fi - dracut_install -o /etc/adjtime /etc/localtime -+ # shellcheck disable=SC2154 - inst "$moddir/monitor_dd_progress.sh" "/kdumpscripts/monitor_dd_progress.sh" - inst "/bin/dd" "/bin/dd" - inst "/bin/tail" "/bin/tail" -@@ -1031,6 +1066,7 @@ install() { - inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh" - inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh" - inst "$moddir/kdump.sh" "/usr/bin/kdump.sh" -+ # shellcheck disable=SC2154 - inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service" - systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service - # Replace existing emergency service and emergency target -diff --git a/dracut/99kdumpbase/monitor_dd_progress.sh b/dracut/99kdumpbase/monitor_dd_progress.sh -index f9b03d5..f6ed409 100755 ---- a/dracut/99kdumpbase/monitor_dd_progress.sh -+++ b/dracut/99kdumpbase/monitor_dd_progress.sh -@@ -11,15 +11,15 @@ done - - while true; do - sleep 5 -- if [ ! -d /proc/$DD_PID ]; then -+ if [ ! -d /proc/"$DD_PID" ]; then - break - fi - -- kill -s USR1 $DD_PID -+ kill -s USR1 "$DD_PID" - CURRENT_SIZE=$(tail -n 1 /tmp/dd_progress_file | sed "s/[^0-9].*//g") - [ -n "$CURRENT_SIZE" ] && { - CURRENT_MB=$((CURRENT_SIZE / 1048576)) -- echo -e "Copied $CURRENT_MB MB / $SRC_FILE_MB MB\r" -+ printf "Copied %s MB / %s MB\r" "$CURRENT_MB" "$SRC_FILE_MB" - } - done - --- -2.46.1 - diff --git a/0006-99earlykdump-fix-shellcheck-warnings.patch b/0006-99earlykdump-fix-shellcheck-warnings.patch deleted file mode 100644 index 35b39af..0000000 --- a/0006-99earlykdump-fix-shellcheck-warnings.patch +++ /dev/null @@ -1,86 +0,0 @@ -From 1b262cde62fed38f124ed2cdf408ae01de508efc Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 16:12:35 +0200 -Subject: [PATCH 06/16] 99earlykdump: fix shellcheck warnings - -Fix the shellcheck warnings for 99earlykdump. With this - - $ shellcheck -x dracut/99earlykdump/*.sh - -now returns without finding. - -Signed-off-by: Philipp Rudo ---- - dracut/99earlykdump/early-kdump.sh | 5 +++++ - dracut/99earlykdump/module-setup.sh | 5 +++++ - 2 files changed, 10 insertions(+) - -diff --git a/dracut/99earlykdump/early-kdump.sh b/dracut/99earlykdump/early-kdump.sh -index a355010..c56ed82 100755 ---- a/dracut/99earlykdump/early-kdump.sh -+++ b/dracut/99earlykdump/early-kdump.sh -@@ -8,9 +8,13 @@ EARLY_KDUMP_KERNEL="" - EARLY_KDUMP_CMDLINE="" - EARLY_KEXEC_ARGS="" - -+# shellcheck source=/dev/null - . /etc/sysconfig/kdump -+# shellcheck source=/dev/null - . /lib/dracut-lib.sh -+# shellcheck source=SCRIPTDIR/../../kdump-lib.sh - . /lib/kdump-lib.sh -+# shellcheck source=SCRIPTDIR/../../kdump-logger.sh - . /lib/kdump-logger.sh - - # initiate the kdump logger -@@ -41,6 +45,7 @@ early_kdump_load() { - - prepare_parameters - -+ # shellcheck disable=SC2153 - EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") - - # Here, only output the messages, but do not save these messages -diff --git a/dracut/99earlykdump/module-setup.sh b/dracut/99earlykdump/module-setup.sh -index 0451118..98486c5 100755 ---- a/dracut/99earlykdump/module-setup.sh -+++ b/dracut/99earlykdump/module-setup.sh -@@ -1,5 +1,6 @@ - #!/bin/bash - -+# shellcheck source=/dev/null - . /etc/sysconfig/kdump - - KDUMP_KERNEL="" -@@ -19,11 +20,13 @@ depends() { - } - - prepare_kernel_initrd() { -+ # shellcheck source=SCRIPTDIR/../../kdump-lib.sh - . /lib/kdump/kdump-lib.sh - - prepare_kdump_bootinfo - - # $kernel is a variable from dracut -+ # shellcheck disable=SC2154 - if [[ $KDUMP_KERNELVER != "$kernel" ]]; then - dwarn "Using kernel version '$KDUMP_KERNELVER' for early kdump," \ - "but the initramfs is generated for kernel version '$kernel'" -@@ -54,6 +57,7 @@ install() { - inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" - inst_script "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump/kdump-lib-initramfs.sh" - inst_script "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh" -+ # shellcheck disable=SC2154 - inst_hook cmdline 00 "$moddir/early-kdump.sh" - inst_binary "$KDUMP_KERNEL" - inst_binary "$KDUMP_INITRD" -@@ -61,5 +65,6 @@ install() { - ln_r "$KDUMP_KERNEL" "/boot/kernel-earlykdump" - ln_r "$KDUMP_INITRD" "/boot/initramfs-earlykdump" - -+ # shellcheck disable=SC2154 - chmod -x "${initdir}/$KDUMP_KERNEL" - } --- -2.46.1 - diff --git a/0007-99zz-fadumpinit-fix-shellcheck-warnings.patch b/0007-99zz-fadumpinit-fix-shellcheck-warnings.patch deleted file mode 100644 index 8e01643..0000000 --- a/0007-99zz-fadumpinit-fix-shellcheck-warnings.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 3cb964855f508e8aabc91c297d9efc0cab766b0c Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 16:23:26 +0200 -Subject: [PATCH 07/16] 99zz-fadumpinit: fix shellcheck warnings - -Fix the shellcheck warnings for 99zz-fadumpinit. With this - - $ shellcheck -x dracut/99zz-fadumpinit/*.sh - -now returns without finding. - -Signed-off-by: Philipp Rudo ---- - dracut/99zz-fadumpinit/init-fadump.sh | 6 ++---- - dracut/99zz-fadumpinit/module-setup.sh | 2 ++ - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/dracut/99zz-fadumpinit/init-fadump.sh b/dracut/99zz-fadumpinit/init-fadump.sh -index 933afc0..911cf9e 100755 ---- a/dracut/99zz-fadumpinit/init-fadump.sh -+++ b/dracut/99zz-fadumpinit/init-fadump.sh -@@ -14,10 +14,8 @@ if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,o - mkdir /newroot - mount -t ramfs ramfs /newroot - -- if [ $ROOTFS_IS_RAMFS ]; then -- for FILE in $(ls -A /fadumproot/); do -- mv /fadumproot/$FILE /newroot/ -- done -+ if [ "$ROOTFS_IS_RAMFS" ]; then -+ mv /fadumproot/* /newroot/ - exec switch_root /newroot /init - else - mkdir /newroot/sys /newroot/proc /newroot/dev /newroot/run /newroot/oldroot -diff --git a/dracut/99zz-fadumpinit/module-setup.sh b/dracut/99zz-fadumpinit/module-setup.sh -index f062486..8fa5e16 100755 ---- a/dracut/99zz-fadumpinit/module-setup.sh -+++ b/dracut/99zz-fadumpinit/module-setup.sh -@@ -9,7 +9,9 @@ depends() { - } - - install() { -+ # shellcheck disable=SC2154 - mv -f "$initdir/init" "$initdir/init.dracut" -+ # shellcheck disable=SC2154 - inst_script "$moddir/init-fadump.sh" /init - chmod a+x "$initdir/init" - --- -2.46.1 - diff --git a/0008-kdumpctl-fix-shellcheck-warnings.patch b/0008-kdumpctl-fix-shellcheck-warnings.patch deleted file mode 100644 index 15fc95c..0000000 --- a/0008-kdumpctl-fix-shellcheck-warnings.patch +++ /dev/null @@ -1,75 +0,0 @@ -From e7813e45234e615bf5c937b30294c63c4885c5f9 Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Wed, 14 Aug 2024 12:58:17 +0200 -Subject: [PATCH 08/16] kdumpctl: fix shellcheck warnings - -Fix the shellcheck warnings for kdumpctl. With this - - $ $ shellcheck -x kdumpctl - -now returns without finding. - -While at it make use of the special SCRIPTDIR value for source-path. - -Signed-off-by: Philipp Rudo ---- - kdumpctl | 17 ++++++++--------- - 1 file changed, 8 insertions(+), 9 deletions(-) - -diff --git a/kdumpctl b/kdumpctl -index 1b6f7b9..612a159 100755 ---- a/kdumpctl -+++ b/kdumpctl -@@ -33,9 +33,9 @@ if [[ ${__SOURCED__:+x} ]]; then - else - KDUMP_LIB_PATH=/lib/kdump - fi --# shellcheck source=./kdump-lib.sh -+# shellcheck source=SCRIPTDIR/kdump-lib.sh - . $KDUMP_LIB_PATH/kdump-lib.sh --# shellcheck source=./kdump-logger.sh -+# shellcheck source=SCRIPTDIR/kdump-logger.sh - . $KDUMP_LIB_PATH/kdump-logger.sh - - #initiate the kdump logger -@@ -1199,16 +1199,15 @@ get_kernel_size() - check_vmlinux "$img" && get_vmlinux_size "$img" && return 0 - - # That didn't work, so retry after decompression. -- try_decompress '\037\213\010' xy gunzip "$img" "$tmp" || -+ if try_decompress '\037\213\010' xy gunzip "$img" "$tmp" || - try_decompress '\3757zXZ\000' abcde unxz "$img" "$tmp" || - try_decompress 'BZh' xy bunzip2 "$img" "$tmp" || - try_decompress '\135\0\0\0' xxx unlzma "$img" "$tmp" || - try_decompress '\211\114\132' xy 'lzop -d' "$img" "$tmp" || - try_decompress '\002!L\030' xxx 'lz4 -d' "$img" "$tmp" || -- try_decompress '(\265/\375' xxx unzstd "$img" "$tmp" -- -- # Finally check for uncompressed images or objects: -- [[ $? -eq 0 ]] && get_vmlinux_size "$tmp" && return 0 -+ try_decompress '(\265/\375' xxx unzstd "$img" "$tmp"; then -+ get_vmlinux_size "$tmp" && return 0 -+ fi - - # Fallback to use iomem - local _size=0 _seg -@@ -1475,14 +1474,14 @@ reset_crashkernel() - exit 1 - fi - _opt_fadump=${_opt#*=} -- if ! _dump_mode=$(get_dump_mode_by_fadump_val $_opt_fadump); then -+ if ! _dump_mode=$(get_dump_mode_by_fadump_val "$_opt_fadump"); then - derror "failed to determine dump mode" - exit - fi - ;; - --kernel=*) - _val=${_opt#*=} -- if ! _valid_grubby_kernel_path $_val; then -+ if ! _valid_grubby_kernel_path "$_val"; then - derror "Invalid $_opt, please specify a valid kernel path, ALL or DEFAULT" - exit - fi --- -2.46.1 - diff --git a/0009-mkdumprd-fix-shellcheck-warnings.patch b/0009-mkdumprd-fix-shellcheck-warnings.patch deleted file mode 100644 index 64aa8b2..0000000 --- a/0009-mkdumprd-fix-shellcheck-warnings.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 6fca9109dadc087265ccd785fbd60003ea69318c Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 16:29:39 +0200 -Subject: [PATCH 09/16] mkdumprd: fix shellcheck warnings - -Fix the shellcheck warnings for mkdumprd. With this - - $ shellcheck -x mkdumprd - -now returns without finding. - -Signed-off-by: Philipp Rudo ---- - mkdumprd | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/mkdumprd b/mkdumprd -index 27eed5e..7a35217 100644 ---- a/mkdumprd -+++ b/mkdumprd -@@ -11,8 +11,11 @@ if [[ -f /etc/sysconfig/kdump ]]; then - fi - - [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut --. $dracutbasedir/dracut-functions.sh -+# shellcheck source=/dev/null -+. "$dracutbasedir"/dracut-functions.sh -+# shellcheck source=SCRIPTDIR/kdump-lib.sh - . /lib/kdump/kdump-lib.sh -+# shellcheck source=SCRIPTDIR/kdump-logger.sh - . /lib/kdump/kdump-logger.sh - export IN_KDUMP=1 - -@@ -32,6 +35,7 @@ MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" - [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." - MKDUMPRD_TMPMNT="$MKDUMPRD_TMPDIR/target" - -+# shellcheck disable=SC2154 - trap ' - ret=$?; - is_mounted $MKDUMPRD_TMPMNT && umount -f $MKDUMPRD_TMPMNT; -@@ -256,7 +260,7 @@ check_user_configured_target() - verify_core_collector() - { - local _cmd="${1%% *}" -- local _params="${1#${_cmd}}" -+ local _params="${1#"${_cmd}"}" - - if [[ $_cmd != "makedumpfile" ]]; then - if is_raw_dump_target; then --- -2.46.1 - diff --git a/0010-mkfadumprd-fix-shellcheck-warnings.patch b/0010-mkfadumprd-fix-shellcheck-warnings.patch deleted file mode 100644 index 9f577ff..0000000 --- a/0010-mkfadumprd-fix-shellcheck-warnings.patch +++ /dev/null @@ -1,44 +0,0 @@ -From f2e4123828e8b0fd02c87fcc62089ee68891bf7d Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Wed, 14 Aug 2024 12:39:28 +0200 -Subject: [PATCH 10/16] mkfadumprd: fix shellcheck warnings - -Fix the shellcheck warnings for mkfadumprd. With this - - $ shellcheck -x mkfadumprd - -now returns without finding. - -Signed-off-by: Philipp Rudo ---- - mkfadumprd | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/mkfadumprd b/mkfadumprd -index dd6840f..2fd09ad 100755 ---- a/mkfadumprd -+++ b/mkfadumprd -@@ -7,8 +7,11 @@ if [[ -f /etc/sysconfig/kdump ]]; then - fi - - [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut --. $dracutbasedir/dracut-functions.sh -+# shellcheck source=/dev/null -+. "$dracutbasedir"/dracut-functions.sh -+# shellcheck source=SCRIPTDIR/kdump-lib.sh - . /lib/kdump/kdump-lib.sh -+# shellcheck source=SCRIPTDIR/kdump-logger.sh - . /lib/kdump/kdump-logger.sh - - #initiate the kdump logger -@@ -19,6 +22,7 @@ fi - - MKFADUMPRD_TMPDIR="$(mktemp -d -t mkfadumprd.XXXXXX)" - [ -d "$MKFADUMPRD_TMPDIR" ] || perror_exit "mkfadumprd: mktemp -d -t mkfadumprd.XXXXXX failed." -+# shellcheck disable=SC2154 - trap ' - ret=$?; - [[ -d $MKFADUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKFADUMPRD_TMPDIR"; --- -2.46.1 - diff --git a/0011-mkdumprd-simplify-handling-of-dracut-arguments.patch b/0011-mkdumprd-simplify-handling-of-dracut-arguments.patch deleted file mode 100644 index 47f8d3d..0000000 --- a/0011-mkdumprd-simplify-handling-of-dracut-arguments.patch +++ /dev/null @@ -1,136 +0,0 @@ -From f3c33d3d9fdea2ff17e8435306d62c4d3973098a Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 15:11:41 +0200 -Subject: [PATCH 11/16] mkdumprd: simplify handling of dracut arguments - -There are currently three functions to add arguments to dracut. None of -these improve readability or add any other benefit. So remove the -functions and clean up the code a little bit. - -Signed-off-by: Philipp Rudo ---- - mkdumprd | 50 ++++++++++++++++++++------------------------------ - 1 file changed, 20 insertions(+), 30 deletions(-) - -diff --git a/mkdumprd b/mkdumprd -index 7a35217..196f3f8 100644 ---- a/mkdumprd -+++ b/mkdumprd -@@ -29,7 +29,16 @@ SSH_KEY_LOCATION=$DEFAULT_SSHKEY - SAVE_PATH=$(get_save_path) - - extra_modules="" --dracut_args=(--add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict --hostonly-nics '' --aggressive-strip -o "plymouth resume ifcfg earlykdump") -+declare -a dracut_args -+dracut_args+=(--add kdumpbase) -+dracut_args+=(--quiet) -+dracut_args+=(--hostonly) -+dracut_args+=(--hostonly-cmdline) -+dracut_args+=(--hostonly-i18n) -+dracut_args+=(--hostonly-mode strict) -+dracut_args+=(--hostonly-nics '') -+dracut_args+=(--aggressive-strip) -+dracut_args+=(--omit "plymouth resume ifcfg earlykdump") - - MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" - [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." -@@ -46,21 +55,6 @@ trap ' - # clean up after ourselves no matter how we die. - trap 'exit 1;' SIGINT - --add_dracut_arg() --{ -- dracut_args+=("$@") --} -- --add_dracut_mount() --{ -- add_dracut_arg "--mount" "$1" --} -- --add_dracut_sshkey() --{ -- add_dracut_arg "--sshkey" "$1" --} -- - # caller should ensure $1 is valid and mounted in 1st kernel - to_mount() - { -@@ -286,11 +280,7 @@ verify_core_collector() - - add_mount() - { -- local _mnt -- -- _mnt=$(to_mount "$@") || exit 1 -- -- add_dracut_mount "$_mnt" -+ dracut_args+=(--mount "$(to_mount "$@")") || exit 1 - } - - #handle the case user does not specify the dump target explicitly -@@ -353,14 +343,14 @@ while read -r config_opt config_val; do - if [[ -z $_praw ]]; then - exit 1 - fi -- add_dracut_arg "--device" "$_praw" -+ dracut_args+=(--device "$_praw") - check_size raw "$config_val" - ;; - ssh) - if strstr "$config_val" "@"; then - mkdir_save_path_ssh "$config_val" - check_size ssh "$config_val" -- add_dracut_sshkey "$SSH_KEY_LOCATION" -+ dracut_args+=(--sshkey "$SSH_KEY_LOCATION") - else - perror_exit "Bad ssh dump target $config_val" - fi -@@ -375,11 +365,11 @@ while read -r config_opt config_val; do - # because we call dracut with --hostonly-mode strict. So manually install - # nfsv4-related drivers. - if [[ $(get_dracut_args_fstype "$config_val") == nfs* ]]; then -- add_dracut_arg "--add-drivers" nfs_layout_nfsv41_files -+ dracut_args+=(--add-drivers "nfs_layout_nfsv41_files") - fi - - while read -r dracut_arg; do -- add_dracut_arg "$dracut_arg" -+ dracut_args+=("$dracut_arg") - done <<< "$(echo "$config_val" | xargs -n 1 echo)" - ;; - *) ;; -@@ -391,14 +381,14 @@ handle_default_dump_target - - if ! have_compression_in_dracut_args; then - if is_squash_available && dracut_have_option "--squash-compressor"; then -- add_dracut_arg "--squash-compressor" "zstd" -+ dracut_args+=("--squash-compressor" "zstd") - elif has_command zstd; then -- add_dracut_arg "--compress" "zstd" -+ dracut_args+=("--compress" "zstd") - fi - fi - - if [[ -n $extra_modules ]]; then -- add_dracut_arg "--add-drivers" "$extra_modules" -+ dracut_args+=("--add-drivers" "$extra_modules") - fi - - # TODO: The below check is not needed anymore with the introduction of -@@ -411,10 +401,10 @@ if ! is_fadump_capable; then - # so it doesn't affect the logic of check_dump_fs_modified(). - is_dump_to_rootfs && add_mount "$(to_dev_name "$(get_root_fs_device)")" - -- add_dracut_arg "--no-hostonly-default-device" -+ dracut_args+=(--no-hostonly-default-device) - - if fips-mode-setup --is-enabled 2> /dev/null; then -- add_dracut_arg --add-device "$(findmnt -n -o SOURCE --target /boot)" -+ dracut_args+=(--add-device "$(findmnt -n -o SOURCE --target /boot)") - fi - fi - --- -2.46.1 - diff --git a/0012-mkdumprd-drop-extra_modules-variable.patch b/0012-mkdumprd-drop-extra_modules-variable.patch deleted file mode 100644 index 680fc91..0000000 --- a/0012-mkdumprd-drop-extra_modules-variable.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 5f1d411c6c6a2118e368e649f3212a0a6e3b9680 Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 16:38:40 +0200 -Subject: [PATCH 12/16] mkdumprd: drop extra_modules variable - -Add the drivers directly and drop the extra_modules variable. - -Signed-off-by: Philipp Rudo ---- - mkdumprd | 7 +------ - 1 file changed, 1 insertion(+), 6 deletions(-) - -diff --git a/mkdumprd b/mkdumprd -index 196f3f8..e01682d 100644 ---- a/mkdumprd -+++ b/mkdumprd -@@ -28,7 +28,6 @@ fi - SSH_KEY_LOCATION=$DEFAULT_SSHKEY - SAVE_PATH=$(get_save_path) - --extra_modules="" - declare -a dracut_args - dracut_args+=(--add kdumpbase) - dracut_args+=(--quiet) -@@ -328,7 +327,7 @@ while read -r config_opt config_val; do - # remove inline comments after the end of a directive. - case "$config_opt" in - extra_modules) -- extra_modules="$extra_modules $config_val" -+ dracut_args+=(--add-drivers "$config_val") - ;; - ext[234] | xfs | btrfs | minix | nfs | virtiofs) - check_user_configured_target "$config_val" "$config_opt" -@@ -387,10 +386,6 @@ if ! have_compression_in_dracut_args; then - fi - fi - --if [[ -n $extra_modules ]]; then -- dracut_args+=("--add-drivers" "$extra_modules") --fi -- - # TODO: The below check is not needed anymore with the introduction of - # 'zz-fadumpinit' module, that isolates fadump's capture kernel initrd, - # but still sysroot.mount unit gets generated based on 'root=' kernel --- -2.46.1 - diff --git a/0013-99kdumpbase-drop-check-for-lvmthinpool-monitor-modul.patch b/0013-99kdumpbase-drop-check-for-lvmthinpool-monitor-modul.patch deleted file mode 100644 index 243d4e9..0000000 --- a/0013-99kdumpbase-drop-check-for-lvmthinpool-monitor-modul.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 7fb90ad5fa3de5248f2fe9cd37a6af839788ef4d Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 18:52:51 +0200 -Subject: [PATCH 13/16] 99kdumpbase: drop check for lvmthinpool-monitor module - -The lvmthinpool-moitor module was added with dracut 057 but the minimal -required dracut version in the Fedora spec file is dracut >=058. So we -can safely assume that the module is always present. - -Signed-off-by: Philipp Rudo ---- - dracut/99kdumpbase/module-setup.sh | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -diff --git a/dracut/99kdumpbase/module-setup.sh b/dracut/99kdumpbase/module-setup.sh -index 70dc8ca..7508851 100755 ---- a/dracut/99kdumpbase/module-setup.sh -+++ b/dracut/99kdumpbase/module-setup.sh -@@ -59,11 +59,7 @@ depends() { - fi - - if is_lvm2_thinp_dump_target; then -- if grep -q lvmthinpool-monitor <<< "$(dracut --list-modules)"; then -- add_opt_module lvmthinpool-monitor -- else -- dwarning "Required lvmthinpool-monitor modules is missing! Please upgrade dracut >= 057." -- fi -+ add_opt_module lvmthinpool-monitor - fi - - if [[ "$(uname -m)" == "s390x" ]]; then --- -2.46.1 - diff --git a/0014-mkdumprd-drop-check-for-dracut-option-squash-compres.patch b/0014-mkdumprd-drop-check-for-dracut-option-squash-compres.patch deleted file mode 100644 index c701c27..0000000 --- a/0014-mkdumprd-drop-check-for-dracut-option-squash-compres.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 13fc0a77b1b676b172f2bf85f44901b8fd832ab8 Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 17:01:55 +0200 -Subject: [PATCH 14/16] mkdumprd: drop check for dracut option - --squash-compressor - -The option --squash-compressor was introduced with dracut 057 but the -minimal required dracut version in the Fedora spec file is dracut >=058. -So we can safely assume that the option is always present. - -Signed-off-by: Philipp Rudo ---- - kdump-lib.sh | 6 ------ - mkdumprd | 2 +- - 2 files changed, 1 insertion(+), 7 deletions(-) - -diff --git a/kdump-lib.sh b/kdump-lib.sh -index f46c2e9..ba853d9 100755 ---- a/kdump-lib.sh -+++ b/kdump-lib.sh -@@ -58,12 +58,6 @@ has_command() - [[ -x $(command -v "$1") ]] - } - --dracut_have_option() --{ -- local _option=$1 -- ! dracut "$_option" 2>&1 | grep -q "unrecognized option" --} -- - perror_exit() - { - derror "$@" -diff --git a/mkdumprd b/mkdumprd -index e01682d..517ce19 100644 ---- a/mkdumprd -+++ b/mkdumprd -@@ -379,7 +379,7 @@ done <<< "$(kdump_read_conf)" - handle_default_dump_target - - if ! have_compression_in_dracut_args; then -- if is_squash_available && dracut_have_option "--squash-compressor"; then -+ if is_squash_available; then - dracut_args+=("--squash-compressor" "zstd") - elif has_command zstd; then - dracut_args+=("--compress" "zstd") --- -2.46.1 - diff --git a/0015-mkdumprd-explicitly-add-dracut-99squash-module.patch b/0015-mkdumprd-explicitly-add-dracut-99squash-module.patch deleted file mode 100644 index 5f2eb70..0000000 --- a/0015-mkdumprd-explicitly-add-dracut-99squash-module.patch +++ /dev/null @@ -1,111 +0,0 @@ -From 70212dd7796cfe0df6a9fe9e3cb9c7b62231ba33 Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 17:09:32 +0200 -Subject: [PATCH 15/16] mkdumprd: explicitly add dracut 99squash module - -The handling of compression in the initrd currently is a total mess. -There are multiple problems: - -1) It is handled in two different locations, mkdumprd and -99kdumpbase, making the code unnecessarily complex. - -2) While mkdumprd only adds the --squash-compressor option when there is -no compression requested in kdump.conf:dracut_args, 99kdumpbase -unconditionally adds the 99squash module. But once 99squash is added -dracut ignores all compression options passed on the command line and -produces an uncompressed initrd (assuming the compression is done in -the squashfs image). So adding a compression option to dracut_args -will neither compress the initrd nor the squashfs image. - -3) To depend on 99squash, 99kdumpbase only checks whether the required -kernel modules are present but doesn't check whether the -squashfs-tools are installed. This can lead to failures when building -the initrd as 99squash fails to install. At the moment this only -works as the dracut-squash rpm depends on the squashfs-tools. But -once support for erofs is added this might no longer be the case. - -4) In case 99squash cannot be used mkdumprd compresses the initrd with -zstd. But that doesn't really makes sense. For one compressing the -initrd only reduces the on-disk size but not the memory usage during -runtime of the initrd. Plus in case no compression is specified -dracut will automatically compress the initrd. For that it checks for -the 'best' available compression algorithm with zstd being the -default. - -Clean this mess up be moving everything to mkdumprd, only addding -99squash when there is no compression given in the dracut_args, drop -setting the --compress option and, only include 99squash when the -squashfs-tools are installed. - -Note: Only checking the squashfs-tools is sufficient as it doesn't make -sense to have them installed, when the kernel doesn't support squashfs. -There might be a use case to build images that then get used on an other -machine where the kernel supports it. But as the initrd is build with ---hostonly that is no use case we need to consider for kdump. - -Signed-off-by: Philipp Rudo ---- - dracut/99kdumpbase/module-setup.sh | 6 ------ - kdump-lib.sh | 10 ---------- - mkdumprd | 7 +++---- - 3 files changed, 3 insertions(+), 20 deletions(-) - -diff --git a/dracut/99kdumpbase/module-setup.sh b/dracut/99kdumpbase/module-setup.sh -index 7508851..34593e4 100755 ---- a/dracut/99kdumpbase/module-setup.sh -+++ b/dracut/99kdumpbase/module-setup.sh -@@ -44,12 +44,6 @@ depends() { - [[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1" - } - -- if is_squash_available; then -- add_opt_module squash -- else -- dwarning "Required modules to build a squashed kdump image is missing!" -- fi -- - if is_wdt_active; then - add_opt_module watchdog - fi -diff --git a/kdump-lib.sh b/kdump-lib.sh -index ba853d9..c14e75e 100755 ---- a/kdump-lib.sh -+++ b/kdump-lib.sh -@@ -43,16 +43,6 @@ is_sme_or_sev_active() - journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" >/dev/null 2>&1 - } - --is_squash_available() --{ -- local _version kmodule -- -- _version=$(_get_kdump_kernel_version) -- for kmodule in squashfs overlay loop; do -- modprobe -S "$_version" --dry-run $kmodule &> /dev/null || return 1 -- done --} -- - has_command() - { - [[ -x $(command -v "$1") ]] -diff --git a/mkdumprd b/mkdumprd -index 517ce19..366bcdb 100644 ---- a/mkdumprd -+++ b/mkdumprd -@@ -379,10 +379,9 @@ done <<< "$(kdump_read_conf)" - handle_default_dump_target - - if ! have_compression_in_dracut_args; then -- if is_squash_available; then -- dracut_args+=("--squash-compressor" "zstd") -- elif has_command zstd; then -- dracut_args+=("--compress" "zstd") -+ if has_command mksquashfs; then -+ dracut_args+=(--add squash) -+ dracut_args+=(--squash-compressor zstd) - fi - fi - --- -2.46.1 - diff --git a/0016-mkdumprd-add-support-for-95squash-erofs.patch b/0016-mkdumprd-add-support-for-95squash-erofs.patch deleted file mode 100644 index c094f7d..0000000 --- a/0016-mkdumprd-add-support-for-95squash-erofs.patch +++ /dev/null @@ -1,88 +0,0 @@ -From eaf2c3678e20b81134a4411d93aa6699867c079f Mon Sep 17 00:00:00 2001 -From: Philipp Rudo -Date: Tue, 13 Aug 2024 18:31:25 +0200 -Subject: [PATCH 16/16] mkdumprd: add support for 95squash-erofs - -With dracut 104 support for erofs in 99squash was added. For that the -squashfs specific code was split from 99squash module into -95squash-squashfs and a new 95squash-erofs was added. The modules are -structured the way, that you can either add 99squash, which then picks -the 'best' back end, or one of the 95squash-{squashfs,erofs} if you want -to make sure which back end is used. - -Unfortunately erofs doesn't support the same compression algorithms -squashfs supports. So explicitly set which image type we want so we can -set the correct --squash-compressor option. - -Keep support for the old 99squash for the time being so newer versions -of kdump-utils can work with dracut <= 103. - -Signed-off-by: Philipp Rudo ---- - mkdumprd | 29 ++++++++++++++++++++++++++++- - mkfadumprd | 2 +- - 2 files changed, 29 insertions(+), 2 deletions(-) - -diff --git a/mkdumprd b/mkdumprd -index 366bcdb..8c1b191 100644 ---- a/mkdumprd -+++ b/mkdumprd -@@ -54,6 +54,22 @@ trap ' - # clean up after ourselves no matter how we die. - trap 'exit 1;' SIGINT - -+# check whether the given dracut module is installed. If multiple modules are -+# provided return true if any of them is installed. -+has_dracut_module() -+{ -+ local -a _args -+ local _e -+ -+ [[ $# -ge 1 ]] || return 1 -+ -+ for _e in "$@"; do -+ _args+=(-e "$_e") -+ done -+ -+ grep -x -q "${_args[@]}" <<< "$(dracut --list-modules)" -+} -+ - # caller should ensure $1 is valid and mounted in 1st kernel - to_mount() - { -@@ -379,7 +395,18 @@ done <<< "$(kdump_read_conf)" - handle_default_dump_target - - if ! have_compression_in_dracut_args; then -- if has_command mksquashfs; then -+ # With dracut 104 the 99squash module got split up into 99squash and -+ # 95squash-squashfs as well as the new 95squash-erofs. Explicitly set -+ # which image type is required otherwise the requested compression -+ # algorithm might not be supported. -+ if has_dracut_module squash-squashfs && has_command mksquashfs; then -+ dracut_args+=(--add squash-squashfs) -+ dracut_args+=(--squash-compressor zstd) -+ elif has_dracut_module squash-erofs && has_command mkfs.erofs; then -+ dracut_args+=(--add squash-erofs) -+ dracut_args+=(--squash-compressor lz4hc) -+ elif has_command mksquashfs; then -+ # only true for dracut <= 103 - dracut_args+=(--add squash) - dracut_args+=(--squash-compressor zstd) - fi -diff --git a/mkfadumprd b/mkfadumprd -index 2fd09ad..37dc05d 100755 ---- a/mkfadumprd -+++ b/mkfadumprd -@@ -46,7 +46,7 @@ ddebug "rebuild fadump initrd: $FADUMP_INITRD" - # compression ratio and increases the size of the initramfs image. - # Don't compress the capture image as uncompressed image is needed immediately. - # Also, early microcode would not be needed here. --if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs --omit squash --no-compress --no-early-microcode; then -+if ! $MKDUMPRD "$FADUMP_INITRD" -i "$MKFADUMPRD_TMPDIR/fadump.initramfs" /etc/fadump.initramfs --omit squash --omit squash-squashfs --omit squash-erofs --no-compress --no-early-microcode; then - perror_exit "mkfadumprd: failed to build image with dump capture support" - fi - --- -2.46.1 - diff --git a/kdump-utils.spec b/kdump-utils.spec index 4f58947..82bef5f 100644 --- a/kdump-utils.spec +++ b/kdump-utils.spec @@ -1,61 +1,13 @@ # kdump-utils has no debug source %global debug_package %{nil} Name: kdump-utils -Version:1.0.43 -Release: 2%{?dist} +Version:1.0.45 +Release: %autorelease Summary: Kernel crash dump collection utilities License: GPL-2.0-only URL: https://github.com/rhkdump/kdump-utils Source0: https://github.com/rhkdump/kdump-utils/archive/v%{version}/%{name}-%{version}.tar.gz -# editorconfig: set indent_size=8 -# Author: Philipp Rudo -Patch1: 0001-editorconfig-set-indent_size-8.patch -# dracut: create sub-directories for dracut modules -# Author: Philipp Rudo -Patch2: 0002-dracut-create-sub-directories-for-dracut-modules.patch -# dracut/*: fix coding style using shfmt -# Author: Philipp Rudo -Patch3: 0003-dracut-fix-coding-style-using-shfmt.patch -# 99kdumpbase: drop unnecessary 2>&1 -# Author: Philipp Rudo -Patch4: 0004-99kdumpbase-drop-unnecessary-2-1.patch -# 99kdumpbase: fix shellcheck warnings -# Author: Philipp Rudo -Patch5: 0005-99kdumpbase-fix-shellcheck-warnings.patch -# 99earlykdump: fix shellcheck warnings -# Author: Philipp Rudo -Patch6: 0006-99earlykdump-fix-shellcheck-warnings.patch -# 99zz-fadumpinit: fix shellcheck warnings -# Author: Philipp Rudo -Patch7: 0007-99zz-fadumpinit-fix-shellcheck-warnings.patch -# kdumpctl: fix shellcheck warnings -# Author: Philipp Rudo -Patch8: 0008-kdumpctl-fix-shellcheck-warnings.patch -# mkdumprd: fix shellcheck warnings -# Author: Philipp Rudo -Patch9: 0009-mkdumprd-fix-shellcheck-warnings.patch -# mkfadumprd: fix shellcheck warnings -# Author: Philipp Rudo -Patch10: 0010-mkfadumprd-fix-shellcheck-warnings.patch -# mkdumprd: simplify handling of dracut arguments -# Author: Philipp Rudo -Patch11: 0011-mkdumprd-simplify-handling-of-dracut-arguments.patch -# mkdumprd: drop extra_modules variable -# Author: Philipp Rudo -Patch12: 0012-mkdumprd-drop-extra_modules-variable.patch -# 99kdumpbase: drop check for lvmthinpool-monitor module -# Author: Philipp Rudo -Patch13: 0013-99kdumpbase-drop-check-for-lvmthinpool-monitor-modul.patch -# mkdumprd: drop check for dracut option --squash-compressor -# Author: Philipp Rudo -Patch14: 0014-mkdumprd-drop-check-for-dracut-option-squash-compres.patch -# mkdumprd: explicitly add dracut 99squash module -# Author: Philipp Rudo -Patch15: 0015-mkdumprd-explicitly-add-dracut-99squash-module.patch -# mkdumprd: add support for 95squash-erofs -# Author: Philipp Rudo -Patch16: 0016-mkdumprd-add-support-for-95squash-erofs.patch %ifarch ppc64 ppc64le Requires(post): servicelog @@ -180,11 +132,4 @@ fi %doc supported-kdump-targets.txt %changelog -* Mon Sep 30 2024 Lichen Liu - 1.0.43-2 -- Enable erofs support for the kdump initrd - -* Mon Jul 15 2024 Lichen Liu - 1.0.43-1 -- Update to upstream 1.0.43 - -* Tue Oct 24 2023 Coiby - 1.0.42-10 -- split from kexec-tools +%autochangelog diff --git a/sources b/sources index ae3cb93..e785299 100644 --- a/sources +++ b/sources @@ -1,2 +1,3 @@ SHA512 (kdump-utils-1.0.42.tar.gz) = 2d8717a010bfbffd4410ef57ade1402316cda07faa1063631b8665ac273fac618bff0afd9bdc02292c859d956790e06a51d81b141db158957ef97eb8408111c4 SHA512 (kdump-utils-1.0.43.tar.gz) = ede87a85f63f1f08aec477729a2fe7858d78bd21588b00d13c8ce25b6d951bd400a0642bc2ae34c62ebcce54b8b8ff0c7a8d1d867be18217c9b015adc4131707 +SHA512 (kdump-utils-1.0.45.tar.gz) = 4df7136473978cdf80690cb25f1e4a5bde6c6b2e4e99940a06210b4a8e491afb0918a63fc4590fcac2379122fec6e9369e1370ec9ce6fcdbe2e80102e43a023d