From 75edd2cb0a89f1df7a376c9c9a4a56264ea06f1f Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Wed, 3 Jul 2024 14:14:20 +0200 Subject: [PATCH] restore: read from backup inventory before unmounting (#150) This fixes a regression introduced in e9d686ae17bfcad5383f2d89d6bf848c3abd9a3b. This is not sufficient however to get Restore to work un UEFI, as setEfiBootEntry() assumes `mounts['efi']` is populated, which is not the case (only `backend.mountVolumes()` would set that). Signed-off-by: Yann Dirson --- restore.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/restore.py b/restore.py index fdd7b596..e884c84b 100644 --- a/restore.py +++ b/restore.py @@ -192,6 +192,11 @@ def restore_partitions(): util.assertDir(os.path.dirname(dst_file)) boot_config.commit(dst_file) + # prepare for boot loader restoration, before unmounting backup_fs + if boot_config.src_fmt == 'grub2' and efi_boot: + branding = util.readKeyValueFile(os.path.join(backup_fs.mount_point, constants.INVENTORY_FILE)) + branding['product-brand'] = branding['PRODUCT_BRAND'] + # repartition if needed backup_fs.unmount() if restore_partitions: @@ -209,8 +214,6 @@ def restore_partitions(): # restore boot loader if boot_config.src_fmt == 'grub2': if efi_boot: - branding = util.readKeyValueFile(os.path.join(backup_fs.mount_point, constants.INVENTORY_FILE)) - branding['product-brand'] = branding['PRODUCT_BRAND'] backend.setEfiBootEntry(mounts, disk_device, boot_partnum, constants.INSTALL_TYPE_RESTORE, branding) else: if location == constants.BOOT_LOCATION_MBR: