mirror of
https://github.com/linuxboot/heads.git
synced 2025-01-30 08:03:55 +00:00
Merge pull request #1240 from JonathonHall-Purism/boot-ignore-grub-device
Ignore grub device specs in boot entry paths
This commit is contained in:
commit
aa0b3e94f8
@ -28,30 +28,52 @@ fix_path() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# GRUB kernel lines (linux/multiboot) can include a command line. Check whether
|
||||||
|
# the file path exists in $bootdir.
|
||||||
|
check_path() {
|
||||||
|
local checkpath firstval
|
||||||
|
checkpath="$1"
|
||||||
|
firstval="$(echo "$checkpath" | cut -d\ -f1)"
|
||||||
|
if ! [ -r "$bootdir$firstval" ]; then return 1; fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
echo_entry() {
|
echo_entry() {
|
||||||
if [ "$kexectype" = "elf" ]; then
|
|
||||||
if [ -z "$kernel" ]; then return; fi
|
if [ -z "$kernel" ]; then return; fi
|
||||||
|
|
||||||
fix_path $kernel
|
fix_path $kernel
|
||||||
|
# The kernel must exist - if it doesn't, ignore this entry, it
|
||||||
|
# wouldn't work anyway. This could happen if there was a
|
||||||
|
# GRUB variable in the kernel path, etc.
|
||||||
|
if ! check_path "$path"; then return; fi
|
||||||
entry="$name|$kexectype|kernel $path"
|
entry="$name|$kexectype|kernel $path"
|
||||||
|
|
||||||
|
case "$kexectype" in
|
||||||
|
elf)
|
||||||
if [ -n "$initrd" ]; then
|
if [ -n "$initrd" ]; then
|
||||||
for init in $(echo $initrd | tr ',' ' '); do
|
for init in $(echo $initrd | tr ',' ' '); do
|
||||||
fix_path $init
|
fix_path $init
|
||||||
|
# The initrd must also exist
|
||||||
|
if ! check_path "$path"; then return; fi
|
||||||
entry="$entry|initrd $path"
|
entry="$entry|initrd $path"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [ -n "$append" ]; then
|
if [ -n "$append" ]; then
|
||||||
entry="$entry|append $append"
|
entry="$entry|append $append"
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
multiboot|xen)
|
||||||
|
entry="$entry$modules"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Double-expand here in case there are variables in the kernel
|
||||||
|
# parameters - some configs do this and can boot with empty
|
||||||
|
# expansions (Debian Live ISOs use this for loopback boots)
|
||||||
echo $(eval "echo \"$entry\"")
|
echo $(eval "echo \"$entry\"")
|
||||||
fi
|
|
||||||
if [ "$kexectype" = "multiboot" -o "$kexectype" = "xen" ]; then
|
|
||||||
if [ -z "$kernel" ]; then return; fi
|
|
||||||
|
|
||||||
fix_path $kernel
|
|
||||||
echo $(eval "echo \"$name|$kexectype|kernel $path$modules\"")
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
search_entry() {
|
search_entry() {
|
||||||
@ -94,11 +116,17 @@ grub_entry() {
|
|||||||
modules="$modules|module $path"
|
modules="$modules|module $path"
|
||||||
;;
|
;;
|
||||||
linux*)
|
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-`
|
append=`echo $trimcmd | cut -d\ -f3-`
|
||||||
;;
|
;;
|
||||||
initrd*)
|
initrd*)
|
||||||
initrd="$val"
|
# Trim off device specification as above
|
||||||
|
initrd="$(echo "$val" | sed "s/([^)]*)//g")"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user