aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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-13 08:17:57 -1000
commit0c6f86b60cfba67c20733516957c0a654eb2b44c (patch)
tree1f0e5e4851c0a8f96f8f71a9e729fc352b65d99b /lib
parent2802adb572eb73a3eb2725a74a9bbdaafc543fa7 (diff)
downloadbitbake-0c6f86b60cfba67c20733516957c0a654eb2b44c.tar.gz
bin/utils: Ensure locale en_US.UTF-8 is available on the systemyocto-4.0.11yocto-4.0.102022-04.11-kirkstone2022-04.10-kirkstone2.0.112.0.10
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] 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 'lib')
-rw-r--r--lib/bb/utils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index cdb3c6864..3f7f82d17 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -13,6 +13,7 @@ import errno
import logging
import bb
import bb.msg
+import locale
import multiprocessing
import fcntl
import importlib
@@ -606,6 +607,21 @@ def preserved_envvars():
]
return v + preserved_envvars_exported()
+def check_system_locale():
+ """Make sure the required system locale are available and configured"""
+ default_locale = locale.getlocale(locale.LC_CTYPE)
+
+ try:
+ locale.setlocale(locale.LC_CTYPE, ("en_US", "UTF-8"))
+ except:
+ sys.exit("Please make sure locale 'en_US.UTF-8' is available on your system")
+ else:
+ locale.setlocale(locale.LC_CTYPE, default_locale)
+
+ if sys.getfilesystemencoding() != "utf-8":
+ sys.exit("Please use a locale setting which supports UTF-8 (such as LANG=en_US.UTF-8).\n"
+ "Python can't change the filesystem locale after loading so we need a UTF-8 when Python starts or things won't work.")
+
def filter_environment(good_vars):
"""
Create a pristine environment for bitbake. This will remove variables that