[mount] Post-merge cleanup of swap enablement

This commit is contained in:
dalto 2023-02-28 18:35:18 -06:00
parent 8e1bd367c4
commit ce6f498358

View File

@ -307,12 +307,14 @@ def mount_partition(root_mount_point, partition, partitions, mount_options, moun
mount_option) != 0:
libcalamares.utils.warning("Cannot mount {}".format(device))
def enable_swap_partition(swap_device):
def enable_swap_partition(devices):
try:
for d in swap_device:
for d in devices:
libcalamares.utils.host_env_process_output(["swapon", d])
except subprocess.CalledProcessError:
raise Exception(_("Failed to swapon " + swap_device))
raise Exception(_(f"Failed to enable swap for devices: {devices}"))
def run():
"""
@ -327,9 +329,10 @@ def run():
return (_("Configuration Error"),
_("No partitions are defined for <pre>{!s}</pre> to use.").format("mount"))
swap_partitions = [p['device'] for p in partitions if ( p['fs'] == 'linuxswap' and p['claimed'] ) ]
if swap_partitions != [] :
enable_swap_partition(swap_partitions)
# Find existing swap partitions that are part of the installation and enable them now
swap_devices = [p['device'] for p in partitions if (p['fs'] == 'linuxswap' and p['claimed'])]
enable_swap_partition(swap_devices)
root_mount_point = tempfile.mkdtemp(prefix="calamares-root-")