Repository: archlinux/archinstall

Issue:
Keyboard layout and timezone menus broken
The following functions iterate over characters instead of lines.

https://github.com/archlinux/archinstall/blob/edbc13590366e93bb8a85eacf104d5613bc5793a/archinstall/lib/locale/utils.py#L8-L13

https://github.com/archlinux/archinstall/blob/edbc13590366e93bb8a85eacf104d5613bc5793a/archinstall/lib/locale/utils.py#L27-L32

https://github.com/archlinux/archinstall/blob/edbc13590366e93bb8a85eacf104d5613bc5793a/archinstall/lib/locale/utils.py#L65-L70

This breaks the _Keyboard layout_ and _Timezone_ menus. It also causes keyboard language validation to fail.

```
Invalid keyboard language specified: us
```


Discussion:

Resolving patch:
diff --git a/archinstall/lib/interactions/general_conf.py b/archinstall/lib/interactions/general_conf.py
--- a/archinstall/lib/interactions/general_conf.py
+++ b/archinstall/lib/interactions/general_conf.py
@@ -44,7 +44,7 @@ def ask_for_a_timezone(preset: Optional[str] = None) -> Optional[str]:
 
 	choice = Menu(
 		_('Select a timezone'),
-		list(timezones),
+		timezones,
 		preset_values=preset,
 		default_option=default
 	).run()
@@ -95,7 +95,7 @@ def select_language(preset: Optional[str] = None) -> Optional[str]:
 	"""
 	kb_lang = list_keyboard_languages()
 	# sort alphabetically and then by length
-	sorted_kb_lang = sorted(sorted(list(kb_lang)), key=len)
+	sorted_kb_lang = sorted(kb_lang, key=lambda x: (len(x), x))
 
 	choice = Menu(
 		_('Select keyboard layout'),
diff --git a/archinstall/lib/locale/locale_menu.py b/archinstall/lib/locale/locale_menu.py
--- a/archinstall/lib/locale/locale_menu.py
+++ b/archinstall/lib/locale/locale_menu.py
@@ -139,7 +139,7 @@ def select_kb_layout(preset: Optional[str] = None) -> Optional[str]:
 	"""
 	kb_lang = list_keyboard_languages()
 	# sort alphabetically and then by length
-	sorted_kb_lang = sorted(sorted(list(kb_lang)), key=len)
+	sorted_kb_lang = sorted(kb_lang, key=lambda x: (len(x), x))
 
 	choice = Menu(
 		_('Select keyboard layout'),
diff --git a/archinstall/lib/locale/utils.py b/archinstall/lib/locale/utils.py
--- a/archinstall/lib/locale/utils.py
+++ b/archinstall/lib/locale/utils.py
@@ -1,16 +1,15 @@
-from typing import Iterator, List
+from typing import List
 
 from ..exceptions import ServiceException, SysCallError
 from ..general import SysCommand
 from ..output import error
 
 
-def list_keyboard_languages() -> Iterator[str]:
-	for line in SysCommand(
+def list_keyboard_languages() -> List[str]:
+	return SysCommand(
 		"localectl --no-pager list-keymaps",
 		environment_vars={'SYSTEMD_COLORS': '0'}
-	).decode():
-		yield line
+	).decode().splitlines()
 
 
 def list_locales() -> List[str]:
@@ -24,12 +23,11 @@ def list_locales() -> List[str]:
 	return locales
 
 
-def list_x11_keyboard_languages() -> Iterator[str]:
-	for line in SysCommand(
+def list_x11_keyboard_languages() -> List[str]:
+	return SysCommand(
 		"localectl --no-pager list-x11-keymap-layouts",
 		environment_vars={'SYSTEMD_COLORS': '0'}
-	).decode():
-		yield line
+	).decode().splitlines()
 
 
 def verify_keyboard_layout(layout :str) -> bool:
@@ -62,9 +60,8 @@ def set_kb_layout(locale :str) -> bool:
 	return False
 
 
-def list_timezones() -> Iterator[str]:
-	for line in SysCommand(
+def list_timezones() -> List[str]:
+	return SysCommand(
 		"timedatectl --no-pager list-timezones",
 		environment_vars={'SYSTEMD_COLORS': '0'}
-	).decode():
-		yield line
+	).decode().splitlines()


Test patch: