From 12b5e2e4e9537fbae0ec21ced9d21482b29610d3 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 26 Apr 2022 13:17:40 +0200 Subject: Adding compression as an option (#1084) * Adding compression as an option * Ignore 'misaligned' ending parenthathese * Moved the 'mark compressed' logic into the sub block within manual disk operations. * Fixed flake8 complaints * Muting a complextion warning on manage_new_and_existing_partitions(). It is too complex, but not something that we'll bother with for v2.4.0. As this whole function could be replaced with a new and improved menu system split into tasks rather than one huge if/else. --- archinstall/lib/user_interaction/partitioning_conf.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'archinstall/lib/user_interaction') diff --git a/archinstall/lib/user_interaction/partitioning_conf.py b/archinstall/lib/user_interaction/partitioning_conf.py index 734bbe87..af1d224f 100644 --- a/archinstall/lib/user_interaction/partitioning_conf.py +++ b/archinstall/lib/user_interaction/partitioning_conf.py @@ -113,7 +113,7 @@ def select_individual_blockdevice_usage(block_devices: list) -> Dict[str, Any]: return result -def manage_new_and_existing_partitions(block_device: 'BlockDevice') -> Dict[str, Any]: +def manage_new_and_existing_partitions(block_device: 'BlockDevice') -> Dict[str, Any]: # noqa: max-complexity: 50 block_device_struct = {"partitions": [partition.__dump__() for partition in block_device.partitions.values()]} # Test code: [part.__dump__() for part in block_device.partitions.values()] # TODO: Squeeze in BTRFS subvolumes here @@ -125,6 +125,7 @@ def manage_new_and_existing_partitions(block_device: 'BlockDevice') -> Dict[str, assign_mount_point = str(_('Assign mount-point for a partition')) mark_formatted = str(_('Mark/Unmark a partition to be formatted (wipes data)')) mark_encrypted = str(_('Mark/Unmark a partition as encrypted')) + mark_compressed = str(_('Mark/Unmark a partition as compressed (btrfs only)')) mark_bootable = str(_('Mark/Unmark a partition as bootable (automatic for /boot)')) set_filesystem_partition = str(_('Set desired filesystem for a partition')) set_btrfs_subvolumes = str(_('Set desired subvolumes on a btrfs partition')) @@ -140,6 +141,7 @@ def manage_new_and_existing_partitions(block_device: 'BlockDevice') -> Dict[str, mark_formatted, mark_encrypted, mark_bootable, + mark_compressed, set_filesystem_partition, set_btrfs_subvolumes, ] @@ -213,6 +215,7 @@ def manage_new_and_existing_partitions(block_device: 'BlockDevice') -> Dict[str, continue block_device_struct.update(suggest_single_disk_layout(block_device)[block_device.path]) + elif task is None: return block_device_struct else: @@ -226,6 +229,18 @@ def manage_new_and_existing_partitions(block_device: 'BlockDevice') -> Dict[str, block_device_struct['partitions'] = [ p for idx, p in enumerate(block_device_struct['partitions']) if idx not in to_delete ] + elif task == mark_compressed: + title = _('{}\n\nSelect which partition to mark as bootable').format(current_layout) + partition = select_partition(title, block_device_struct["partitions"]) + + if partition is not None: + if "filesystem" not in block_device_struct["partitions"][partition]: + block_device_struct["partitions"][partition]["filesystem"] = {} + if "mount_options" not in block_device_struct["partitions"][partition]["filesystem"]: + block_device_struct["partitions"][partition]["filesystem"]["mount_options"] = [] + + if "compress=zstd" not in block_device_struct["partitions"][partition]["filesystem"]["mount_options"]: + block_device_struct["partitions"][partition]["filesystem"]["mount_options"].append("compress=zstd") elif task == delete_all_partitions: block_device_struct["partitions"] = [] elif task == assign_mount_point: -- cgit v1.2.3-54-g00ecf