summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorFrank de Brabander <debrabander@gmail.com>2022-12-06 19:18:05 +0100
committerSteve Sakoman <steve@sakoman.com>2023-04-26 04:03:21 -1000
commitee5ff08d87a84f957af29bdf96ef232efdb229ae (patch)
tree48fbf184043fbe74b089ac7ed06def460f8f040e /bitbake/lib/bb
parentfa856e0dac16e13991561882bc6ad4c830674d78 (diff)
downloadpoky-ee5ff08d87a84f957af29bdf96ef232efdb229ae.tar.gz
bitbake: bin/utils: Ensure locale en_US.UTF-8 is available on the system
Get rid of the duplicate code and add extra check that the locale en_US.UTF-8 is available on the system. This new helper method is now located right above the method filter_environment() which sets LC_ALL environment variable to 'en_US.UTF-8'. [YOCTO #10165] (Bitbake rev: 0c6f86b60cfba67c20733516957c0a654eb2b44c) Signed-off-by: Frank de Brabander <debrabander@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit a4ce040a6fd540a1cac52f808f909f9fcf8c961c) Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/utils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index cdb3c6864b..3f7f82d17d 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -13,6 +13,7 @@ import errno
13import logging 13import logging
14import bb 14import bb
15import bb.msg 15import bb.msg
16import locale
16import multiprocessing 17import multiprocessing
17import fcntl 18import fcntl
18import importlib 19import importlib
@@ -606,6 +607,21 @@ def preserved_envvars():
606 ] 607 ]
607 return v + preserved_envvars_exported() 608 return v + preserved_envvars_exported()
608 609
610def check_system_locale():
611 """Make sure the required system locale are available and configured"""
612 default_locale = locale.getlocale(locale.LC_CTYPE)
613
614 try:
615 locale.setlocale(locale.LC_CTYPE, ("en_US", "UTF-8"))
616 except:
617 sys.exit("Please make sure locale 'en_US.UTF-8' is available on your system")
618 else:
619 locale.setlocale(locale.LC_CTYPE, default_locale)
620
621 if sys.getfilesystemencoding() != "utf-8":
622 sys.exit("Please use a locale setting which supports UTF-8 (such as LANG=en_US.UTF-8).\n"
623 "Python can't change the filesystem locale after loading so we need a UTF-8 when Python starts or things won't work.")
624
609def filter_environment(good_vars): 625def filter_environment(good_vars):
610 """ 626 """
611 Create a pristine environment for bitbake. This will remove variables that 627 Create a pristine environment for bitbake. This will remove variables that