From 0f4c895b95e2531f2a17e06259638ca533112945 Mon Sep 17 00:00:00 2001 From: John Chittum Date: Fri, 8 Sep 2023 08:36:14 -0500 Subject: [PATCH] fix: GRUB_DISTRIBUTOR and grub install rectification LP: 2034253 and LP: 2027686 both deal with buildd vm images failing to boot when removing `--removable` and the stanzas copying EFI around. We need to remove those stanzas for launchpad builder compatibility. even though focal and jammy weren't failing, keeping everything aligned is important. LP: 2034253 further showed that GRUB_DISTRIBUTOR being set by default in grub requires lsb_release, which isn't in buildd images. That's the root of why removing the stanzas failed. Since the only image we know of where this bug is hit with grub is buildd (because everything else has lsb_release), rather than adding a new dependency into buildd, or backporting grub if we don't need to, setting GRUB_DISTRIBUTOR in the buildd hook solves the immediate issue --- .../buildd/hooks/02-disk-image-uefi.binary | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/live-build/buildd/hooks/02-disk-image-uefi.binary b/live-build/buildd/hooks/02-disk-image-uefi.binary index 280db0ab..3217a956 100755 --- a/live-build/buildd/hooks/02-disk-image-uefi.binary +++ b/live-build/buildd/hooks/02-disk-image-uefi.binary @@ -98,39 +98,30 @@ install_grub() { # snap listings) chroot mountpoint dpkg-query -W > binary/boot/filesystem.packages + cat > mountpoint/etc/default/grub.d/50-builddimg-settings.cfg << EOF +GRUB_DEFAULT=0 +GRUB_HIDDEN_TIMEOUT=0.1 +GRUB_HIDDEN_TIMEOUT_QUIET=true +GRUB_TIMEOUT=0.1 +GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0" +GRUB_RECORDFAIL_TIMEOUT=0 +GRUB_TERMINAL=console +GRUB_DISTRIBUTOR=Ubuntu +EOF + chroot mountpoint grub-install "${loop_device}" \ --boot-directory=/boot \ --efi-directory=/boot/efi \ --target=${efi_target} \ - --removable \ --uefi-secure-boot \ --no-nvram - if [ -f mountpoint/boot/efi/EFI/BOOT/grub.cfg ]; then - sed -i "s| root| root hd0,gpt1|" mountpoint/boot/efi/EFI/BOOT/grub.cfg - sed -i "1i${IMAGE_STR}" mountpoint/boot/efi/EFI/BOOT/grub.cfg - # For some reason the grub disk is looking for /boot/grub/grub.cfg on - # part 15.... - chroot mountpoint mkdir -p /boot/efi/boot/grub - chroot mountpoint cp /boot/efi/EFI/BOOT/grub.cfg /boot/efi/boot/grub - fi - if [ "$ARCH" = "amd64" ]; then # Install the BIOS/GPT bits. Since GPT boots from the ESP partition, # it means that we just run this simple command and we're done chroot mountpoint grub-install --target=i386-pc "${loop_device}" fi - cat > mountpoint/etc/default/grub.d/50-builddimg-settings.cfg << EOF -GRUB_DEFAULT=0 -GRUB_HIDDEN_TIMEOUT=0.1 -GRUB_HIDDEN_TIMEOUT_QUIET=true -GRUB_TIMEOUT=0.1 -GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0" -GRUB_RECORDFAIL_TIMEOUT=0 -GRUB_TERMINAL=console -EOF - divert_grub mountpoint chroot mountpoint update-grub replace_grub_root_with_label mountpoint