Merge pull request #779 from mwhudson/utf8-fallback

call setlocale() and set LC_CTYPE to C.UTF-8 if it fails
This commit is contained in:
Michael Hudson-Doyle 2020-05-21 11:28:25 +12:00 committed by GitHub
commit 8628cbb0b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -3,7 +3,7 @@ early-commands:
- echo a - echo a
- sleep 1 - sleep 1
- echo a - echo a
locale: en_UK.UTF-8 locale: en_GB.UTF-8
refresh-installer: refresh-installer:
update: yes update: yes
channel: edge channel: edge

View File

@ -42,7 +42,7 @@ validate
python3 scripts/check-yaml-fields.py .subiquity/subiquity-curtin-install.conf \ python3 scripts/check-yaml-fields.py .subiquity/subiquity-curtin-install.conf \
debconf_selections.subiquity='"eek"' debconf_selections.subiquity='"eek"'
python3 scripts/check-yaml-fields.py .subiquity/var/lib/cloud/seed/nocloud-net/user-data \ python3 scripts/check-yaml-fields.py .subiquity/var/lib/cloud/seed/nocloud-net/user-data \
locale='"en_UK.UTF-8"' locale='"en_GB.UTF-8"'
grep -q 'finish: subiquity/InstallProgress/install/postinstall/install_package1: SUCCESS: installing package1' \ grep -q 'finish: subiquity/InstallProgress/install/postinstall/install_package1: SUCCESS: installing package1' \
.subiquity/subiquity-debug.log .subiquity/subiquity-debug.log
grep -q 'finish: subiquity/InstallProgress/install/postinstall/install_package2: SUCCESS: installing package2' \ grep -q 'finish: subiquity/InstallProgress/install/postinstall/install_package2: SUCCESS: installing package2' \

View File

@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import argparse import argparse
import locale
import logging import logging
import os import os
import fcntl import fcntl
@ -103,6 +104,13 @@ AUTO_ANSWERS_FILE = "/subiquity_config/answers.yaml"
def main(): def main():
# Python 3.7+ does more or less this by default, but we need to
# work with the Python 3.6 in bionic.
try:
locale.setlocale(locale.LC_ALL, "")
except locale.Error:
locale.setlocale(locale.LC_CTYPE, "C.UTF-8")
# Prefer utils from $SNAP, over system-wide # Prefer utils from $SNAP, over system-wide
snap = os.environ.get('SNAP') snap = os.environ.get('SNAP')
if snap: if snap: