cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #05038
[Merge] ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master
Scott Moser has proposed merging ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master.
Commit message:
Z99-cloud-locale-test.sh: shorten message and change locale to C.UTF-8.
Two basic changes here to the behavior of Z99-cloud-locale-test.sh
when a locale found in LC_* settings is not present on the system:
a.) shorten the message.
b.) change the locale to C.UTF-8.
LP: #1134036
Requested reviews:
cloud-init commiters (cloud-init-dev)
Related bugs:
Bug #1134036 in maas (Ubuntu): "Failure when using ssh with a locale that is not configured on the server"
https://bugs.launchpad.net/ubuntu/+source/maas/+bug/1134036
For more details, see:
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/348065
see commit message
--
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master.
diff --git a/tools/Z99-cloud-locale-test.sh b/tools/Z99-cloud-locale-test.sh
index 4978d87..33d1214 100644
--- a/tools/Z99-cloud-locale-test.sh
+++ b/tools/Z99-cloud-locale-test.sh
@@ -6,9 +6,8 @@
# (c) 2012, Canonical Group, Ltd.
#
# This file is part of cloud-init. See LICENSE file for license information.
-
-# Purpose: Detect invalid locale settings and inform the user
-# of how to fix them.
+
+# Purpose: Detect invalid locale, change to C-UTF-8. and inform the user.
locale_warn() {
local bad_names="" bad_lcs="" key="" val="" var="" vars="" bad_kv=""
@@ -33,6 +32,10 @@ locale_warn() {
vars="${vars} $key=$val";;
esac
done
+
+ if [ "${bad_names#* LC_ALL}" != "${bad_names}" ]; then
+ bad_names=LC_ALL
+ fi
for bad in $bad_names; do
for var in ${vars}; do
[ "${bad}" = "${var%=*}" ] || continue
@@ -47,14 +50,7 @@ locale_warn() {
bad_kv=${bad_kv# }
[ -n "$bad_lcs" ] || return 0
- printf "_____________________________________________________________________\n"
- printf "WARNING! Your environment specifies an invalid locale.\n"
- printf " The unknown environment variables are:\n %s\n" "$bad_kv"
- printf " This can affect your user experience significantly, including the\n"
- printf " ability to manage packages. You may install the locales by running:\n\n"
-
- local bad invalid="" to_gen="" sfile="/usr/share/i18n/SUPPORTED"
- local pkgs=""
+ local bad="" pkgs="" invalid="" to_gen="" sfile="/usr/share/i18n/SUPPORTED"
if [ -e "$sfile" ]; then
for bad in ${bad_lcs}; do
grep -q -i "${bad}" "$sfile" &&
@@ -62,7 +58,6 @@ locale_warn() {
invalid="${invalid} ${bad}"
done
else
- printf " sudo apt-get install locales\n"
to_gen=$bad_lcs
fi
to_gen=${to_gen# }
@@ -73,28 +68,20 @@ locale_warn() {
done
pkgs=${pkgs# }
- if [ -n "${pkgs}" ]; then
- printf " sudo apt-get install ${pkgs# }\n"
- printf " or\n"
- printf " sudo locale-gen ${to_gen# }\n"
- printf "\n"
- fi
- for bad in ${invalid}; do
- printf "WARNING: '${bad}' is an invalid locale\n"
- done
-
- printf "To see all available language packs, run:\n"
- printf " apt-cache search \"^language-pack-[a-z][a-z]$\"\n"
- printf "To disable this message for all users, run:\n"
- printf " sudo touch /var/lib/cloud/instance/locale-check.skip\n"
- printf "_____________________________________________________________________\n\n"
-
- # only show the message once
- : > ~/.cloud-locale-test.skip 2>/dev/null || :
+ echo "Your locale (${bad_kv}) is not present and has been"
+ echo "changed to LC_ALL=C.UTF-8. To install native locales:"
+ echo " sudo apt-get install locales${pkgs:+ ${pkgs}}"
+ return 1
}
-[ -f ~/.cloud-locale-test.skip -o -f /var/lib/cloud/instance/locale-check.skip ] ||
- locale 2>&1 | locale_warn
+if [ ! -f ~/.cloud-locale-test.skip ] &&
+ [ ! -f /var/lib/cloud/instance/locale-check.skip ]; then
+ if locale 2>&1 | locale_warn; then
+ LC_ALL=C.UTF-8
+ # only show the message once
+ : > ~/.cloud-locale-test.skip 2>/dev/null || :
+ fi
+fi
unset locale_warn
# vi: ts=4 expandtab
Follow ups
-
[Merge] ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master
From: Scott Moser, 2018-09-14
-
[Merge] ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master
From: Scott Moser, 2018-06-15
-
Re: [Merge] ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master
From: Scott Moser, 2018-06-15
-
Re: [Merge] ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master
From: Steve Langasek, 2018-06-15
-
Re: [Merge] ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master
From: Steve Langasek, 2018-06-15
-
Re: [Merge] ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master
From: Scott Moser, 2018-06-15
-
Re: [Merge] ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master
From: Steve Langasek, 2018-06-15
-
Re: [Merge] ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master
From: Server Team CI bot, 2018-06-15
-
Re: [Merge] ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master
From: Server Team CI bot, 2018-06-15
-
[Merge] ~smoser/cloud-init:fix/1134036-locale-message-change into cloud-init:master
From: Scott Moser, 2018-06-15