forked from Mirror/pmbootstrap
pmbootstrap init: add locale selection (MR 2004)
Adds a list of locales user can choose from on init step. If locale isn't default, then "lang" package is installed and LANG is changed to the chosen locale.
This commit is contained in:
parent
2247fc5aad
commit
196186df24
3 changed files with 45 additions and 0 deletions
|
@ -678,6 +678,7 @@ def create_device_rootfs(args, step, steps):
|
|||
logging.info(f'*** ({step}/{steps}) CREATE DEVICE ROOTFS ("{args.device}")'
|
||||
' ***')
|
||||
|
||||
suffix = f"rootfs_{args.device}"
|
||||
# Create user before installing packages, so post-install scripts of
|
||||
# pmaports can figure out the username (legacy reasons: pmaports#820)
|
||||
set_user(args)
|
||||
|
@ -698,6 +699,9 @@ def create_device_rootfs(args, step, steps):
|
|||
install_packages += args.extra_packages.split(",")
|
||||
if args.add:
|
||||
install_packages += args.add.split(",")
|
||||
locale_is_set = (args.locale != pmb.config.defaults["locale"])
|
||||
if locale_is_set:
|
||||
install_packages += ["lang", "musl-locales"]
|
||||
|
||||
pmb.helpers.repo.update(args, args.deviceinfo["arch"])
|
||||
|
||||
|
@ -725,6 +729,12 @@ def create_device_rootfs(args, step, steps):
|
|||
# Set timezone
|
||||
pmb.chroot.root(args, ["setup-timezone", "-z", args.timezone], suffix)
|
||||
|
||||
# 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)
|
||||
|
||||
# Set the hostname as the device name
|
||||
setup_hostname(args)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue