kdump-load: Fix the initrd clean-up

This is not really related to the upstreaming effort, but many
changes happened so it's a lot easier to just add this patch on
top of it.

The issues are two: first, if the kdump directory is empty, the
"find" tool complains, which is harmless but an unnecessary log
pollution. But more important, the second issue is related to
writing the kernel versions file, which was unreliable - we now
fix that by being more explicit in the usage of stdout redirection.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
This commit is contained in:
Guilherme G. Piccoli
2022-08-12 17:26:13 -03:00
parent ecbf6f298f
commit b75eb24298

View File

@ -69,9 +69,10 @@ create_initrd() {
cleanup_unused_initrd() {
INSTALLED_KERNELS="${MOUNT_FOLDER}/.installed_kernels"
find /lib/modules/* -maxdepth 0 -type d -exec basename {} \;>"${INSTALLED_KERNELS}"
find /lib/modules/* -maxdepth 0 -type d -exec basename {} \; 1> "${INSTALLED_KERNELS}"
find "${MOUNT_FOLDER}"/* -name "kdump-initrd*" -type f -print0 | while IFS= read -r -d '' file
find "${MOUNT_FOLDER}"/* -name "kdump-initrd*" -type f -print0 2>/dev/null |\
while IFS= read -r -d '' file
do
FNAME="$(basename "${file}" .img)"
KVER="${FNAME#kdump-initrd-}"