Browse Source

test(grub): Fix incorrectly generated test images.

Because the shim has hardcoded paths for each distribution, it is
better to use the `grub-install --removable` argument to install into
`/EFI/BOOT` than to do it ourselves. This makes sure that all files
are present and loaded from correct locations.

The symptom before this change was that the shim could not find the
grubx64.efi file, which is because we were not installing it
correctly. So in fact the image would not boot, even though it would
boot after a Mender conversion.

Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>
automatic_bootstrap_artifact
Kristian Amlie 3 years ago
parent
commit
69da759609
No known key found for this signature in database GPG Key ID: F464407C996AF03F
  1. 19
      scripts/test/generate-image.sh

19
scripts/test/generate-image.sh

@ -82,8 +82,6 @@ post_process_image() {
regenerate_grub_live "$image"
mount ${LO_DEVICE}p1 tmp-p1
mount ${LO_DEVICE}p2 tmp-p2
post_tweaks tmp-p1 tmp-p2
}
pre_tweaks() {
@ -107,21 +105,6 @@ EOF
sed -E -i -e 's/^#? *PermitRootLogin .*/PermitRootLogin yes/' $root/etc/ssh/sshd_config
}
post_tweaks() {
local -r boot="$1"
local -r root="$2"
# Delete systemd-boot, which isn't normally present in images that were
# installed with OS installers, at least not at the time of writing.
rm -rf "$boot/EFI/systemd"
# Also replace bootx64.efi, which is the default bootloader. Mkosi installs
# systemd-bootx86.efi, but we want the shim.
rm -f "$boot/EFI/BOOT/*"
mkdir -p "$boot/EFI/BOOT"
cp "$root/usr/lib/shim/shimx64.efi.signed" "$boot/EFI/BOOT/BOOTX64.EFI"
}
# Unfortunately installing grub scripts is something which is not really
# possible when offline. This is something which is easier with systemd-boot, so
# longterm GRUB will probably follow, or systemd-boot will take over. Anyway,
@ -136,7 +119,7 @@ Description=Regenerate grub scripts, disable itself and then shut down.
[Service]
Type=oneshot
ExecStart=sh -c "grub-install && update-grub && systemctl disable mender-regenerate-grub-and-shutdown.service && poweroff"
ExecStart=sh -c "grub-install && grub-install --removable && update-grub && systemctl disable mender-regenerate-grub-and-shutdown.service && poweroff"
EOF
ln -sf "$root/etc/systemd/system/mender-regenerate-grub-and-shutdown.service" "$root/etc/systemd/system/multi-user.target.wants/"

Loading…
Cancel
Save