Merge pull request #2442 from pentoo/updates20260716

pentoo-updater: simplify efi/grub logic a bit and better handle efi that doesn't contain Pentoo
This commit is contained in:
github-actions[bot] 2025-07-17 01:26:38 +00:00 committed by GitHub
commit dcad6e7d60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -716,46 +716,42 @@ grub_safety_check() {
if [ ! -d /sys/firmware/efi ]; then if [ ! -d /sys/firmware/efi ]; then
# Only efi safety checks are implemented # Only efi safety checks are implemented
return 0 return 0
else fi
efi_uuid="$(efibootmgr -v | grep -i pentoo | awk -F',' '{print $3}')" efi_uuid="$(efibootmgr -v | grep -i pentoo | awk -F',' '{print $3}')"
mount_point="$(findmnt --source PARTUUID="${efi_uuid}" --output TARGET --noheadings)" if [ -z $"{efi_uuid:-}" ]; then
if [ ! -d "${mount_point}" ]; then printf "Unable to find Pentoo listed in the efi. Skipping boot loader updates\n"
printf "Unable to find mounted efi partition, please report this!!!\n" return 0
fi fi
mount_point="$(findmnt --source PARTUUID="${efi_uuid}" --output TARGET --noheadings)"
if [ ! -d "${mount_point}" ]; then
printf "Unable to find mounted efi partition, please report this!!!\n"
fi fi
# https://www.gentoo.org/support/news-items/2024-02-01-grub-upgrades.html # https://www.gentoo.org/support/news-items/2024-02-01-grub-upgrades.html
# https://bugs.gentoo.org/925370 # https://bugs.gentoo.org/925370
if [ ! -f '/boot/grub/grub.cfg' ]; then if [ ! -f '/boot/grub/grub.cfg' ]; then
printf "Unable to find /boot/grub/grub.cfg, unable to safety check your config. Next boot may fail!\n" printf "Unable to find /boot/grub/grub.cfg, unable to safety check your config. Next boot may fail!\n"
return 1 return 1
else fi
if grep -q -- '--is-supported' /boot/grub/grub.cfg; then if grep -q -- '--is-supported' /boot/grub/grub.cfg; then
if [ ! -f '/boot/grub/x86_64-efi/efifwsetup.mod' ]; then if [ ! -f '/boot/grub/x86_64-efi/efifwsetup.mod' ]; then
printf "Unable to find /boot/grub/x86_64-efi/efifwsetup.mod, unable to safety check your config. Next boot may fail!\n" printf "Unable to find /boot/grub/x86_64-efi/efifwsetup.mod, unable to safety check your config. Next boot may fail!\n"
return 1 return 1
fi
if ! strings /boot/grub/x86_64-efi/efifwsetup.mod | grep -q -- '--is-supported'; then
if [ -d "${mount_point}" ] && grub-install --efi-directory="${mount_point}" --recheck; then
printf "Successfully reinstalled grub to fix incompatibility in updated version\n"
else else
if strings /boot/grub/x86_64-efi/efifwsetup.mod | grep -q -- '--is-supported'; then printf "WARNING WARNING WARNING\n"
true printf "NEXT BOOT WILL FAIL\n"
printf "WARNING WARNING WARNING\n"
printf "You MUST reinstall grub before reboot\n"
if [ -d "${mount_point}" ]; then
printf "Required command is 'grub-install --efi-directory=%s --recheck' as root\n" "${mount_point}"
else else
if [ -d "${mount_point}" ] && grub-install --efi-directory="${mount_point}" --recheck; then printf "Required command is 'grub-install --efi-directory=/your_efi_dir_here --recheck' as root\n"
printf "Successfully reinstalled grub to fix incompatibility in updated version\n"
else
printf "WARNING WARNING WARNING\n"
printf "NEXT BOOT WILL FAIL\n"
printf "WARNING WARNING WARNING\n"
printf "You MUST reinstall grub before reboot\n"
if [ -d "${mount_point}" ]; then
printf "Required command is 'grub-install --efi-directory=%s --recheck' as root\n" "${mount_point}"
else
printf "Required command is 'grub-install --efi-directory=/your_efi_dir_here --recheck' as root\n"
fi
return 1
fi
fi fi
return 1
fi fi
else
# This part of the check passes because we didn't find anything broken yet
true
fi fi
fi fi