kexec-parse-boot: Trim device specifications from GRUB entries

Some configs specify kernel/initrd paths relative to a device (often
found in a variable).  Assume the device is the /boot partition and
ignore the device specification.

Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
This commit is contained in:
Jonathon Hall 2022-11-10 10:09:16 -05:00
parent e19aadf4cb
commit 2a8a7655d3
No known key found for this signature in database
GPG Key ID: 1E9C3CA91AE25114

View File

@ -94,11 +94,17 @@ grub_entry() {
modules="$modules|module $path"
;;
linux*)
kernel=`echo $trimcmd | cut -d\ -f2`
# Some configs have a device specification in the kernel
# or initrd path. Assume this would be /boot and remove
# it. Keep the '/' following the device, since this
# path is relative to the device root, not the config
# location.
kernel=`echo $trimcmd | sed "s/([^)]*)//g" | cut -d\ -f2`
append=`echo $trimcmd | cut -d\ -f3-`
;;
initrd*)
initrd="$val"
# Trim off device specification as above
initrd="$(echo "$val" | sed "s/([^)]*)//g")"
;;
esac
}