locale: Use C.UTF-8 rather than en_US.UTF-8.

The `en_US.UTF-8` locale may not be configured or generated on all
installs; it also requires that the `locales` package be installed.
If users generate the `en_US.UTF-8` locale without adding it to the
permanent set of system locales, the generated `en_US.UTF-8` stops
working when the `locales` package is updated.

Switch to using `C.UTF-8` in all cases, which is guaranteed to be
installed.

Fixes #15819.
This commit is contained in:
Alex Vandiver
2021-04-30 12:57:25 -07:00
committed by Tim Abbott
parent a9688ceb75
commit eda9ce2364
13 changed files with 34 additions and 44 deletions

View File

@@ -40,19 +40,10 @@ RUN apt-get update \
unzip zip jq \
python3-pip \
&& ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime \
&& {{ locale-gen en_US.UTF-8 || true; }} \
&& echo "LC_ALL=en_US.UTF-8" | sudo tee -a /etc/default/locale
&& echo "LC_ALL=C.UTF-8" | sudo tee -a /etc/default/locale
# Set the locale, together with the locale-related steps above.
# It's not entirely clear why, but alternatives that don't work include
# * using `C.UTF-8` instead of `en_US.UTF-8`, here and above
# (causes mysterious failures in zerver.tests.test_message_fetch)
# * skipping the /etc/default/locale step above (ditto)
# * skipping this ENV instruction (causes provision to fail,
# because Python tries to use the `ascii` codec)
# Details in https://github.com/zulip/zulip/pull/7762#issuecomment-353197289
# and particularly https://circleci.com/gh/hackerkid/zulip/80 .
ENV LC_ALL en_US.UTF-8
ENV LC_ALL C.UTF-8
# Install Docker. This logic comes from Circle's Dockerfile; it's probably
# faster than the upstream-recommended approach of using their apt repo,

View File

@@ -3,8 +3,8 @@ FROM ubuntu:18.04
ARG UBUNTU_MIRROR
# Basic packages and dependencies of docker-systemctl-replacement
RUN echo locales locales/default_environment_locale select en_US.UTF-8 | debconf-set-selections \
&& echo locales locales/locales_to_be_generated select "en_US.UTF-8 UTF-8" | debconf-set-selections \
RUN echo locales locales/default_environment_locale select C.UTF-8 | debconf-set-selections \
&& echo locales locales/locales_to_be_generated select "C.UTF-8 UTF-8" | debconf-set-selections \
&& { [ ! "$UBUNTU_MIRROR" ] || sed -i "s|http://\(\w*\.\)*archive\.ubuntu\.com/ubuntu/\? |$UBUNTU_MIRROR |" /etc/apt/sources.list; } \
# This restores man pages and other documentation that have been
# stripped from the default Ubuntu cloud image and installs

View File

@@ -60,8 +60,8 @@ run apt-get install -y --no-install-recommends \
"${extra_packages[@]}"
run ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime
run locale-gen en_US.UTF-8 || true
echo "LC_ALL=en_US.UTF-8" | run tee /etc/default/locale
run locale-gen C.UTF-8 || true
echo "LC_ALL=C.UTF-8" | run tee /etc/default/locale
# TODO: on failure, either stop or print message
lxc-stop -n "$CONTAINER_NAME"

View File

@@ -20,7 +20,7 @@ os.environ["PUPPETEER_TESTS"] = "1"
# The locale can have impact how Firefox does locale-aware sorting,
# which we do verify in some tests.
os.environ["LC_ALL"] = "en_US.UTF-8"
os.environ["LC_ALL"] = "C.UTF-8"
os.environ["CHROMIUM_EXECUTABLE"] = os.path.join(ZULIP_PATH, "node_modules/.bin/chromium")
os.environ.pop("http_proxy", "")