From bb295cb83a21e104fd39e05b627403d170c2c445 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 3 Apr 2021 11:25:34 +0200 Subject: Fixes #149 as well as --help. This will be added in the next patch release. --- archinstall/lib/user_interaction.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 80db7be1..630862ee 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -272,9 +272,16 @@ def select_language(options, show_only_country_codes=True): print(' -- You can enter ? or help to search for more languages --') selected_language = input('Select one of the above keyboard languages (by number or full name): ') if selected_language.lower() in ('?', 'help'): - filter_string = input('Search for layout containing (example: "sv-"): ') - new_options = search_keyboard_layout(filter_string) - return select_language(new_options, show_only_country_codes=False) + while True: + filter_string = input('Search for layout containing (example: "sv-"): ') + new_options = list(search_keyboard_layout(filter_string)) + + if len(new_options) <= 0: + log(f"Search string '{filter_string}' yielded no results, please try another search or Ctrl+D to abort.", fg='yellow') + continue + + return select_language(new_options, show_only_country_codes=False) + elif selected_language.isdigit() and (pos := int(selected_language)) <= len(languages)-1: selected_language = languages[pos] # I'm leaving "options" on purpose here. -- cgit v1.2.3-70-g09d2 From 7ae9696f133b114ef40fe3ba3c29ecb81f110467 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 3 Apr 2021 14:04:18 +0200 Subject: This should correct #135. I'll have to investigate other places where this logic might be as well and correct those. --- archinstall/lib/luks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/luks.py b/archinstall/lib/luks.py index f36a25ab..62067ec1 100644 --- a/archinstall/lib/luks.py +++ b/archinstall/lib/luks.py @@ -109,7 +109,7 @@ class luks2(): else: raise err - if b'Command successful.' not in (cmd_output := b''.join(cmd_handle)): + if cmd_handle.exit_code != 0: raise DiskError(f'Could not encrypt volume "{partition.path}": {cmd_output}') return key_file -- cgit v1.2.3-70-g09d2 From 67bb00c655cbe85e740a9d7e8b233dd4d69a79e2 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 3 Apr 2021 14:59:40 +0200 Subject: This partially addresses #151. Which might require more than just the path being returned. As the blkid might not be correctly identifying it in the bootloader step. But we'll have to test and see. --- archinstall/lib/disk.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'archinstall/lib') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 9ad49ac2..95418ab1 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -78,10 +78,15 @@ class BlockDevice(): return drive['back-file'] elif self.info['type'] == 'disk': return self.path + elif self.info['type'][:4] == 'raid': + # This should catch /dev/md## raid devices + return self.path elif self.info['type'] == 'crypt': if 'pkname' not in self.info: raise DiskError(f'A crypt device ({self.path}) without a parent kernel device name.') return f"/dev/{self.info['pkname']}" + else: + raise DiskError(f"Could not locate actual block device path for {self.path}") # if not stat.S_ISBLK(os.stat(full_path).st_mode): # raise DiskError(f'Selected disk "{full_path}" is not a block device.') -- cgit v1.2.3-70-g09d2 From 1c3287bc813d0652bc671c120c52b99a368e31fe Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 3 Apr 2021 15:11:10 +0200 Subject: Removed a breaking change while fixing hardware raids --- archinstall/lib/disk.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 95418ab1..371bf7f5 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -85,8 +85,6 @@ class BlockDevice(): if 'pkname' not in self.info: raise DiskError(f'A crypt device ({self.path}) without a parent kernel device name.') return f"/dev/{self.info['pkname']}" - else: - raise DiskError(f"Could not locate actual block device path for {self.path}") # if not stat.S_ISBLK(os.stat(full_path).st_mode): # raise DiskError(f'Selected disk "{full_path}" is not a block device.') -- cgit v1.2.3-70-g09d2 From 7333fe109ce832dcda1daa7f363e352990e66886 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 3 Apr 2021 15:18:35 +0200 Subject: Converted the raise exception into a log. Whenever blockdevice is unsure of what type it's working on, it will not log it as a debug message. --- archinstall/lib/disk.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'archinstall/lib') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 371bf7f5..52c6e287 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -85,6 +85,8 @@ class BlockDevice(): if 'pkname' not in self.info: raise DiskError(f'A crypt device ({self.path}) without a parent kernel device name.') return f"/dev/{self.info['pkname']}" + else: + log(f"Unknown blockdevice type for {self.path}: {self.info['type']}", level=LOG_LEVELS.Debug) # if not stat.S_ISBLK(os.stat(full_path).st_mode): # raise DiskError(f'Selected disk "{full_path}" is not a block device.') -- cgit v1.2.3-70-g09d2 From 2bf947ba055722f58b568fc1c984a298ad230ecb Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 3 Apr 2021 15:32:06 +0200 Subject: This should correct #152. When a newly /boot partition is created with no content or incorrect filesystem (meaning, no file system yet), the .has_content() call will crash due to incorrect fstype. Which means we should be able to skip the check and assume it's safe to format. Because there's no way (?) other OS:es can store something on the boot partition on a broken FS. --- archinstall/lib/disk.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 52c6e287..44d46c8b 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -245,9 +245,15 @@ class Partition(): if self.allow_formatting is False: log(f"Partition {self} is not marked for formatting.", level=LOG_LEVELS.Debug) return False - elif self.target_mountpoint == '/boot' and self.has_content(): - log(f"Partition {self} is a boot partition and has content inside.", level=LOG_LEVELS.Debug) - return False + elif self.target_mountpoint == '/boot': + try: + if self.has_content(): + log(f"Partition {self} is a boot partition and has content inside.", level=LOG_LEVELS.Debug) + return False + except SysCallError as err: + log(err.message, LOG_LEVELS.Debug) + log(f"Partition {self} was identified as /boot but we could not mount to check for content, continuing!", level=LOG_LEVELS.Debug) + pass return True -- cgit v1.2.3-70-g09d2 From b2927a50670d92bb99e0b8a23e6321e4a8c6f26b Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 3 Apr 2021 16:22:09 +0200 Subject: This should fix #151, by using lsblk instead of /dev/disk/by-partuuid. It also cleaned up the installer code quite a bit during the bootloader installation. Will do the same for encrypted drives later on by implementing UUID on a BlockDevice (disk) level. --- archinstall/lib/disk.py | 11 +++++++++++ archinstall/lib/installer.py | 14 +++----------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'archinstall/lib') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index 44d46c8b..8fbc50b2 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -190,6 +190,17 @@ class Partition(): else: return f'Partition(path={self.path}, fs={self.filesystem}{mount_repr})' + @property + def uuid(self) -> str: + """ + Returns the PARTUUID as returned by lsblk. + This is more reliable than relying on /dev/disk/by-partuuid as + it doesn't seam to be able to detect md raid partitions. + """ + lsblk = b''.join(sys_command(f'lsblk -J {self.path}')) + for partition in json.loads(lsblk.decode('UTF-8'))['blockdevices']: + return partition['partuuid'] + @property def encrypted(self): return self._encrypted diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index d161c3b7..a4321893 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -384,18 +384,10 @@ class Installer(): break else: 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') + entry.write(f'options root=PARTUUID={self.partition.uuid} rw intel_pstate=no_hwp\n') - self.helper_flags['bootloader'] = bootloader - return True - break + self.helper_flags['bootloader'] = bootloader + return True raise RequirementError(f"Could not identify the UUID of {self.partition}, there for {self.mountpoint}/boot/loader/entries/arch.conf will be broken until fixed.") else: -- cgit v1.2.3-70-g09d2