From acb94beaf98d038b19940cb49d2f6be68e006b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= Date: Fri, 12 May 2023 22:07:09 +0200 Subject: [PATCH] install: write new file instead of modifying locale.sh from alpine-baselayout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First of all, modifying in-place the file owned by alpine-baselayout has the consequence of that file never being updated by APK. This is an issue changes happen upstream. And I just fixed[1] an issue upstream that had to be with that exact file, so make sure that from now on, we're writing to another file that sorts before the one from alpine-baselayout. Additionally, equivalently to the fix in [1] for bug [2], don't set the variable unconditionally, but instead use its current value if it's already set. [1] https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/46718 [2] https://gitlab.alpinelinux.org/alpine/aports/-/issues/14862 Signed-off-by: Pablo Correa Gómez Reviewed-by: Oliver Smith Tested-by: Oliver Smith Co-developed-by: Oliver Smith Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3CDB9P192MB12912380DD72F8A840694B44C7759@DB9P192MB1291.EURP192.PROD.OUTLOOK.COM%3E --- pmb/install/_install.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pmb/install/_install.py b/pmb/install/_install.py index 216b8419..28f40459 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -1032,9 +1032,12 @@ def create_device_rootfs(args, step, steps): # Set locale if locale_is_set: - pmb.chroot.root(args, ["sed", "-i", - f"s/LANG=C.UTF-8/LANG={args.locale}/", - "/etc/profile.d/locale.sh"], suffix) + # 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(args.locale)}}}" + pmb.chroot.root(args, ["sh", "-c", f"echo {shlex.quote(line)}" + " > /etc/profile.d/10locale-pmos.sh"], suffix) # Set the hostname as the device name setup_hostname(args)