Fix locale warnings during chroot operations

Build process generated numerous locale warnings like:
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
perl: warning: Setting locale failed

This happened because the Docker container and host environment were
configured to use `en_US.UTF-8`, but the rootfs cache may not contain
this locale (only `C.utf8` and whatever `DEST_LANG` specifies,
e.g. `en_GB.utf8`).

When `chroot_sdcard` runs commands inside the rootfs, environment variables
are inherited from the host/Docker, causing locale lookup failures.

Then use `C.UTF-8` locale for the build environment instead of `en_US.UTF-8`.
This locale is always available in rootfs immediately after mmdebstrap,
requiring no generation.

Changes
`lib/functions/host/docker.sh`: Remove `en_US.UTF-8` locale generation,
set `LANG=C.UTF-8` in container environment
`lib/functions/host/prepare-host.sh`: Change locale exports
from `en_US.UTF-8` to `C.UTF-8`
This commit is contained in:
Igor Velkov 2026-01-04 03:37:15 +02:00 committed by Igor
parent 43c7710bfd
commit 3e71438048
2 changed files with 4 additions and 8 deletions

View File

@ -292,10 +292,9 @@ function docker_cli_prepare_dockerfile() {
${c}RUN echo "--> CACHE MISS IN DOCKERFILE: apt packages." && \\
${c} DEBIAN_FRONTEND=noninteractive apt-get -y update && \\
${c} DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ${BASIC_DEPS[@]} ${host_dependencies[@]}
${c}RUN sed -i 's/# en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen
${c}RUN locale-gen
${c}# Use C.UTF-8 locale which is available in rootfs from the very first command
WORKDIR ${DOCKER_ARMBIAN_TARGET_PATH}
ENV ARMBIAN_RUNNING_IN_CONTAINER=yes
ENV ARMBIAN_RUNNING_IN_CONTAINER=yes LANG=C.UTF-8
ADD . ${DOCKER_ARMBIAN_TARGET_PATH}/
${c}${c_req}RUN echo "--> CACHE MISS IN DOCKERFILE: running Armbian requirements initialization." && \\
${c}${c_req} ARMBIAN_INSIDE_DOCKERFILE_BUILD="yes" /bin/bash "${DOCKER_ARMBIAN_TARGET_PATH}/compile.sh" requirements SHOW_LOG=yes && \\

View File

@ -57,11 +57,8 @@ function prepare_host_noninteractive() {
display_alert "locale-gen is not installed @host" "skipping locale-gen -- problems might arise" "warn"
fi
# Let's try and get all log output in English, overriding the builder's chosen or default language
export LANG="en_US.UTF-8"
export LANGUAGE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
# Use C.UTF-8 locale which is always available in rootfs from the very first command
export LANG="C.UTF-8"
declare -g USE_LOCAL_APT_DEB_CACHE=${USE_LOCAL_APT_DEB_CACHE:-yes} # Use SRC/cache/aptcache as local apt cache by default
display_alert "Using local apt cache?" "USE_LOCAL_APT_DEB_CACHE: ${USE_LOCAL_APT_DEB_CACHE}" "debug"