Merge pull request #120 from Torxed/torxed-patch-sunday
Torxed patch sunday
This commit is contained in:
commit
6cba404b75
|
|
@ -142,7 +142,7 @@ class Partition():
|
|||
self.target_mountpoint = mountpoint
|
||||
self.filesystem = filesystem
|
||||
self.size = size # TODO: Refresh?
|
||||
self.encrypted = encrypted
|
||||
self._encrypted = encrypted
|
||||
self.allow_formatting = False # A fail-safe for unconfigured partitions, such as windows NTFS partitions.
|
||||
|
||||
if mountpoint:
|
||||
|
|
@ -161,7 +161,7 @@ class Partition():
|
|||
self.filesystem = fstype
|
||||
|
||||
if self.filesystem == 'crypto_LUKS':
|
||||
self.encrypted = True
|
||||
self._encrypted = True
|
||||
|
||||
def __lt__(self, left_comparitor):
|
||||
if type(left_comparitor) == Partition:
|
||||
|
|
@ -177,14 +177,23 @@ class Partition():
|
|||
elif self.target_mountpoint:
|
||||
mount_repr = f", rel_mountpoint={self.target_mountpoint}"
|
||||
|
||||
if self.encrypted:
|
||||
if self._encrypted:
|
||||
return f'Partition(path={self.path}, real_device={self.real_device}, fs={self.filesystem}{mount_repr})'
|
||||
else:
|
||||
return f'Partition(path={self.path}, fs={self.filesystem}{mount_repr})'
|
||||
|
||||
@property
|
||||
def encrypted(self):
|
||||
return self._encrypted
|
||||
|
||||
@encrypted.setter
|
||||
def encrypted(self, value :bool):
|
||||
log(f'Marking {self} as encrypted', level=LOG_LEVELS.Debug)
|
||||
self._encrypted = value
|
||||
|
||||
@property
|
||||
def real_device(self):
|
||||
if not self.encrypted:
|
||||
if not self._encrypted:
|
||||
return self.path
|
||||
else:
|
||||
for blockdevice in json.loads(b''.join(sys_command('lsblk -J')).decode('UTF-8'))['blockdevices']:
|
||||
|
|
@ -237,7 +246,7 @@ class Partition():
|
|||
"""
|
||||
from .luks import luks2
|
||||
|
||||
if not self.encrypted:
|
||||
if not self._encrypted:
|
||||
raise DiskError(f"Attempting to encrypt a partition that was not marked for encryption: {self}")
|
||||
|
||||
if not self.safe_to_format():
|
||||
|
|
|
|||
|
|
@ -369,10 +369,12 @@ class Installer():
|
|||
|
||||
|
||||
if self.partition.encrypted:
|
||||
log(f"Identifying root partition {self.partition} to boot based on disk UUID, looking for '{os.path.basename(self.partition.real_device)}'.", level=LOG_LEVELS.Debug)
|
||||
log(f"Identifying root partition by DISK-UUID on {self.partition}, looking for '{os.path.basename(self.partition.real_device)}'.", level=LOG_LEVELS.Debug)
|
||||
for root, folders, uids in os.walk('/dev/disk/by-uuid'):
|
||||
for uid in uids:
|
||||
real_path = os.path.realpath(os.path.join(root, uid))
|
||||
|
||||
log(f"Checking root partition match {os.path.basename(real_path)} against {os.path.basename(self.partition.real_device)}: {os.path.basename(real_path) == os.path.basename(self.partition.real_device)}", level=LOG_LEVELS.Debug)
|
||||
if not os.path.basename(real_path) == os.path.basename(self.partition.real_device): continue
|
||||
|
||||
entry.write(f'options cryptdevice=UUID={uid}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n')
|
||||
|
|
@ -381,10 +383,12 @@ class Installer():
|
|||
return True
|
||||
break
|
||||
else:
|
||||
log(f"Identifying root partition {self.partition} to boot based on partition UUID, looking for '{os.path.basename(self.partition.path)}'.", level=LOG_LEVELS.Debug)
|
||||
log(f"Identifying root partition by PART-UUID on {self.partition}, looking for '{os.path.basename(self.partition.path)}'.", level=LOG_LEVELS.Debug)
|
||||
for root, folders, uids in os.walk('/dev/disk/by-partuuid'):
|
||||
for uid in uids:
|
||||
real_path = os.path.realpath(os.path.join(root, uid))
|
||||
|
||||
log(f"Checking root partition match {os.path.basename(real_path)} against {os.path.basename(self.partition.path)}: {os.path.basename(real_path) == os.path.basename(self.partition.path)}", level=LOG_LEVELS.Debug)
|
||||
if not os.path.basename(real_path) == os.path.basename(self.partition.path): continue
|
||||
|
||||
entry.write(f'options root=PARTUUID={uid} rw intel_pstate=no_hwp\n')
|
||||
|
|
|
|||
Loading…
Reference in New Issue