enter_chroot.sh: Translate C.UTF-8 to a supported locale configuration
Several distributions offer a C.UTF-8 locale, but that locale does not
exist in upstream glibc. This results in errors from locale, perl, and
other tools, complaining that the current locales don't exist.
To work around this, translate C.UTF-8 to the guaranteed-to-exist
en_US.UTF-8 locale within the chroot. To get behavior closer to that of
the C locale, translate LC_COLLATE to C rather than en_US.UTF-8.
BUG=None
TEST="LANG=C.UTF-8 cros_sdk locale" and similar permutations.
Change-Id: I760e3df6444a6f4c58adbeb33637bf9363af3c41
Reviewed-on: https://chromium-review.googlesource.com/203785
Tested-by: Josh Triplett <josh@joshtriplett.org>
Commit-Queue: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh
index d4704ce..443d563 100755
--- a/sdk_lib/enter_chroot.sh
+++ b/sdk_lib/enter_chroot.sh
@@ -495,6 +495,20 @@
"EXTERNAL_TRUNK_PATH=${FLAGS_trunk}"
)
+# Translate C.UTF-8 into something we support. Remove this when our glibc
+# starts supporting C.UTF-8. https://bugzilla.redhat.com/show_bug.cgi?id=902094
+for var in LANG \
+ LC_{ADDRESS,ALL,COLLATE,CTYPE,IDENTIFICATION,MEASUREMENT,MESSAGES} \
+ LC_{MONETARY,NAME,NUMERIC,PAPER,TELEPHONE,TIME}; do
+ if [[ ${!var} =~ C\.[Uu][Tt][Ff]-?8 ]]; then
+ if [[ ${var} == LC_COLLATE ]]; then
+ export LC_COLLATE=C
+ else
+ export ${var}=en_US.UTF-8
+ fi
+ fi
+done
+
# Add the whitelisted environment variables to CHROOT_PASSTHRU.
load_environment_whitelist
for var in "${ENVIRONMENT_WHITELIST[@]}" ; do