This was lost during cleanup of the branch, where the usage
of grub-mkdevicemap was dropped - original code created a
list of disks, and then iterated over those disks, and all
partitions, finding the ones matching belonging to the disk;
it did that because it was grouping partitions by disk - which
does not make sense here, as disks are not suitable install
devices by themselves.
Looking at postinst.in, it matched a parition to a disk by
doing:
if [ "${partition_id#$disk_id-part}" != "$partition_id" ]; then
aka, it stripped the disk id and "-part" from the partition and
checked that this did something.
This means we can still easily get the device ($disk-id): we
just strip of "-part*" at the end.
We also run grub-multi-install from shim-signed and
grub-efi-amd64-signed, but duplicating the logic everywhere
would get slightly nasty.
So, let's rework this so that it does not rely on a version
we are upgrading from and instead checks if grub-efi/install_devices
is empty _AND_ we have not seen the question yet, which should
prompt in the same instances.
Then move the whole thing into grub-multi-install, so that
all postinst make use of it automatically.
In case there are a lot of zfs snapshots, we end up with a huge delay
when navigating grub (eg 80 seconds, displaying a black screen, for 100
system snapshots).
Reduce the grub.cfg file size by moving the entries in a single
function with parameter instead of duplicating each entry.
Ensure the user can still easily edit them easily by naming the
parameters.
UBUNTU: efivar: Correctly handle boot order of multiple ESPs
Modify the code to insert the ESP mounted to /boot/efi (the *primary*
ESP) as the first item, but any other ESP after any other of _our_
ESPs.
So assume we have three ESPs A, B, C (_ours_), and three other
boot entries X, Y, Z. We configure A, B, and C in that order,
though some might already be in it, some examples:
XYZ -> ABCXYZ (A is added to front, B after it, C after B)
BXCYZ -> ABXCYZ (A is added to front, B and C remain unchanged)
AXCYZ -> AXCBYZ (the previously unconfigured ESP B is added after last ESP C)
Doing this requires us passing the path of the ESP directory down to
the code doing the install, so it can then check whether it was the
primary ESP - that is, mounted to /boot/efi - or not.
This is an ugly hack to get resilient boot somewhat working:
We pass in a list of all ESPS in _UBUNTU_ALTERNATIVE_ESPS, and
then we ignore those when looking for entries to change/remove.
ubuntu: Update the linux boot protocol version check.
The EFI implementation of grub_cmd_linux makes use of xloadflags which was
introduced in to version 2.12 of the kernel's boot protocol, so update the
check accordingly.
ubuntu: Make the linux command in EFI grub always try EFI handover
The previous implementation only boots via the EFI handover protocol when
secure boot is enabled. This means that disabling secure boot breaks some
features that depend on the kernel being booted via the EFI handover entry
point, such as retrieval of the TCG event log.
Update the linux command to always attempt to defer to linuxefi in EFI grub
builds, regardless of whether secure boot is enabled or not. This also allows
a fallback to the non-EFI handover path on kernels that don't support it, but
only if secure boot is disabled.
smbios: Add a --linux argument to apply linux modalias-like filtering
Linux creates modalias strings by filtering out non-ASCII, space,
and colon characters. Provide an option that does the same filtering
so people can create a modalias string in GRUB, and then match their
modalias patterns against it.