K-114: set up locales in setup_base_apt (C.UTF-8 during install, en_US.UTF-8 default)
CI / Shell-Lint (bash -n, source-check, Validierungs-Tests) (pull_request) Successful in 9s

LXC templates ship without a configured locale, so every apt/perl run
warned 'Setting locale failed'. setup_base_apt now exports C.UTF-8 for
the install run itself, installs the locales package, generates
en_US.UTF-8 and sets it as the system default via update-locale.
This commit is contained in:
2026-06-12 14:42:03 +02:00
parent aa3ad2f716
commit 7f64b12a77
+18 -2
View File
@@ -15,10 +15,14 @@ msg_warn() { echo -e "${YELLOW}[!]${NC} $*"; }
msg_err() { echo -e "${RED}[✗]${NC} $*" >&2; }
# ── apt ──────────────────────────────────────────────────────────────────────
# Always installs: ca-certificates curl openssl tzdata gnupg
# Always installs: ca-certificates curl openssl tzdata gnupg locales
# Additional packages can be passed as args.
setup_base_apt() {
export DEBIAN_FRONTEND=noninteractive
# C.UTF-8 ist in glibc eingebaut und damit schon VOR dem locales-Paket
# verfügbar — deckt den ersten apt/dpkg-Lauf ab (keine perl-Warnungen
# "Setting locale failed" mehr, LXC-Templates kommen ohne Locale).
export LANG=C.UTF-8 LC_ALL=C.UTF-8
msg_info "Updating apt index..."
apt-get update -qq
if [[ $# -gt 0 ]]; then
@@ -27,12 +31,24 @@ setup_base_apt() {
msg_info "Installing base packages..."
fi
apt-get install -y -qq \
ca-certificates curl openssl tzdata gnupg \
ca-certificates curl openssl tzdata gnupg locales \
"$@" \
>/dev/null
setup_locales
msg_ok "apt setup complete"
}
# en_US.UTF-8 generieren und systemweit als Default setzen; C.UTF-8 braucht
# keine Generierung (glibc-built-in). Idempotent: sed greift nur auf die
# auskommentierte Zeile, locale-gen/update-locale sind re-run-sicher.
setup_locales() {
msg_info "Generating locales (en_US.UTF-8; C.UTF-8 built-in)..."
sed -i 's/^# *en_US\.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
locale-gen >/dev/null
update-locale LANG=en_US.UTF-8
msg_ok "Default locale: en_US.UTF-8"
}
apt_cleanup() {
apt-get autoremove -y -qq >/dev/null || true
apt-get autoclean -qq >/dev/null || true