[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 639a5fd8 5/5: Rework locales
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 639a5fd8 5/5: Rework locales |
Date: |
Mon, 3 Apr 2023 19:10:22 -0400 (EDT) |
branch: master
commit 639a5fd8dcbc5dcf3dc6c1e90ad515737e862a61
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Rework locales
Revisited commit f9ed2d2180133 of 20190418T1834Z, which set LC_ALL
globally, with the undesirable consequence that setting other LC_
variables had no effect.
* lmi_setup_20.sh: Install all desired locales in chroots. Attempt
to set defaults by calling 'update-locale', which doesn't seem to
work in chroots although release notes suggest that it should.
* gwc/.zshrc: Explicitly set every desired LC_ variable, taking care
to set both LC_COLLATE and LC_CTYPE together, to C.UTF-8 for rational
sorting (except for old redhat systems that lack C.UTF-8).
---
gwc/.zshrc | 8 ++++++--
lmi_setup_20.sh | 21 +++++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/gwc/.zshrc b/gwc/.zshrc
index 89f1e105..2d954995 100644
--- a/gwc/.zshrc
+++ b/gwc/.zshrc
@@ -45,15 +45,19 @@ export coefficiency="--jobs=$(nproc)"
# This should be unnecessary:
# export TZ=UCT
+# This should be unnecessary, but, most regrettably, it seems to
+# have a persistent nonempty value on one particular machine:
+unset LC_ALL
+
# redhat-based distributions may lack 'C.UTF-8'--see:
# https://bugzilla.redhat.com/show_bug.cgi?id=902094
if locale -a | grep --quiet C.UTF-8; then
pref_lc=C.UTF-8; else
pref_lc=en_US.UTF-8;
fi
-export LANG=en_US.UTF-8 LC_ALL=$pref_lc LC_TIME=en_DK.UTF-8 LC_COLLATE=$pref_lc
+export LANG=en_US.UTF-8 LC_TIME=en_DK.UTF-8 LC_COLLATE=$pref_lc
LC_CTYPE=$pref_lc
# Instead of assigning those variables, this is generally preferable:
-# update-locale LANG=en_US.UTF-8 LC_TIME=en_DK.UTF-8 LC_COLLATE=C.UTF-8
+# update-locale LANG=en_US.UTF-8 LC_TIME=en_DK.UTF-8 LC_COLLATE=$pref_lc
LC_CTYPE=$pref_lc
# but neither the chroot's nor the host's /etc/default/locale is
# sourced by schroot, which strives to set as few environment
# variables as possible.
diff --git a/lmi_setup_20.sh b/lmi_setup_20.sh
index 0837143a..31519b43 100755
--- a/lmi_setup_20.sh
+++ b/lmi_setup_20.sh
@@ -114,6 +114,7 @@ apt-get --assume-yes install \
libxml2-utils \
libxslt1-dev \
lld \
+ locales \
make \
mold \
patch \
@@ -158,5 +159,25 @@ apt-get --assume-yes install \
# Warning: The home dir /run/uuidd you specified can't be accessed: No such
file or directory
# Not creating home directory `/run/uuidd'.
+# Generate all desired locales:
+# C.UTF-8 for sorting without surprises
+# en_DK.UTF-8 for its rational date format
+# en_US.UTF-8 for general use
+
+sed -i /etc/locale.gen \
+ -e'/ C.UTF-8/s/^# *//' \
+ -e'/ en_DK.UTF-8/s/^# *//' \
+ -e'/ en_US.UTF-8/s/^# *//' \
+
+locale-gen
+
+# ...and set them as defaults, taking care to specify C.UTF-8 for
+# both LC_COLLATE and LC_CTYPE, for mutual consistency. Also set
+# these variables in .zshrc because it appears that schroot does
+# not source /etc/default/locale (though it should according to
+# the schroot-1.6.4 release notes).
+
+update-locale LANG=en_US.UTF-8 LC_TIME=en_DK.UTF-8 LC_COLLATE=C.UTF-8
LC_CTYPE=C.UTF-8
+
stamp=$(date -u +'%Y%m%dT%H%M%SZ')
echo "$stamp $0: Installed debian packages." | tee /dev/tty || true