|
|
|
@ -1641,12 +1641,22 @@ class EFIGRUB(GRUB2):
|
|
|
|
|
|
|
|
|
|
def remove_efi_boot_target(self):
|
|
|
|
|
buf = self.efibootmgr(capture=True)
|
|
|
|
|
bootorder = None
|
|
|
|
|
for line in buf.splitlines():
|
|
|
|
|
try:
|
|
|
|
|
(slot, _product) = line.split(None, 1)
|
|
|
|
|
except ValueError:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
# Workaround for bug in efibootmgr that causes abort() when
|
|
|
|
|
# removing an entry not present in BootOrder.
|
|
|
|
|
# This is already fixed in efibootmgr-0.12, so can be removed when
|
|
|
|
|
# we upgrade it one day
|
|
|
|
|
# The fix (with bug details):
|
|
|
|
|
# https://github.com/rhinstaller/efibootmgr/commit/f575bf87
|
|
|
|
|
if slot == "BootOrder:":
|
|
|
|
|
bootorder = _product
|
|
|
|
|
|
|
|
|
|
if _product == productName:
|
|
|
|
|
slot_id = slot[4:8]
|
|
|
|
|
# slot_id is hex, we can't use .isint and use this regex:
|
|
|
|
@ -1654,6 +1664,11 @@ class EFIGRUB(GRUB2):
|
|
|
|
|
log.warning("failed to parse efi boot slot (%s)", slot)
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if bootorder.count(slot_id) == 0:
|
|
|
|
|
rc = self.efibootmgr("-o", bootorder + "," + slot_id)
|
|
|
|
|
if rc:
|
|
|
|
|
raise BootLoaderError("failed to update BootOrder while removing old boot entry")
|
|
|
|
|
|
|
|
|
|
rc = self.efibootmgr("-b", slot_id, "-B",
|
|
|
|
|
root=ROOT_PATH)
|
|
|
|
|
if rc:
|
|
|
|
|