Added an early check for filesystem compatability. Since we need to handle unique packages etc for certain filesystem formats. This early check can be caught and ignored if the programmer/user wants to override the check and continue anyway. But the default should be to stop all execution to not install a half-working system.
This commit is contained in:
parent
759b778743
commit
a5a6ff4d31
|
|
@ -138,14 +138,26 @@ class Partition():
|
||||||
self.mountpoint = partition_info['target']
|
self.mountpoint = partition_info['target']
|
||||||
self.filesystem = partition_info['fstype']
|
self.filesystem = partition_info['fstype']
|
||||||
|
|
||||||
|
# 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')
|
||||||
|
except DiskError:
|
||||||
|
pass # We supported it, but /dev/null is not formatable as expected
|
||||||
|
except UnknownFilesystemFormat as err:
|
||||||
|
raise err
|
||||||
|
|
||||||
def __repr__(self, *args, **kwargs):
|
def __repr__(self, *args, **kwargs):
|
||||||
if self.encrypted:
|
if self.encrypted:
|
||||||
return f'Partition(path={self.path}, real_device={self.real_device}, fs={self.filesystem}, mounted={self.mountpoint})'
|
return f'Partition(path={self.path}, real_device={self.real_device}, fs={self.filesystem}, mounted={self.mountpoint})'
|
||||||
else:
|
else:
|
||||||
return f'Partition(path={self.path}, fs={self.filesystem}, mounted={self.mountpoint})'
|
return f'Partition(path={self.path}, fs={self.filesystem}, mounted={self.mountpoint})'
|
||||||
|
|
||||||
def format(self, filesystem):
|
def format(self, filesystem, path=None):
|
||||||
log(f'Formatting {self} -> {filesystem}', level=LOG_LEVELS.Info)
|
if not path:
|
||||||
|
path = self.path
|
||||||
|
|
||||||
|
log(f'Formatting {path} -> {filesystem}', level=LOG_LEVELS.Info)
|
||||||
if filesystem == 'btrfs':
|
if filesystem == 'btrfs':
|
||||||
o = b''.join(sys_command(f'/usr/bin/mkfs.btrfs -f {self.path}'))
|
o = b''.join(sys_command(f'/usr/bin/mkfs.btrfs -f {self.path}'))
|
||||||
if b'UUID' not in o:
|
if b'UUID' not in o:
|
||||||
|
|
@ -169,7 +181,7 @@ class Partition():
|
||||||
raise DiskError(f'Could not format {self.path} with {filesystem} because: {b"".join(handle)}')
|
raise DiskError(f'Could not format {self.path} with {filesystem} because: {b"".join(handle)}')
|
||||||
self.filesystem = 'f2fs'
|
self.filesystem = 'f2fs'
|
||||||
else:
|
else:
|
||||||
raise DiskError(f'Fileformat {filesystem} is not yet implemented.')
|
raise UnknownFilesystemFormat(f'Fileformat '{filesystem}' is not yet implemented.')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def find_parent_of(self, data, name, parent=None):
|
def find_parent_of(self, data, name, parent=None):
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ class RequirementError(BaseException):
|
||||||
pass
|
pass
|
||||||
class DiskError(BaseException):
|
class DiskError(BaseException):
|
||||||
pass
|
pass
|
||||||
|
class UnknownFilesystemFormat(BaseException):
|
||||||
|
pass
|
||||||
class ProfileError(BaseException):
|
class ProfileError(BaseException):
|
||||||
pass
|
pass
|
||||||
class SysCallError(BaseException):
|
class SysCallError(BaseException):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue