55from archinstall .lib .models .device_model import (
66 DeviceModification ,
77 DiskEncryption ,
8- DiskLayoutConfiguration ,
98 EncryptionType ,
109 LvmConfiguration ,
1110 LvmVolume ,
2827class DiskEncryptionMenu (AbstractSubMenu [DiskEncryption ]):
2928 def __init__ (
3029 self ,
31- disk_config : DiskLayoutConfiguration ,
30+ device_modifications : list [DeviceModification ],
31+ lvm_config : LvmConfiguration | None = None ,
3232 preset : DiskEncryption | None = None ,
3333 ):
3434 if preset :
3535 self ._enc_config = preset
3636 else :
3737 self ._enc_config = DiskEncryption ()
3838
39- self ._disk_config = disk_config
39+ self ._device_modifications = device_modifications
40+ self ._lvm_config = lvm_config
4041
4142 menu_optioons = self ._define_menu_options ()
4243 self ._item_group = MenuItemGroup (menu_optioons , sort_items = False , checkmarks = True )
@@ -51,7 +52,7 @@ def _define_menu_options(self) -> list[MenuItem]:
5152 return [
5253 MenuItem (
5354 text = tr ('Encryption type' ),
54- action = lambda x : select_encryption_type (self ._disk_config , x ),
55+ action = lambda x : select_encryption_type (self ._device_modifications , self . _lvm_config , x ),
5556 value = self ._enc_config .encryption_type ,
5657 preview_action = self ._preview ,
5758 key = 'encryption_type' ,
@@ -66,7 +67,7 @@ def _define_menu_options(self) -> list[MenuItem]:
6667 ),
6768 MenuItem (
6869 text = tr ('Partitions' ),
69- action = lambda x : select_partitions_to_encrypt (self ._disk_config . device_modifications , x ),
70+ action = lambda x : select_partitions_to_encrypt (self ._device_modifications , x ),
7071 value = self ._enc_config .partitions ,
7172 dependencies = [self ._check_dep_partitions ],
7273 preview_action = self ._preview ,
@@ -91,8 +92,8 @@ def _define_menu_options(self) -> list[MenuItem]:
9192 ]
9293
9394 def _select_lvm_vols (self , preset : list [LvmVolume ]) -> list [LvmVolume ]:
94- if self ._disk_config . lvm_config :
95- return select_lvm_vols_to_encrypt (self ._disk_config . lvm_config , preset = preset )
95+ if self ._lvm_config :
96+ return select_lvm_vols_to_encrypt (self ._lvm_config , preset = preset )
9697 return []
9798
9899 def _check_dep_enc_type (self ) -> bool :
@@ -214,15 +215,23 @@ def _prev_hsm(self) -> str | None:
214215 return f'{ tr ("HSM device" )} : { output } '
215216
216217
217- def select_encryption_type (disk_config : DiskLayoutConfiguration , preset : EncryptionType ) -> EncryptionType | None :
218+ def select_encryption_type (
219+ device_modifications : list [DeviceModification ],
220+ lvm_config : LvmConfiguration | None = None ,
221+ preset : EncryptionType | None = None ,
222+ ) -> EncryptionType | None :
218223 options : list [EncryptionType ] = []
219- preset_value = EncryptionType .type_to_text (preset )
220224
221- if disk_config . lvm_config :
225+ if lvm_config :
222226 options = [EncryptionType .LvmOnLuks , EncryptionType .LuksOnLvm ]
223227 else :
224228 options = [EncryptionType .Luks ]
225229
230+ if not preset :
231+ preset = options [0 ]
232+
233+ preset_value = EncryptionType .type_to_text (preset )
234+
226235 items = [MenuItem (EncryptionType .type_to_text (o ), value = o ) for o in options ]
227236 group = MenuItemGroup (items )
228237 group .set_focus_by_value (preset_value )
0 commit comments