spec: drop dependency for binutils

Resolves: https://issues.redhat.com/browse/RHEL-138697
Conflict: None

commit 48dd252bf8cc75c696d5d7e9a07efc838e3aad66
Author: Philipp Rudo <prudo@redhat.com>
Date:   Tue Sep 2 13:28:32 2025 +0200

    spec: drop dependency for binutils

    The binutils were added as dependency to support UKIs. With the main
    part of the UKI support been moved to kexec-tools only one spot remains
    in prepare_kdump_bootinfo where they are used. Refractor
    prepare_kdump_bootinfo to get rid of the dependency.

    This slightly changes the behavior for UKIs. In particular the kdump
    initrd is moved from /boot to /var/lib/kdump.

    While at it also simplify the logic in prepare_kdump_bootinfo as it is
    unnecessarily complex and can lead to weird corner cases. For example if
    the default initrd is located at /boot/$machine_id/$kernel_version/initrd
    and the directory is not writable, then the kdump initrd would be stored
    at /var/lib/kdump/initrdkdump without any information about the kernel
    version. This can lead to all sorts of problems when multiple kernel
    versions are installed. Thus always use
    initramfs-${kernel_version}kdump.img when the initrd is stored at
    /var/lib/kdump. Update 60-kdump.install accordingly.

    Signed-off-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Coiby Xu 2026-01-21 10:40:56 +08:00
parent 3aa4c426cd
commit d2f21f374d
4 changed files with 385 additions and 0 deletions

View File

@ -0,0 +1,103 @@
From 9d716888ac9b0a2e47bc6728a74013ade0da072e Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 19 Aug 2025 12:13:40 +0200
Subject: [PATCH] kdumpctl: clean up {backup,restore}_default_initrd
The sha1 algorithm used is no longer considered secure. In addition the
shaXsum commands have a --check option that reads checksums stored in a
file and verifies them. So there is no need for the home grown
verification in restore_default_initrd.
While at it refractor the two functions slightly to increase their
readability and add additional debug messages.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
---
kdumpctl | 54 ++++++++++++++++++++++++++++++++----------------------
1 file changed, 32 insertions(+), 22 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 13f341f..2d2c81a 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -243,19 +243,22 @@ backup_default_initrd()
ddebug "backup default initrd: $DEFAULT_INITRD"
if [[ ! -f $DEFAULT_INITRD ]]; then
+ ddebug "\$DEFAULT_INITRD=$DEFAULT_INITRD does not exist"
return
fi
- if [[ ! -e $DEFAULT_INITRD_BAK ]]; then
- dinfo "Backing up $DEFAULT_INITRD before rebuild."
- # save checksum to verify before restoring
- sha1sum "$DEFAULT_INITRD" > "$INITRD_CHECKSUM_LOCATION"
- if ! cp "$DEFAULT_INITRD" "$DEFAULT_INITRD_BAK"; then
- dwarn "WARNING: failed to backup $DEFAULT_INITRD."
- rm -f -- "$INITRD_CHECKSUM_LOCATION"
- rm -f -- "$DEFAULT_INITRD_BAK"
- fi
+ if [[ -f $DEFAULT_INITRD_BAK ]]; then
+ ddebug "\$DEFAULT_INITRD_BAK=$DEFAULT_INITRD_BAK already exist"
+ return
+ fi
+
+ dinfo "Backing up $DEFAULT_INITRD before rebuild."
+ if ! cp "$DEFAULT_INITRD" "$DEFAULT_INITRD_BAK"; then
+ dwarn "WARNING: failed to backup $DEFAULT_INITRD."
+ rm -f -- "$DEFAULT_INITRD_BAK"
+ return
fi
+ sha512sum "$DEFAULT_INITRD_BAK" > "$INITRD_CHECKSUM_LOCATION"
}
restore_default_initrd()
@@ -263,24 +266,31 @@ restore_default_initrd()
ddebug "restore default initrd: $DEFAULT_INITRD"
if [[ ! -f $DEFAULT_INITRD ]]; then
+ ddebug "\$DEFAULT_INITRD=$DEFAULT_INITRD does not exist"
+ return
+ fi
+
+ if [[ ! -f $DEFAULT_INITRD_BAK ]]; then
+ ddebug "\$DEFAULT_INITRD_BAK=$DEFAULT_INITRD_BAK does not exist"
+ return
+ fi
+
+ if [[ ! -f $INITRD_CHECKSUM_LOCATION ]]; then
+ ddebug "\$INITRD_CHECKSUM_LOCATION=$INITRD_CHECKSUM_LOCATION does not exist"
return
fi
# If a backup initrd exists, we must be switching back from
# fadump to kdump. Restore the original default initrd.
- if [[ -f $DEFAULT_INITRD_BAK ]] && [[ -f $INITRD_CHECKSUM_LOCATION ]]; then
- # verify checksum before restoring
- backup_checksum=$(sha1sum "$DEFAULT_INITRD_BAK" | awk '{ print $1 }')
- default_checksum=$(awk '{ print $1 }' "$INITRD_CHECKSUM_LOCATION")
- if [[ $default_checksum != "$backup_checksum" ]]; then
- dwarn "WARNING: checksum mismatch! Can't restore original initrd.."
- else
- rm -f "$INITRD_CHECKSUM_LOCATION"
- if mv "$DEFAULT_INITRD_BAK" "$DEFAULT_INITRD"; then
- derror "Restoring original initrd as fadump mode is disabled."
- sync -f "$DEFAULT_INITRD"
- fi
- fi
+ if ! sha512sum --status --check "$INITRD_CHECKSUM_LOCATION"; then
+ dwarn "WARNING: checksum mismatch! Can't restore original initrd."
+ return
+ fi
+
+ rm -f "$INITRD_CHECKSUM_LOCATION"
+ if mv "$DEFAULT_INITRD_BAK" "$DEFAULT_INITRD"; then
+ derror "Restoring original initrd as fadump mode is disabled."
+ sync -f "$DEFAULT_INITRD"
fi
}
--
2.52.0

View File

@ -0,0 +1,93 @@
From db47f86cf273a539d803bacc22a9fc825ef5af93 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 19 Aug 2025 12:44:30 +0200
Subject: [PATCH] kdumpctl: add comments to different initrd variables
kdumpctl has multiple variables for different initrds it is using. From
the variable names it is not always clear what the difference of those
initrds are. Thus add some comments to describe the differences and what
the initrds are used for.
While at it rename INITRD_CHECKSUM_LOCATION to DEFAULT_INITRD_CHECKSUM
so it aligns better with the naming convention.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
---
kdumpctl | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 2d2c81a..dd69318 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -7,11 +7,23 @@ KEXEC_ARGS=""
MKDUMPRD="/sbin/mkdumprd -f"
MKFADUMPRD="/sbin/mkfadumprd"
DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt"
+
+# Path to the initrd used for normal boot. Used to determine the naming
+# convention and in case for fadump (and earlykdump) gets rebuild.
DEFAULT_INITRD=""
+
+# Path to backup and checksum of the default initrd. Used to backup/restore the
+# default initrd for fadump.
DEFAULT_INITRD_BAK=""
-INITRD_CHECKSUM_LOCATION=""
+DEFAULT_INITRD_CHECKSUM=""
+
+# Path to the initrd used for kdump
KDUMP_INITRD=""
+
+# Path to the initrd depending on the dump mode. Identical to KDUMP_INITRD for
+# kdump and DEFAULT_INITRD for fadump
TARGET_INITRD=""
+
#kdump shall be the default dump mode
DEFAULT_DUMP_MODE="kdump"
VMCORE_CREATION_STATUS="/var/lib/kdump/vmcore-creation.status"
@@ -258,7 +270,7 @@ backup_default_initrd()
rm -f -- "$DEFAULT_INITRD_BAK"
return
fi
- sha512sum "$DEFAULT_INITRD_BAK" > "$INITRD_CHECKSUM_LOCATION"
+ sha512sum "$DEFAULT_INITRD_BAK" > "$DEFAULT_INITRD_CHECKSUM"
}
restore_default_initrd()
@@ -275,19 +287,19 @@ restore_default_initrd()
return
fi
- if [[ ! -f $INITRD_CHECKSUM_LOCATION ]]; then
- ddebug "\$INITRD_CHECKSUM_LOCATION=$INITRD_CHECKSUM_LOCATION does not exist"
+ if [[ ! -f $DEFAULT_INITRD_CHECKSUM ]]; then
+ ddebug "\$DEFAULT_INITRD_CHECKSUM=$DEFAULT_INITRD_CHECKSUM does not exist"
return
fi
# If a backup initrd exists, we must be switching back from
# fadump to kdump. Restore the original default initrd.
- if ! sha512sum --status --check "$INITRD_CHECKSUM_LOCATION"; then
+ if ! sha512sum --status --check "$DEFAULT_INITRD_CHECKSUM"; then
dwarn "WARNING: checksum mismatch! Can't restore original initrd."
return
fi
- rm -f "$INITRD_CHECKSUM_LOCATION"
+ rm -f "$DEFAULT_INITRD_CHECKSUM"
if mv "$DEFAULT_INITRD_BAK" "$DEFAULT_INITRD"; then
derror "Restoring original initrd as fadump mode is disabled."
sync -f "$DEFAULT_INITRD"
@@ -421,7 +433,7 @@ setup_initrd()
fi
DEFAULT_INITRD_BAK="$KDUMP_BOOTDIR/.$(basename "$DEFAULT_INITRD").default"
- INITRD_CHECKSUM_LOCATION="$DEFAULT_INITRD_BAK.checksum"
+ DEFAULT_INITRD_CHECKSUM="$DEFAULT_INITRD_BAK.checksum"
if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then
TARGET_INITRD="$DEFAULT_INITRD"
--
2.52.0

View File

@ -0,0 +1,186 @@
From 48dd252bf8cc75c696d5d7e9a07efc838e3aad66 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 2 Sep 2025 13:28:32 +0200
Subject: [PATCH] spec: drop dependency for binutils
The binutils were added as dependency to support UKIs. With the main
part of the UKI support been moved to kexec-tools only one spot remains
in prepare_kdump_bootinfo where they are used. Refractor
prepare_kdump_bootinfo to get rid of the dependency.
This slightly changes the behavior for UKIs. In particular the kdump
initrd is moved from /boot to /var/lib/kdump.
While at it also simplify the logic in prepare_kdump_bootinfo as it is
unnecessarily complex and can lead to weird corner cases. For example if
the default initrd is located at /boot/$machine_id/$kernel_version/initrd
and the directory is not writable, then the kdump initrd would be stored
at /var/lib/kdump/initrdkdump without any information about the kernel
version. This can lead to all sorts of problems when multiple kernel
versions are installed. Thus always use
initramfs-${kernel_version}kdump.img when the initrd is stored at
/var/lib/kdump. Update 60-kdump.install accordingly.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
---
60-kdump.install | 24 ++++++++++--------
kdump-lib.sh | 64 +++++++++++++-----------------------------------
kdump-utils.spec | 2 --
3 files changed, 31 insertions(+), 59 deletions(-)
diff --git a/60-kdump.install b/60-kdump.install
index 458adb6..7272a79 100755
--- a/60-kdump.install
+++ b/60-kdump.install
@@ -10,16 +10,19 @@ if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
fi
if [[ -d "$KDUMP_INITRD_DIR_ABS" ]]; then
- KDUMP_INITRD="initrdkdump"
+ KDUMP_INITRD="$KDUMP_INITRD_DIR_ABS/initrdkdump"
else
- # If `KDUMP_BOOTDIR` is not writable, then the kdump
- # initrd must have been placed at `/var/lib/kdump`
- if [[ ! -w "/boot" ]]; then
- KDUMP_INITRD_DIR_ABS="/var/lib/kdump"
- else
- KDUMP_INITRD_DIR_ABS="/boot"
- fi
- KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img"
+ # Usually the initrd is stored besides the kernel image in /boot. But there
+ # are some exceptions when /boot isn't writable or there is no "normal"
+ # initrd, e.g. for UKIs. In those cases the KDUMP_INITRD is stored in
+ # /var/lib/kdump.
+
+ _initrd="initramfs-${KERNEL_VERSION}kdump.img"
+ for dir in "/boot" "/var/lib/kdump"; do
+ [[ -f "$dir/$_initrd" ]] || continue
+ KDUMP_INITRD="$dir/$_initrd"
+ break
+ done
fi
ret=0
@@ -34,7 +37,8 @@ case "$COMMAND" in
echo "Multiple entry types may exist, not removing kdump initrd."
exit 0
fi
- rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD"
+ [[ -n "$KDUMP_INITRD" ]] || exit 0
+ rm -f -- "$KDUMP_INITRD"
ret=$?
;;
esac
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 32e43c6..639256c 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -17,17 +17,6 @@ FADUMP_APPEND_ARGS_SYS_NODE="/sys/kernel/fadump/bootargs_append"
# shellcheck disable=SC2034
FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump"
-is_uki()
-{
- local img
-
- img="$1"
-
- [[ -f $img ]] || return
- [[ "$(objdump -a "$img" 2> /dev/null)" =~ pei-(x86-64|aarch64-little) ]] || return
- objdump -h -j .linux "$img" &> /dev/null
-}
-
is_fadump_capable()
{
# Check if firmware-assisted dump is enabled
@@ -621,7 +610,7 @@ _get_kdump_kernel_version()
#
prepare_kdump_bootinfo()
{
- local boot_initrdlist default_initrd_base var_target_initrd_dir
+ local _initrd
KDUMP_KERNELVER=$(_get_kdump_kernel_version)
KDUMP_KERNEL=$(prepare_kdump_kernel "$KDUMP_KERNELVER")
@@ -632,48 +621,29 @@ prepare_kdump_bootinfo()
fi
# For 64k variant, e.g. vmlinuz-5.14.0-327.el9.aarch64+64k-debug
- if [[ $KDUMP_KERNEL == *"+debug" || $KDUMP_KERNEL == *"64k-debug" ]]; then
+ if [[ ${KDUMP_KERNEL##*+} == ?(64k-)debug ]]; then
dwarn "Using debug kernel, you may need to set a larger crashkernel than the default value."
fi
- # Set KDUMP_BOOTDIR to where kernel image is stored
- if is_uki "$KDUMP_KERNEL"; then
- KDUMP_BOOTDIR=/boot
- else
- KDUMP_BOOTDIR=$(dirname "$KDUMP_KERNEL")
- fi
-
- # Default initrd should just stay aside of kernel image, try to find it in KDUMP_BOOTDIR
- boot_initrdlist="initramfs-$KDUMP_KERNELVER.img initrd"
- for initrd in $boot_initrdlist; do
- if [[ -f "$KDUMP_BOOTDIR/$initrd" ]]; then
- default_initrd_base="$initrd"
- DEFAULT_INITRD="$KDUMP_BOOTDIR/$default_initrd_base"
- break
- fi
+ KDUMP_BOOTDIR="$(dirname "$KDUMP_KERNEL")"
+ for _initrd in "initramfs-$KDUMP_KERNELVER.img" "initrd"; do
+ [[ -f "$KDUMP_BOOTDIR/$_initrd" ]] || continue
+ DEFAULT_INITRD="$KDUMP_BOOTDIR/$_initrd"
+ break
done
- # Create kdump initrd basename from default initrd basename
- # initramfs-5.7.9-200.fc32.x86_64.img => initramfs-5.7.9-200.fc32.x86_64kdump.img
- # initrd => initrdkdump
- if [[ -z $default_initrd_base ]]; then
- kdump_initrd_base=initramfs-${KDUMP_KERNELVER}kdump.img
- elif [[ $default_initrd_base == *.* ]]; then
- kdump_initrd_base=${default_initrd_base%.*}kdump.${DEFAULT_INITRD##*.}
- else
- kdump_initrd_base=${default_initrd_base}kdump
- fi
-
- # Place kdump initrd in $(/var/lib/kdump) if $(KDUMP_BOOTDIR) not writable
- if [[ ! -w $KDUMP_BOOTDIR ]]; then
- var_target_initrd_dir="/var/lib/kdump"
- mkdir -p "$var_target_initrd_dir"
- # shellcheck disable=SC2034 # KDUMP_INITRD is used by kdumpctl
- KDUMP_INITRD="$var_target_initrd_dir/$kdump_initrd_base"
+ # There are cases where $DEFAULT_INITRD can be empty, e.g. for UKIs.
+ if [[ -z $DEFAULT_INITRD ]] || [[ ! -w $KDUMP_BOOTDIR ]]; then
+ local statedir="/var/lib/kdump"
+ mkdir -p "$statedir"
+ _initrd="$statedir/initramfs-${KDUMP_KERNELVER}kdump.img"
+ elif [[ $DEFAULT_INITRD == *.img ]]; then
+ _initrd="${DEFAULT_INITRD/%.img/kdump.img}"
else
- # shellcheck disable=SC2034 # KDUMP_INITRD is used by kdumpctl
- KDUMP_INITRD="$KDUMP_BOOTDIR/$kdump_initrd_base"
+ _initrd="${DEFAULT_INITRD}kdump"
fi
+ # shellcheck disable=SC2034 # KDUMP_INITRD is used by kdumpctl
+ KDUMP_INITRD="$_initrd"
}
get_watchdog_drvs()
diff --git a/kdump-utils.spec b/kdump-utils.spec
index 1d78127..2bfb217 100644
--- a/kdump-utils.spec
+++ b/kdump-utils.spec
@@ -23,8 +23,6 @@ Requires: dracut-squash >= 058
Requires: ethtool
Requires: gawk
Requires: util-linux
-# Needed for UKI support
-Recommends: binutils
Recommends: grubby
Recommends: hostname
BuildRequires: make
--
2.52.0

View File

@ -24,6 +24,9 @@ Patch13: 0013-powerpc-Set-nr_cpus-16-for-kdump-kernel.patch
Patch14: 0014-kexec-kdump-howto.txt-update-paragraphs-related-to-d.patch
Patch15: 0015-kdump-lib-initramfs-Fix-performance-regression-in-kd.patch
Patch16: 0016-sysconfig-use-initramfs_options-to-reduce-memory-usa.patch
Patch17: 0017-kdumpctl-clean-up-backup-restore-_default_initrd.patch
Patch18: 0018-kdumpctl-add-comments-to-different-initrd-variables.patch
Patch19: 0019-spec-drop-dependency-for-binutils.patch
%ifarch ppc64 ppc64le