Added the ability to check if a harddrive has any mountpoint related to a given parameter.
This commit is contained in:
parent
9c7f689dd6
commit
53cdb607bc
|
|
@ -103,6 +103,12 @@ class BlockDevice():
|
|||
def has_partitions(self):
|
||||
return len(self.partitions)
|
||||
|
||||
def has_mount_point(self, mountpoint):
|
||||
for partition in self.partitions:
|
||||
if self.partitions[partition].mountpoint == mountpoint:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class Partition():
|
||||
def __init__(self, path, part_id=None, size=-1, filesystem=None, mountpoint=None, encrypted=False):
|
||||
|
|
|
|||
|
|
@ -17,5 +17,6 @@ storage = {
|
|||
'UPSTREAM_URL' : 'https://raw.githubusercontent.com/Torxed/archinstall/master/profiles',
|
||||
'PROFILE_DB' : None, # Used in cases when listing profiles is desired, not mandatory for direct profile grabing.
|
||||
'LOG_PATH' : '/var/log/archinstall',
|
||||
'LOG_FILE' : 'install.log'
|
||||
'LOG_FILE' : 'install.log',
|
||||
'MOUNT_POINT' : '/mnt'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,11 @@ archinstall.storage['_guided']['harddrive'] = harddrive
|
|||
if harddrive.has_partitions():
|
||||
archinstall.log(f" ! {harddrive} contains existing partitions", fg='red')
|
||||
if (option := input('Do you wish to keep existing partition setup or format the entire disk? (k/f): ')).lower() in ('k', 'keep'):
|
||||
print("We're keeping it!")
|
||||
# If we want to keep the existing partitioning table
|
||||
# Make sure that it's the selected drive mounted under /mnt
|
||||
# That way, we can rely on genfstab and some manual post-installation steps.
|
||||
if harddrive.has_mount_point(archinstall.storage['MOUNT_POINT']) is False:
|
||||
raise archinstall.DiskException(f"The selected drive {harddrive} is not pre-mounted to {archinstall.storage['MOUNT_POINT']}. This is required when keeping a existing partitioning scheme.")
|
||||
else:
|
||||
print('Formatting woop woop!')
|
||||
exit(1)
|
||||
|
|
|
|||
Loading…
Reference in New Issue