kdump-lib: Drop 'file' dependency in is_uki

Resolves: RHEL-46776

commit 2f21fa2acfac9f6e19e071330f917e60aafc4600
Author: Philipp Rudo <prudo@redhat.com>
Date:   Mon Jun 24 17:34:35 2024 +0200

    kdump-lib: Drop 'file' dependency in is_uki

    The 'file' utility is no longer installed per default. In addition there
    was an update to it so it now reports the file type as
    application/vnd.microsoft.portable-executable. Thus fall back to use
    objdump to avoid adding yet an other dependency for kdump-utils and deal
    with different versions of 'file'.

    Note: This has the small drawback that objdump is arch specific. I.e.
    examining a aarch64 UKI on a x86_64 machine will return an 'file format
    not recognized' error.

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

Signed-off-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
Philipp Rudo 2024-07-09 15:39:32 +02:00
parent 5e77777a6b
commit 71ff08fc9d
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,36 @@
From efc06f21a5b1b3a30ce438c15ce4a07fdfdd2440 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Mon, 24 Jun 2024 17:34:35 +0200
Subject: [PATCH 7/7] kdump-lib: Drop 'file' dependency in is_uki
The 'file' utility is no longer installed per default. In addition there
was an update to it so it now reports the file type as
application/vnd.microsoft.portable-executable. Thus fall back to use
objdump to avoid adding yet an other dependency for kdump-utils and deal
with different versions of 'file'.
Note: This has the small drawback that objdump is arch specific. I.e.
examining a aarch64 UKI on a x86_64 machine will return an 'file format
not recognized' error.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
kdump-lib.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 35f0ac9..13e16e3 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -18,7 +18,7 @@ is_uki()
img="$1"
[[ -f "$img" ]] || return
- [[ "$(file -b --mime-type "$img")" == application/x-dosexec ]] || return
+ [[ "$(objdump -a "$img" 2> /dev/null)" =~ pei-(x86-64|aarch64-little) ]] || return
objdump -h -j .linux "$img" &> /dev/null
}
--
2.45.2

View File

@ -71,6 +71,7 @@ Patch615: 0003-kdumpctl-Simplify-fadump-handling-in-reset_crashkern.patch
Patch616: 0004-kdumpctl.8-Add-description-to-reset-crashkernel-rebo.patch Patch616: 0004-kdumpctl.8-Add-description-to-reset-crashkernel-rebo.patch
Patch617: 0005-dracut-kdump.sh-Save-kexec-dmesg.log-after-failure_a.patch Patch617: 0005-dracut-kdump.sh-Save-kexec-dmesg.log-after-failure_a.patch
Patch618: 0006-Makefile-Fix-early-kdump-file-names.patch Patch618: 0006-Makefile-Fix-early-kdump-file-names.patch
Patch619: 0007-kdump-lib-Drop-file-dependency-in-is_uki.patch
%description %description
kexec-tools provides /sbin/kexec binary that facilitates a new kexec-tools provides /sbin/kexec binary that facilitates a new
@ -172,6 +173,7 @@ tar -z -x -v -f %{SOURCE19}
%patch 616 -p1 -d kdump-utils-%{kdump_utils_ver} %patch 616 -p1 -d kdump-utils-%{kdump_utils_ver}
%patch 617 -p1 -d kdump-utils-%{kdump_utils_ver} %patch 617 -p1 -d kdump-utils-%{kdump_utils_ver}
%patch 618 -p1 -d kdump-utils-%{kdump_utils_ver} %patch 618 -p1 -d kdump-utils-%{kdump_utils_ver}
%patch 619 -p1 -d kdump-utils-%{kdump_utils_ver}
%ifarch ppc %ifarch ppc
%define archdef ARCH=ppc %define archdef ARCH=ppc