Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/disk/device_handler.py31
-rw-r--r--archinstall/lib/disk/device_model.py2
-rw-r--r--archinstall/lib/disk/partitioning_menu.py2
3 files changed, 19 insertions, 16 deletions
diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py
index 7731bbc3..7cd79784 100644
--- a/archinstall/lib/disk/device_handler.py
+++ b/archinstall/lib/disk/device_handler.py
@@ -246,7 +246,7 @@ class DeviceHandler(object):
info(f'luks2 locking device: {dev_path}')
luks_handler.lock()
- def _validate(self, device_mod: DeviceModification):
+ def _validate_partitions(self, partitions: List[PartitionModification]):
checks = {
# verify that all partitions have a path set (which implies that they have been created)
lambda x: x.dev_path is None: ValueError('When formatting, all partitions must have a path set'),
@@ -257,7 +257,7 @@ class DeviceHandler(object):
}
for check, exc in checks.items():
- found = next(filter(check, device_mod.partitions), None)
+ found = next(filter(check, partitions), None)
if found is not None:
raise exc
@@ -270,12 +270,16 @@ class DeviceHandler(object):
Format can be given an overriding path, for instance /dev/null to test
the formatting functionality and in essence the support for the given filesystem.
"""
- self._validate(device_mod)
+
+ # don't touch existing partitions
+ filtered_part = [p for p in device_mod.partitions if not p.exists()]
+
+ self._validate_partitions(filtered_part)
# make sure all devices are unmounted
- self._umount_all_existing(device_mod)
+ self._umount_all_existing(device_mod.device_path)
- for part_mod in device_mod.partitions:
+ for part_mod in filtered_part:
# partition will be encrypted
if enc_conf is not None and part_mod in enc_conf.partitions:
self._perform_enc_formatting(
@@ -446,10 +450,10 @@ class DeviceHandler(object):
return luks_handler
- def _umount_all_existing(self, modification: DeviceModification):
- info(f'Unmounting all partitions: {modification.device_path}')
+ def _umount_all_existing(self, device_path: Path):
+ info(f'Unmounting all existing partitions: {device_path}')
- existing_partitions = self._devices[modification.device_path].partition_infos
+ existing_partitions = self._devices[device_path].partition_infos
for partition in existing_partitions:
debug(f'Unmounting: {partition.path}')
@@ -476,7 +480,7 @@ class DeviceHandler(object):
raise DiskError('Too many partitions on disk, MBR disks can only have 3 primary partitions')
# make sure all devices are unmounted
- self._umount_all_existing(modification)
+ self._umount_all_existing(modification.device_path)
# WARNING: the entire device will be wiped and all data lost
if modification.wipe:
@@ -489,13 +493,10 @@ class DeviceHandler(object):
info(f'Creating partitions: {modification.device_path}')
- # TODO sort by delete first
-
- for part_mod in modification.partitions:
- # don't touch existing partitions
- if part_mod.exists():
- continue
+ # don't touch existing partitions
+ filtered_part = [p for p in modification.partitions if not p.exists()]
+ for part_mod in filtered_part:
# if the entire disk got nuked then we don't have to delete
# any existing partitions anymore because they're all gone already
requires_delete = modification.wipe is False
diff --git a/archinstall/lib/disk/device_model.py b/archinstall/lib/disk/device_model.py
index 7611eda5..28ee3116 100644
--- a/archinstall/lib/disk/device_model.py
+++ b/archinstall/lib/disk/device_model.py
@@ -96,6 +96,7 @@ class DiskLayoutConfiguration:
length=Size.parse_args(partition['length']),
mount_options=partition['mount_options'],
mountpoint=Path(partition['mountpoint']) if partition['mountpoint'] else None,
+ dev_path=Path(partition['dev_path']) if partition['dev_path'] else None,
type=PartitionType(partition['type']),
flags=[PartitionFlag[f] for f in partition.get('flags', [])],
btrfs_subvols=SubvolumeModification.parse_args(partition.get('btrfs', [])),
@@ -750,6 +751,7 @@ class PartitionModification:
'mountpoint': str(self.mountpoint) if self.mountpoint else None,
'mount_options': self.mount_options,
'flags': [f.name for f in self.flags],
+ 'dev_path': str(self.dev_path) if self.dev_path else None,
'btrfs': [vol.__dump__() for vol in self.btrfs_subvols]
}
diff --git a/archinstall/lib/disk/partitioning_menu.py b/archinstall/lib/disk/partitioning_menu.py
index 4acb4e85..4c4d8fac 100644
--- a/archinstall/lib/disk/partitioning_menu.py
+++ b/archinstall/lib/disk/partitioning_menu.py
@@ -347,7 +347,7 @@ def manual_partitioning(
manual_preset = preset
menu_list = PartitioningList(prompt, device, manual_preset)
- partitions = menu_list.run()
+ partitions: List[PartitionModification] = menu_list.run()
if menu_list.is_last_choice_cancel():
return preset