From 6d1fdf2446f84b4686089e8b95457da43490b027 Mon Sep 17 00:00:00 2001 From: Steve McIntyre Date: Sat, 26 Nov 2022 01:45:26 +0000 Subject: [PATCH] Change how we find the installer when booting via grub-efi instead of looking for the .disk/info file, use .disk/id/$UUID instead. Closes: #1024346, #1024720. --- debian/changelog | 3 +++ tools/boot/bookworm/boot-arm64 | 2 ++ tools/boot/bookworm/boot-armhf | 2 ++ tools/boot/bookworm/boot-hurd-common | 2 ++ tools/boot/bookworm/boot-ia64 | 2 ++ tools/boot/bookworm/boot-x86 | 2 ++ tools/boot/bookworm/common.sh | 14 ++++++++++++++ 7 files changed, 27 insertions(+) diff --git a/debian/changelog b/debian/changelog index 5564a6b6..c1b405dd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,9 @@ debian-cd (3.1.36) UNRELEASED; urgency=medium to look for non-free packages. * Add a Contents-firmware file to help with looking up firmware packages in d-i. + * Change how we find the installer when booting via grub-efi: + instead of looking for the .disk/info file, use .disk/id/$UUID + instead. Closes: #1024346, #1024720. [ Cyril Brulebois ] * generate_firmware_patterns: Drop support for the temporary --test diff --git a/tools/boot/bookworm/boot-arm64 b/tools/boot/bookworm/boot-arm64 index 2a1ab7f6..2ddd70c1 100755 --- a/tools/boot/bookworm/boot-arm64 +++ b/tools/boot/bookworm/boot-arm64 @@ -91,6 +91,8 @@ if [ -d boot$N/grub ] ; then mv boot$N/grub/* $CDDIR/boot/grub/ rmdir boot$N/grub + change_grub_cfg_uuid $CDDIR + # Stuff the EFI boot files into a FAT filesystem, making it as # small as possible. We end up re-packing like this in case we're # making a multi-arch image diff --git a/tools/boot/bookworm/boot-armhf b/tools/boot/bookworm/boot-armhf index 0218d1d0..62bbebab 100755 --- a/tools/boot/bookworm/boot-armhf +++ b/tools/boot/bookworm/boot-armhf @@ -90,6 +90,8 @@ if [ -d boot$N/grub ] ; then mv boot$N/grub/* $CDDIR/boot/grub/ rmdir boot$N/grub + change_grub_cfg_uuid $CDDIR + # Stuff the EFI boot files into a FAT filesystem, making it as # small as possible. We end up re-packing like this in case we're # making a multi-arch image diff --git a/tools/boot/bookworm/boot-hurd-common b/tools/boot/bookworm/boot-hurd-common index 16c34d60..fcc000b9 100644 --- a/tools/boot/bookworm/boot-hurd-common +++ b/tools/boot/bookworm/boot-hurd-common @@ -134,6 +134,8 @@ if [ $BOOT_EFI -ne 0 ] ; then mv boot$N/grub/* $CDDIR/boot/grub/ rmdir boot$N/grub + change_grub_cfg_uuid $CDDIR + # Stuff the EFI boot files into a FAT filesystem, making it as # small as possible. We end up re-packing like this in case we're # making a multi-arch image diff --git a/tools/boot/bookworm/boot-ia64 b/tools/boot/bookworm/boot-ia64 index 0d4d2f99..4121e6fa 100755 --- a/tools/boot/bookworm/boot-ia64 +++ b/tools/boot/bookworm/boot-ia64 @@ -87,6 +87,8 @@ if [ -d boot$N/grub ] ; then mv boot$N/grub/* $CDDIR/boot/grub/ rmdir boot$N/grub + change_grub_cfg_uuid $CDDIR + # Stuff the EFI boot files into a FAT filesystem, making it as # small as possible. We end up re-packing like this in case we're # making a multi-arch image diff --git a/tools/boot/bookworm/boot-x86 b/tools/boot/bookworm/boot-x86 index e77b8c5c..bd87a929 100644 --- a/tools/boot/bookworm/boot-x86 +++ b/tools/boot/bookworm/boot-x86 @@ -456,6 +456,8 @@ if [ -d boot$N/isolinux/grub ] && [ $BOOT_EFI -ne 0 ] ; then NUM_ENTRIES=$(grep menuentry $CDDIR/boot/grub/grub.cfg | wc -l) echo " CD$N/boot/grub/grub.cfg has $NUM_ENTRIES boot entries defined" + change_grub_cfg_uuid $CDDIR + # Stuff the EFI boot files into a FAT filesystem, making it as # small as possible. We end up re-packing like this in case we're # making a multi-arch image diff --git a/tools/boot/bookworm/common.sh b/tools/boot/bookworm/common.sh index 6433f258..0499b45d 100644 --- a/tools/boot/bookworm/common.sh +++ b/tools/boot/bookworm/common.sh @@ -248,3 +248,17 @@ install_firmwares_initrd () { fi fi } + +change_grub_cfg_uuid () { + CDDIR=$1 + + # We (used to) look for /.disk/info in grub.cfg to find this + # Debian media once we've booted via EFI. This is not 100% + # reliable - see #1024346 and #1024720 for examples where this + # fails. Instead, let's generate a UUID here and use that as a + # flag file. + UUID=$(uuidgen) + mkdir -p $CDDIR/.disk/id + touch $CDDIR/.disk/id/$UUID + sed -i "/search --file --set=root/s,.disk/info,.disk/id/$UUID," $CDDIR/EFI/debian/grub.cfg +}