From 27013154e5730ddd905b44b3f8c2bb89da110c0f Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Wed, 3 Jul 2024 14:14:20 +0200 Subject: [PATCH 1/2] 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 3da45cc9..39c99361 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: From 9b63a88deda6a2b26fc36068caf54459ab50b676 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Wed, 3 Jul 2024 14:26:37 +0200 Subject: [PATCH 2/2] restore: fix access to ESP partition Commit 29c7bb54201d81b84ec17ddca5328e306173c7a0 introduced assumption that `mounts` has a `esp` key, which was not the case when called from `restoreFromBackup`. This makes sure the key is created. Signed-off-by: Yann Dirson --- restore.py | 1 + 1 file changed, 1 insertion(+) diff --git a/restore.py b/restore.py index 39c99361..392cd0d4 100644 --- a/restore.py +++ b/restore.py @@ -214,6 +214,7 @@ def restore_partitions(): # restore boot loader if boot_config.src_fmt == 'grub2': if efi_boot: + mounts['esp'] = esp backend.setEfiBootEntry(mounts, disk_device, boot_partnum, constants.INSTALL_TYPE_RESTORE, branding) else: if location == constants.BOOT_LOCATION_MBR: