Fixed format detection on commands, should be using exit codes instead?

This commit is contained in:
Anton Hvornum 2021-06-10 21:00:33 +02:00
parent adae29c205
commit 0a8c061ab4
3 changed files with 18 additions and 10 deletions

View File

@ -437,13 +437,13 @@ class Partition:
log(f'Formatting {path} -> {filesystem}', level=logging.INFO)
if filesystem == 'btrfs':
if b'UUID' not in (mkfs := SysCommand(f'/usr/bin/mkfs.btrfs -f {path}')):
if 'UUID:' not in (mkfs := SysCommand(f'/usr/bin/mkfs.btrfs -f {path}').decode('UTF-8')):
raise DiskError(f'Could not format {path} with {filesystem} because: {mkfs}')
self.filesystem = filesystem
elif filesystem == 'fat32':
mkfs = SysCommand(f'/usr/bin/mkfs.vfat -F32 {path}')
if (b'mkfs.fat' not in mkfs and b'mkfs.vfat' not in mkfs) or b'command not found' in mkfs:
mkfs = SysCommand(f'/usr/bin/mkfs.vfat -F32 {path}').decode('UTF-8')
if ('mkfs.fat' not in mkfs and 'mkfs.vfat' not in mkfs) or 'command not found' in mkfs:
raise DiskError(f"Could not format {path} with {filesystem} because: {mkfs}")
self.filesystem = filesystem
@ -619,12 +619,6 @@ class Filesystem:
else:
partition['device_instance'].format(partition['filesystem']['format'], allow_formatting=partition.get('format', False))
def mount_ordered_layout(self, layout :dict):
mountpoints = {}
for partition in layout['partitions']:
print(partition)
exit(0)
def find_partition(self, mountpoint):
for partition in self.blockdevice:
if partition.target_mountpoint == mountpoint or partition.mountpoint == mountpoint:

View File

@ -122,6 +122,14 @@ class Installer:
return True
def mount_ordered_layout(self, layout :dict):
mountpoints = {}
for partition in layout['partitions']:
mountpoints[partition['mountpoint']] = partition['device_instance']
for mountpoint in sorted(mountpoints.keys()):
mountpoints[mountpoint].mount(f"{self.target}{mountpoint}")
def mount(self, partition, mountpoint, create_mountpoint=True):
if create_mountpoint and not os.path.isdir(f'{self.target}{mountpoint}'):
os.makedirs(f'{self.target}{mountpoint}')

View File

@ -223,7 +223,6 @@ def perform_filesystem_operations():
for drive in archinstall.arguments['harddrives']:
with archinstall.Filesystem(drive, mode) as fs:
fs.load_layout(archinstall.storage['disk_layouts'][drive])
fs.mount_ordered_layout(archinstall.storage['disk_layouts'][drive])
perform_installation(archinstall.storage.get('MOUNT_POINT', '/mnt'))
@ -234,7 +233,14 @@ def perform_installation(mountpoint):
Only requirement is that the block devices are
formatted and setup prior to entering this function.
"""
with archinstall.Installer(mountpoint, kernels=archinstall.arguments.get('kernels', 'linux')) as installation:
# Mount all the drives to the desired mountpoint
# This *can* be done outside of the installation, but the installer can deal with it.
for drive in archinstall.arguments['harddrives']:
installation.mount_ordered_layout(archinstall.storage['disk_layouts'][drive])
# if len(mirrors):
# Certain services might be running that affects the system during installation.
# Currently, only one such service is "reflector.service" which updates /etc/pacman.d/mirrorlist