Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This allows us to set LANG= in vconsole for keymap negotiation during crypt-unlock #1187

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion archinstall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
from .lib.profiles import *
from .lib.services import *
from .lib.storage import *
from .lib.systemd import *
from .lib.systemd import (
localectl_status,
Boot,
Ini
)
from .lib.user_interaction import *
from .lib.menu import Menu
from .lib.menu.list_manager import ListManager
Expand Down
12 changes: 12 additions & 0 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,8 @@ def create_file(self, filename :str, owner :Optional[str] = None) -> Installatio
return InstallationFile(self, filename, owner)

def set_keyboard_language(self, language: str) -> bool:
from .systemd import localectl_status

log(f"Setting keyboard language to {language}", level=logging.INFO)
if len(language.strip()):
if not verify_keyboard_layout(language):
Expand All @@ -1075,6 +1077,16 @@ def set_keyboard_language(self, language: str) -> bool:
else:
self.log('Keyboard language was not changed from default (no language specified).', fg="yellow", level=logging.INFO)

# This needs to be explicitly set in some cases due to https://github.com/archlinux/archinstall/issues/596
if LANG := localectl_status().get('x11_layout'):
with open(f"{self.target}/etc/vconsole.conf", "a") as vconsole:
with open(f'{self.target}/etc/locale.conf', 'r') as locale:
locale_data = locale.read()

# TODO: A bit of a hack to convert LANG=en_US.UTF-8 into just US.UTF-8
locale_and_encoding = locale_data.split('=', 1)[1].split('_', 1)[1]
vconsole.write(f"LANG={LANG}_{locale_and_encoding}\n")

return True

def set_x11_keyboard_language(self, language: str) -> bool:
Expand Down
8 changes: 8 additions & 0 deletions archinstall/lib/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,11 @@ def SysCommandWorker(self, cmd: list, *args, **kwargs) -> SysCommandWorker:
cmd[0] = locate_binary(cmd[0])

return SysCommandWorker(["systemd-run", f"--machine={self.container_name}", "--pty", *cmd], *args, **kwargs)

def localectl_status():
result = {}
for line in SysCommand(["localectl", "status"]):
key, value = line.strip().decode('UTF-8').split(': ', 1)
result[key.lower().replace(' ', '_')] = value

return result
4 changes: 4 additions & 0 deletions examples/guided.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ def perform_installation(mountpoint):
if archinstall.arguments.get('custom-commands', None):
archinstall.run_custom_user_commands(archinstall.arguments['custom-commands'], installation)

# After certain locale's has been set, this needs
# to be re-run to avoid issues such as https://github.com/archlinux/archinstall/issues/596
installation.mkinitcpio('-P')

installation.log("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation", fg="yellow")
if not archinstall.arguments.get('silent'):
prompt = str(_('Would you like to chroot into the newly created installation and perform post-installation configuration?'))
Expand Down