[grubcfg] Avoid crashes in tests

- remove "bogus" key when it's not needed
- check for existence of "branding" key in GS before
  subscripting it (this happens in tests, where no
  GS contents are loaded, but not in regular use,
  where startup loads the branding data into GS)
This commit is contained in:
Adriaan de Groot 2022-06-28 23:41:17 +02:00
parent 0c79418393
commit 6a9d9700d4
5 changed files with 6 additions and 5 deletions

View File

@ -281,7 +281,10 @@ def run():
partitions = libcalamares.globalstorage.value("partitions")
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
branding = libcalamares.globalstorage.value("branding")
distributor = branding["bootloaderEntryName"]
if branding is None:
distributor = None
else:
distributor = branding["bootloaderEntryName"]
if libcalamares.globalstorage.value("bootLoader") is None and fw_type != "efi":
return None

View File

@ -1,4 +1,5 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
---
bogus: true
branding:
bootloaderEntryName: generic

View File

@ -1,7 +1,6 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
---
bogus: true
firmwareType: bios
bootLoader: grub
rootMountPoint: /tmp/calamares/grubcfg-test-2

View File

@ -1,7 +1,6 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
---
bogus: true
firmwareType: bios
bootLoader: grub
rootMountPoint: /tmp/calamares/grubcfg-test-3

View File

@ -1,7 +1,6 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
---
bogus: true
firmwareType: bios
bootLoader: grub
rootMountPoint: /tmp/calamares/grubcfg-test-4