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
This commit is contained in:
fossdd 2025-02-04 19:54:39 +01:00 committed by Oliver Smith
parent 9656c53a6a
commit 50d2bb45f4
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -399,9 +399,11 @@ def setup_locale(chroot: Chroot, locale: str) -> None:
# 10locale-pmos.sh gets sourced before 20locale.sh from # 10locale-pmos.sh gets sourced before 20locale.sh from
# alpine-baselayout by /etc/profile. Since they don't override the # alpine-baselayout by /etc/profile. Since they don't override the
# locale if it exists, it warranties we have preference # 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( 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 # add keyboard layout related to locale and layout switcher
xkb_layout = get_xkb_layout(locale) xkb_layout = get_xkb_layout(locale)