@@ -193,14 +193,36 @@ def generic_multi_select(options, text="Select one or more of the options above
193193 return selected_options
194194
195195def select_encrypted_partitions (block_devices :dict , password :str ) -> dict :
196+ def get_mountpoint (partition ):
197+ result_list = []
198+ if partition .get ('mountpoint' ):
199+ result_list .append (partition ['mountpoint' ])
200+ elif partition .get ('btrfs' ,{}).get ('subvolumes' ,{}):
201+ # a list comprehension can be written but it's a bit offuscated
202+ for subvol in partition ['btrfs' ]['subvolumes' ]:
203+ if isinstance (partition ['btrfs' ]['subvolumes' ][subvol ],str ):
204+ result_list .append (partition ['btrfs' ]['subvolumes' ][subvol ])
205+ elif partition ['btrfs' ]['subvolumes' ][subvol ].get ('mountpoint' ):
206+ result_list .append (partition ['btrfs' ]['subvolumes' ][subvol ]['mountpoint' ])
207+ return result_list
208+
209+ def is_encryptable (mountpoint_list ):
210+ if len (mountpoint_list ) == 0 :
211+ return False
212+ elif '/boot' in mountpoint_list :
213+ return False
214+ else :
215+ return True
216+
196217 for device in block_devices :
197218 for partition in block_devices [device ]['partitions' ]:
198- if partition .get ('mountpoint' , None ) not in ('/boot' , None ):
219+ mounts = get_mountpoint (partition )
220+ if is_encryptable (mounts ):
199221 log (f"Marked { partition } to be encrypted." , level = logging .WARNING , fg = "yellow" )
200222 partition ['encrypted' ] = True
201223 partition ['!password' ] = password
202224
203- if partition [ 'mountpoint' ] != '/' :
225+ if '/' not in mounts :
204226 # Tell the upcoming steps to generate a key-file for non root mounts.
205227 log (f"Marking partition for use with encryption-key: { partition } " , level = logging .WARNING , fg = "yellow" )
206228 partition ['generate-encryption-key-file' ] = True
0 commit comments