bootloader: Strip prior console settings

Prior to this change, source images could introduce variation in the
the result of the bootloader element results, if the configuration
is changed later which would could re-introduce arguments not desired
which come from the source image.

Since we assert, bsaed upon user supplied input, new console configuration
we now strip the console configuration from /etc/default/grub configuration
before starting to work on putting in place the user's desired end state.

This also ends up helping reduce/remove the possibility of multiple
console elements as some were sourcing from the original source image.

Change-Id: Ia1f9987d989f1d0e1cbda619f7abdf7005b47fbc
This commit is contained in:
Julia Kreger 2024-06-27 08:43:33 -07:00
parent 1d48e5afde
commit abe2a4e239
2 changed files with 17 additions and 0 deletions

View File

@ -87,6 +87,16 @@ if [[ -L $GRUBENV ]]; then
rm -f $GRUBENV
fi
# NOTE(TheJulia): Explicitly strip out embedded console settings
# in the source's grub defaults. This prevents re-introduction later.
# Intentionally matching 'console=ttyS0,115200n8 console=tty0'
# Also globally matches so it can handle 'console=tty0 stuff console=tty1'
# ... and also matches
# 'console=ttyS0,112500n81 console=ttyS1,n8 console=tty0'
if [[ -f /etc/default/grub ]]; then
sed -i 's/\<console=[[:alnum:],]*[[:space:]]*//g' /etc/default/grub
fi
echo "GRUB_DEVICE=LABEL=${DIB_ROOT_LABEL}" >> /etc/default/grub
echo 'GRUB_DISABLE_LINUX_UUID=true' >> /etc/default/grub
echo "GRUB_TIMEOUT=${DIB_GRUB_TIMEOUT:-5}" >>/etc/default/grub

View File

@ -0,0 +1,7 @@
---
fixes:
- |
The ``bootloader`` element now strips prior explicit console settings
from the ``/etc/default/grub`` file, in order to prevent accidential
re-introduction of prior settings when grub configuration is manually
updated later.