Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archinstall/lib/disk.py29
-rw-r--r--archinstall/lib/output.py11
-rw-r--r--examples/guided.py2
3 files changed, 27 insertions, 15 deletions
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index f01300b3..a0fcfddf 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -7,6 +7,7 @@ from .storage import storage
ROOT_DIR_PATTERN = re.compile('^.*?/devices')
GPT = 0b00000001
+MBR = 0b00000010
#import ctypes
#import ctypes.util
@@ -113,6 +114,10 @@ class BlockDevice():
all_partitions = self.partitions
return [all_partitions[k] for k in all_partitions]
+ @property
+ def partition_table_type(self):
+ return GPT
+
def has_partitions(self):
return len(self.partitions)
@@ -272,15 +277,21 @@ class Filesystem():
self.mode = mode
def __enter__(self, *args, **kwargs):
- #if self.mode == GPT:
- # if sys_command(f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt',).exit_code == 0:
- # return self
- # else:
- # raise DiskError(f'Problem setting the partition format to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt')
- #else:
- # raise DiskError(f'Unknown mode selected to format in: {self.mode}')
- print(type(self.blockdevice))
- print('Keep partitions:', self.blockdevice.keep_partitions)
+ if self.blockdevice.keep_partitions is False:
+ log(f'Wiping {self.blockdevice} by using partition format {self.mode}', level=LOG_LEVELS.Debug)
+ if self.mode == GPT:
+ if sys_command(f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt',).exit_code == 0:
+ return self
+ else:
+ raise DiskError(f'Problem setting the partition format to GPT:', f'/usr/bin/parted -s {self.blockdevice.device} mklabel gpt')
+ else:
+ raise DiskError(f'Unknown mode selected to format in: {self.mode}')
+
+ # TODO: partition_table_type is hardcoded to GPT at the moment. This has to be changed.
+ elif self.mode == self.blockdevice.partition_table_type:
+ log(f'Kept partition format {self.mode} for {self.blockdevice}', level=LOG_LEVELS.Debug)
+ else:
+ raise DiskError(f'The selected partition table format {self.mode} does not match that of {self.blockdevice}.')
def __repr__(self):
return f"Filesystem(blockdevice={self.blockdevice}, mode={self.mode})"
diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py
index 956ad0c4..0e0a295b 100644
--- a/archinstall/lib/output.py
+++ b/archinstall/lib/output.py
@@ -5,6 +5,9 @@ import logging
from pathlib import Path
from .storage import storage
+# TODO: use logging's built in levels instead.
+# Altough logging is threaded and I wish to avoid that.
+# It's more Pythonistic or w/e you want to call it.
class LOG_LEVELS:
Critical = 0b001
Error = 0b010
@@ -108,10 +111,10 @@ def log(*args, **kwargs):
# In that case, we'll drop it.
return None
- try:
- journald.log(string, level=kwargs['level'])
- except ModuleNotFoundError:
- pass # Ignore writing to journald
+ try:
+ journald.log(string, level=kwargs.get('level', LOG_LEVELS.Info))
+ except ModuleNotFoundError:
+ pass # Ignore writing to journald
# Finally, print the log unless we skipped it based on level.
# We use sys.stdout.write()+flush() instead of print() to try and
diff --git a/examples/guided.py b/examples/guided.py
index fbe6ea47..15f9ba1c 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -271,8 +271,6 @@ signal.signal(signal.SIGINT, original_sigint_handler)
Once that's done, we'll hand over to perform_installation()
"""
with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs:
- print('Debug')
- exit(0)
# Use partitioning helper to set up the disk partitions.
if disk_password:
fs.use_entire_disk('luks2')