acb94beaf98d038b19940cb49d2f6be68e006b56 — Pablo Correa Gómez 9 months ago d200414
install: write new file instead of modifying locale.sh from alpine-baselayout

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 <ablocorrea@hotmail.com>
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Tested-by: Oliver Smith <ollieparanoid@postmarketos.org>
Co-developed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3CDB9P192MB12912380DD72F8A840694B44C7759@DB9P192MB1291.EURP192.PROD.OUTLOOK.COM%3E
1 files changed, 6 insertions(+), 3 deletions(-)

M pmb/install/_install.py
M pmb/install/_install.py => pmb/install/_install.py +6 -3
@@ 1032,9 1032,12 @@ def create_device_rootfs(args, step, steps):

    # Set locale
    if locale_is_set:
        pmb.chroot.root(args, ["sed", "-i",
                               "/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