Qubes-dist-upgrade breaks when multiple "Qubes" boot menu entries are present

I just learned this the hard way.
For reasons™ I currently have multiple EFI boot entries that contain the text “Qubes”:

Boot0000* Qubes
Boot0001* Qubes 4.0
[...]

During an in-place upgrade with qubes-dist-upgrade, the EFI menu is updated in stage 5 of the update process.
For me, this stage failed with error message “Invalid bootnum value0000\n0001”.

The reason is that the upgrade script searches for the correct boot entry by issuing the command efibootmgr -v | grep "Qubes" | awk '{print $1}'.

In case of multiple matching lines this returns more than one number, causing the error.

Due to my currently broken installation I am unfortunately unable to post this to GitHub. I consider this a bug.

Ouch, that indeed is (too) fragile.
You can fix your system with something like:

efibootmgr -v -b 0000 -u -L Qubes -l /EFI/qubes/grubx64.efi -d /dev/sda -p 1

(adjust 0000 for your current boot entry, and /dev/sda for the disk device)
If your EFI partition was restored to the pre-upgrade state, use xen.efi instead of grubx64.efi above.

For now, I guess you need to rename other entries for the upgrade time… You should be able to retry just this stage.

Copied here: Qubes-dist-upgrade breaks when multiple “Qubes” boot menu entries are present · Issue #7004 · QubesOS/qubes-issues · GitHub

Thank you for filing the GitHub issue.
I already fixed this part of the setup by editing qubes-dist-upgrade to include a head -n1 at the end of the line in question.

Unfortunately, there seems to be another issue with my device and Qubes 4.1 (which is part of the reason why I ended up having two of these boot entries). I will see that I regain access to my Github account and file another issue describing my problems there.

The qubes-dist-upgrade part seems mostly solved, or at least can be worked around with the command given by marmarek until an update of the script is ready.