20-grub.install: Add variable for per-kernel devicetree setting

In the old days before BLS, setting the GRUB_DEFAULT_DTB variable would
create a devicetree entry for each kernel, which would be prepended by
/dtb-${kernelver}, so it was possible to test a different dtb per
installed kernel.
In the transition to BLS, the variable was kept but the functionality is
now slightly different. The value of GRUB_DEFAULT_DTB goes to the
grubenv and that dtb is loaded from the /dtb symlink instead, which may
change with kernel installs.

This patch introduces a different variable which restores the previous
behavior, and adds the devicetree entry to each BLS entry, if set.
This variable is not set by default in an install, so it does not affect
users with default settings.
It is useful for developers and users of boards with not yet stable
upstream support, where changes to the dtb may cause behavior
difference. In these cases, it is desirable to not pick the dtb of just
the latest installed kernel, but keep previous kernel+dtb choices
unaffected as a fallback.

Signed-off-by: Erico Nunes <ernunes@redhat.com>
This commit is contained in:
Erico Nunes 2024-06-10 20:12:59 +02:00 committed by nfrayer
parent ce0dd8c056
commit d4811852b4

View file

@ -32,6 +32,7 @@ mkbls() {
local debugname=""
local debugid=""
local flavor=""
local devicetree_entry=""
if [[ "$kernelver" == *\+* ]] ; then
local flavor=-"${kernelver##*+}"
@ -41,6 +42,12 @@ mkbls() {
fi
fi
# Define devicetree_entry if the user defined GRUB_DEVICETREE
# in /etc/default/grub, otherwise leave it empty
if [ -n "$GRUB_DEVICETREE" ] ; then
local devicetree_entry="devicetree /dtb-${kernelver}/$GRUB_DEVICETREE"
fi
cat <<EOF
title ${NAME} (${kernelver}) ${VERSION}${debugname}
version ${kernelver}${debugid}
@ -50,6 +57,7 @@ options ${kernelopts}
grub_users \$grub_users
grub_arg --unrestricted
grub_class ${ID}
${devicetree_entry}
EOF
}