Upstream grub does not pass to LoadImage the correct path to the
loaded binary. This results in second grub not knowing where it was
loaded from and loading the wrong grub.cfg. If we set "root", then the
path becomes correct.
Currently in mantic, the Ubuntu patch that used to be applied to 2.06
is not applied to 2.12. So we are we are back to upstream behavior.
The common use case for chainloading in EFI with grub (see
30_os-prober) always sets root. So we should do it and not get broken
again.
grub's regexp does not change the store variable if there is no match,
so checking for empty variable after the regexp call was not really
working. Instead, check for successful regexp call.
This commit will help the boot speed on most PC devices and
requested by the Taipei team.
The changes to the auto-generated parts are done via:
```
$ cd boot/assets
$ go build -o ./genasset/genasset ./genasset/
$ ./genasset/genasset -in ./data/grub.cfg -out grub_cfg_asset.go -name grub.cfg
```
and the `Snapd-Boot-Config-Edition` for `grub.cfg` was bumped.
Note that no changes for the recovery grub configuration are done
in this commit. I'm happy to do a follwup for this.
Use different grub binaries in different architectures, by checking
the grub_cfg variable in the grub recovery script. Also, increase the
config edition for grub-recovery.cfg.
Provide the different names for the assets in snapd by using constants
in files tagged for different architectures.
If we chainload in the case of a failed kernel update, we will not be
able to unseal keys from the TMP, as the measurements in the PCR
registers store all the history since we booted so we will get there
unexpected values in the fail case. Instead, reboot so we clean the
PCR registers and we can start the old kernel.
Add fallback entry to grub configuration, so in updates we boot the
previous kernel if the new one fails to be loaded by grub or the
systemd stub. This is needed when failures happen before exitting UEFI
boot services: otherwise we get stuck in a grub menu and a manual
reboot would be needed. The case when the kernel itself fails should
be handled by a hw watchdog.
Also, remove the test for the kernel file so the fallback mechanism
also works when the try-kernel.efi link has not been
created (previously we would get stuck in grub prompt if that
happened).
Update the recovery grub boot config to allow all system labels that are
considered valid by snapd, which are typically just numbers based on date, eg.
20210706 but follow the same rules as model names so hyphen separated
numbers/letters are allowed.
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Add support for snapd_full_cmdline_args variable that carries a set of command
line arguments that shall be used in place of the static and extra ones. Thus
the contents of the new variable effectively become the list of arguments that
directly follows `snapd_recovery_mode=.. snapd_recovery_system=...` in the
kernel command line passed by grub.
The boot config edition is not bumped yet, thus it will not trigger an automatic
boot config update when a new snapd gets installed.
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>