[mount] Handle missing configuration keys gracefully
- If a key is missing from mount.conf, don't raise KeyError - If both keys are missing, suggest that mount.conf might be missing instead (a consequence of INSTALL_CONFIG=OFF, for instance). - Simplify code a bit. - Don't bother returning None explicitly.
This commit is contained in:
parent
1def06cfd3
commit
e4d67b5572
@ -124,25 +124,24 @@ def run():
|
||||
"""
|
||||
root_mount_point = tempfile.mkdtemp(prefix="calamares-root-")
|
||||
partitions = libcalamares.globalstorage.value("partitions")
|
||||
extra_mounts = libcalamares.job.configuration["extraMounts"]
|
||||
extra_mounts_efi = libcalamares.job.configuration["extraMountsEfi"]
|
||||
|
||||
# Guard against missing keys (generally a sign that the config file is bad)
|
||||
extra_mounts = libcalamares.job.configuration.get("extraMounts") or []
|
||||
extra_mounts_efi = libcalamares.job.configuration.get("extraMountsEfi") or []
|
||||
if not extra_mounts and not extra_mounts_efi:
|
||||
libcalamares.utils.warning("No extra mounts defined. Does mount.conf exist?")
|
||||
|
||||
# Sort by mount points to ensure / is mounted before the rest
|
||||
partitions.sort(key=lambda x: x["mountPoint"])
|
||||
mount_partitions(root_mount_point, partitions)
|
||||
mount_partitions(root_mount_point, extra_mounts)
|
||||
fw_type = libcalamares.globalstorage.value("firmwareType")
|
||||
|
||||
if fw_type == 'efi':
|
||||
all_extra_mounts = extra_mounts
|
||||
if libcalamares.globalstorage.value("firmwareType") == "efi":
|
||||
mount_partitions(root_mount_point, extra_mounts_efi)
|
||||
all_extra_mounts.extend(extra_mounts_efi)
|
||||
|
||||
libcalamares.globalstorage.insert("rootMountPoint", root_mount_point)
|
||||
|
||||
# Remember the extra mounts for the unpackfs module
|
||||
if fw_type == 'efi':
|
||||
libcalamares.globalstorage.insert(
|
||||
"extraMounts", extra_mounts + extra_mounts_efi)
|
||||
else:
|
||||
libcalamares.globalstorage.insert("extraMounts", extra_mounts)
|
||||
|
||||
return None
|
||||
libcalamares.globalstorage.insert("extraMounts", all_extra_mounts)
|
||||
|
Loading…
Reference in New Issue
Block a user