From 50d2bb45f4590d86e6510585e992844fce81f28d Mon Sep 17 00:00:00 2001 From: fossdd Date: Tue, 4 Feb 2025 19:54:39 +0100 Subject: [PATCH] pmb.install._install: write lang configuration to /etc/locale.conf Previous reasons to write the locales to /etc/profile.d/.. was because musl-locales do only support reading from environment variables and not /etc/locale.conf. However systemd-localed (and glibc) uses /etc/locale.conf to read and write locale configurations. gnome-control-center, for example, uses localed to change locales. In the sake of a single source of truth, allow pmb to write to /etc/locale.conf and allow its consumers (e.g. g-c-c via systemd) to read/change these variables. Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2547 --- pmb/install/_install.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pmb/install/_install.py b/pmb/install/_install.py index fd951d37..3f95b5fd 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -399,9 +399,11 @@ def setup_locale(chroot: Chroot, locale: str) -> None: # 10locale-pmos.sh gets sourced before 20locale.sh from # alpine-baselayout by /etc/profile. Since they don't override the # locale if it exists, it warranties we have preference - line = f"export LANG=${{LANG:-{shlex.quote(locale)}}}" + pmb.chroot.root(["sh", "-c", f"echo LANG={shlex.quote(locale)} > /etc/locale.conf"], chroot) + # musl-locales doesn't read from /etc/locale.conf, only from environment variables + # TODO: once musl implements locales (hopefully with /etc/locale.conf support) the following should be removed pmb.chroot.root( - ["sh", "-c", f"echo {shlex.quote(line)} > /etc/profile.d/10locale-pmos.sh"], chroot + ["sh", "-c", "echo source /etc/locale.conf > /etc/profile.d/10locale-pmos.sh"], chroot ) # add keyboard layout related to locale and layout switcher xkb_layout = get_xkb_layout(locale)