From 6a9d9700d454a551f00169f75539fb0c165e6b42 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 28 Jun 2022 23:41:17 +0200 Subject: [PATCH] [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) --- src/modules/grubcfg/main.py | 5 ++++- src/modules/grubcfg/tests/1.global | 3 ++- src/modules/grubcfg/tests/2.global | 1 - src/modules/grubcfg/tests/3.global | 1 - src/modules/grubcfg/tests/4.global | 1 - 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index b992629dd..c9a863ffd 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -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 diff --git a/src/modules/grubcfg/tests/1.global b/src/modules/grubcfg/tests/1.global index 7dedc1527..504931063 100644 --- a/src/modules/grubcfg/tests/1.global +++ b/src/modules/grubcfg/tests/1.global @@ -1,4 +1,5 @@ # SPDX-FileCopyrightText: no # SPDX-License-Identifier: CC0-1.0 --- -bogus: true +branding: + bootloaderEntryName: generic diff --git a/src/modules/grubcfg/tests/2.global b/src/modules/grubcfg/tests/2.global index 31c6f1166..1e01c6b95 100644 --- a/src/modules/grubcfg/tests/2.global +++ b/src/modules/grubcfg/tests/2.global @@ -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 diff --git a/src/modules/grubcfg/tests/3.global b/src/modules/grubcfg/tests/3.global index f9e1e6954..3eda6d5a1 100644 --- a/src/modules/grubcfg/tests/3.global +++ b/src/modules/grubcfg/tests/3.global @@ -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 diff --git a/src/modules/grubcfg/tests/4.global b/src/modules/grubcfg/tests/4.global index 1e8d37fc6..7d4579543 100644 --- a/src/modules/grubcfg/tests/4.global +++ b/src/modules/grubcfg/tests/4.global @@ -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