index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton@hvornum.se> | 2021-03-14 12:16:46 +0100 |
---|---|---|
committer | Anton Hvornum <anton@hvornum.se> | 2021-03-14 12:16:46 +0100 |
commit | f589750a3cff6f061bc4b78ef857e52a7fbc874c (patch) | |
tree | 58c321134df6bb86ef994d85e959af29959e245f /archinstall/lib | |
parent | 577428f1b20da6f7f583c9c3c276ee1d38abb01d (diff) |
-rw-r--r-- | archinstall/lib/exceptions.py | 5 | ||||
-rw-r--r-- | archinstall/lib/general.py | 2 | ||||
-rw-r--r-- | archinstall/lib/luks.py | 14 |
diff --git a/archinstall/lib/exceptions.py b/archinstall/lib/exceptions.py index 5a5d47c6..558a397d 100644 --- a/archinstall/lib/exceptions.py +++ b/archinstall/lib/exceptions.py @@ -7,7 +7,10 @@ class UnknownFilesystemFormat(BaseException): class ProfileError(BaseException): pass class SysCallError(BaseException): - pass + def __init__(self, message, error_code): + super(SysCallError, self).__init__(message) + self.message = message + self.error_code = error_code class ProfileNotFound(BaseException): pass class HardwareIncompatibilityError(BaseException): diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index e87e4102..28fc0934 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -251,7 +251,7 @@ class sys_command():#Thread): if self.exit_code != 0 and not self.kwargs['suppress_errors']: #self.log(self.trace_log.decode('UTF-8'), level=LOG_LEVELS.Debug) #self.log(f"'{self.raw_cmd}' did not exit gracefully, exit code {self.exit_code}.", level=LOG_LEVELS.Error) - raise SysCallError(f"{self.trace_log.decode('UTF-8')}\n'{self.raw_cmd}' did not exit gracefully (trace log above), exit code: {self.exit_code}") + raise SysCallError(message=f"{self.trace_log.decode('UTF-8')}\n'{self.raw_cmd}' did not exit gracefully (trace log above), exit code: {self.exit_code}", exit_code=self.exit_code) self.ended = time.time() with open(f'{self.cwd}/trace.log', 'wb') as fh: diff --git a/archinstall/lib/luks.py b/archinstall/lib/luks.py index de53c05e..a4d2a07d 100644 --- a/archinstall/lib/luks.py +++ b/archinstall/lib/luks.py @@ -64,12 +64,16 @@ class luks2(): with open(key_file, 'wb') as fh: fh.write(password) - cmd_handle = sys_command(f'/usr/bin/cryptsetup -q -v --type luks2 --pbkdf argon2i --hash {hash_type} --key-size {key_size} --iter-time {iter_time} --key-file {os.path.abspath(key_file)} --use-urandom luksFormat {partition.path}') - if cmd_handle.exit_code == 256: - # Partition was in use, unmount it and - partition.unmount() - sys_command(f'cryptsetup close {partition.path}') + try: cmd_handle = sys_command(f'/usr/bin/cryptsetup -q -v --type luks2 --pbkdf argon2i --hash {hash_type} --key-size {key_size} --iter-time {iter_time} --key-file {os.path.abspath(key_file)} --use-urandom luksFormat {partition.path}') + except SysCallError as err: + if err.exit_code == 256: + # Partition was in use, unmount it and try again + partition.unmount() + sys_command(f'cryptsetup close {partition.path}') + cmd_handle = sys_command(f'/usr/bin/cryptsetup -q -v --type luks2 --pbkdf argon2i --hash {hash_type} --key-size {key_size} --iter-time {iter_time} --key-file {os.path.abspath(key_file)} --use-urandom luksFormat {partition.path}') + else: + raise err if b'Command successful.' not in b''.join(cmd_handle): raise DiskError(f'Could not encrypt volume "{partition.path}": {o}') |