fadump: add a kernel install hook to clean up fadump initramfs

Resolves: bz2139000
Upstream: Fedora
Conflict: Upstream doesn't have Source37: supported-kdump-targets.txt,
so the number of SourceXX need to be changed.

commit 4a2dcab26ac5ede266449515fc906687728f9ace
Author: Hari Bathini <hbathini@linux.ibm.com>
Date:   Fri Dec 2 18:46:51 2022 +0530

    fadump: add a kernel install hook to clean up fadump initramfs

    Kdump service will create fadump initramfs when needed, but it won't
    clean up the fadump initramfs on kernel uninstall. So create a kernel
    install hook to do the clean up job.

    Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Lichen Liu <lichliu@redhat.com>
This commit is contained in:
Lichen Liu 2022-12-22 13:32:52 +08:00
parent 5b2306b562
commit fb93b28df8
2 changed files with 36 additions and 2 deletions

31
60-fadump.install Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/bash
COMMAND="$1"
KERNEL_VERSION="$2"
if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
exit 0
fi
# Currently, fadump is supported only in environments with
# writable /boot directory.
if [[ ! -w "/boot" ]]; then
exit 0
fi
FADUMP_INITRD="/boot/.initramfs-${KERNEL_VERSION}.img.default"
FADUMP_INITRD_CHECKSUM="$FADUMP_INITRD.checksum"
ret=0
case "$COMMAND" in
add)
# Do nothing, fadump initramfs is strictly host only
# and managed by kdump service
;;
remove)
rm -f -- "$FADUMP_INITRD"
rm -f -- "$FADUMP_INITRD_CHECKSUM"
ret=$?
;;
esac
exit $ret

View File

@ -44,7 +44,8 @@ Source33: 92-crashkernel.install
Source34: crashkernel-howto.txt
Source35: kdump-migrate-action.sh
Source36: kdump-restart.sh
Source37: supported-kdump-targets.txt
Source37: 60-fadump.install
Source38: supported-kdump-targets.txt
#######################################
# These are sources for mkdumpramfs
@ -153,7 +154,7 @@ cp %{SOURCE21} .
cp %{SOURCE26} .
cp %{SOURCE27} .
cp %{SOURCE34} .
cp %{SOURCE37} .
cp %{SOURCE38} .
# Generate kdump.conf file
%{SOURCE8} %{_target_cpu} > kdump.conf
@ -217,6 +218,7 @@ install -m 644 %{SOURCE13} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules
%endif
%ifarch ppc64 ppc64le
install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules
install -m 755 -D %{SOURCE37} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-fadump.install
%endif
install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5
install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service
@ -381,6 +383,7 @@ fi
%endif
%ifarch ppc64 ppc64le
/usr/sbin/mkfadumprd
%{_prefix}/lib/kernel/install.d/60-fadump.install
%endif
/usr/sbin/mkdumprd
/usr/sbin/vmcore-dmesg