Skip to content

Commit

Permalink
Moved the output of the current fileformat structure in guided, as we…
Browse files Browse the repository at this point in the history
…ll as added an option to supress the log message from format() in order to hide (for users) the some what confusing formating of /dev/null.
  • Loading branch information
Torxed committed Feb 7, 2021
1 parent acf3929 commit 530edb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions archinstall/lib/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ def __repr__(self, *args, **kwargs):
else:
return f'Partition(path={self.path}, fs={self.filesystem}, mounted={self.mountpoint})'

def format(self, filesystem, path=None):
def format(self, filesystem, path=None, log_formating=True):
if not path:
path = self.path

log(f'Formatting {path} -> {filesystem}', level=LOG_LEVELS.Info)
if log_formating:
log(f'Formatting {path} -> {filesystem}', level=LOG_LEVELS.Info)

if filesystem == 'btrfs':
o = b''.join(sys_command(f'/usr/bin/mkfs.btrfs -f {path}'))
if b'UUID' not in o:
Expand Down Expand Up @@ -211,7 +213,7 @@ def filesystem_supported(self):
# We perform a dummy format on /dev/null with the given filesystem-type
# in order to determain if we support it or not.
try:
self.format(self.filesystem, '/dev/null')
self.format(self.filesystem, '/dev/null', log_formating=False)
except SysCallError:
pass # We supported it, but /dev/null is not formatable as expected so the mkfs call exited with an error code
except UnknownFilesystemFormat as err:
Expand Down
9 changes: 5 additions & 4 deletions examples/guided.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,18 @@ def perform_installation(device, boot_partition, language, mirrors):

if harddrive.has_partitions():
archinstall.log(f" ! {harddrive} contains existing partitions", fg='red')
for partition in harddrive:
if partition.filesystem_supported():
archinstall.log(f" {partition}")

if (option := input('Do you wish to keep existing partition setup or format the entire disk? (k/f): ')).lower() in ('k', 'keep'):
# 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.DiskError(f"The selected drive {harddrive} is not pre-mounted to {archinstall.storage['MOUNT_POINT']}. This is required when keeping a existing partitioning scheme.")

archinstall.log('Using existing partition table:')
for partition in harddrive:
if partition.filesystem_supported():
archinstall.log(f" {partition}")
archinstall.log('Using existing partition table reported above.')
else:
print('Formatting woop woop!')
exit(1)
Expand Down

0 comments on commit 530edb5

Please sign in to comment.