diff options
author | Frank de Brabander <debrabander@gmail.com> | 2022-12-06 19:18:05 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-12-08 10:49:53 +0000 |
commit | 79d689f5da5bf5eb4c5a767e10d581554e100008 (patch) | |
tree | 10f8b2ce554c8d3722f7a148ae71995e5de54efd /bitbake/lib/bb/utils.py | |
parent | 2015bf3eb82e043c3e3f75de9951d9133c8359dd (diff) | |
download | poky-79d689f5da5bf5eb4c5a767e10d581554e100008.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: a4ce040a6fd540a1cac52f808f909f9fcf8c961c)
Signed-off-by: Frank de Brabander <debrabander@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index f4da356338..0df522b372 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -13,6 +13,7 @@ import errno | |||
13 | import logging | 13 | import logging |
14 | import bb | 14 | import bb |
15 | import bb.msg | 15 | import bb.msg |
16 | import locale | ||
16 | import multiprocessing | 17 | import multiprocessing |
17 | import fcntl | 18 | import fcntl |
18 | import importlib | 19 | import importlib |
@@ -608,6 +609,21 @@ def preserved_envvars(): | |||
608 | ] | 609 | ] |
609 | return v + preserved_envvars_exported() | 610 | return v + preserved_envvars_exported() |
610 | 611 | ||
612 | def check_system_locale(): | ||
613 | """Make sure the required system locale are available and configured""" | ||
614 | default_locale = locale.getlocale(locale.LC_CTYPE) | ||
615 | |||
616 | try: | ||
617 | locale.setlocale(locale.LC_CTYPE, ("en_US", "UTF-8")) | ||
618 | except: | ||
619 | sys.exit("Please make sure locale 'en_US.UTF-8' is available on your system") | ||
620 | else: | ||
621 | locale.setlocale(locale.LC_CTYPE, default_locale) | ||
622 | |||
623 | if sys.getfilesystemencoding() != "utf-8": | ||
624 | sys.exit("Please use a locale setting which supports UTF-8 (such as LANG=en_US.UTF-8).\n" | ||
625 | "Python can't change the filesystem locale after loading so we need a UTF-8 when Python starts or things won't work.") | ||
626 | |||
611 | def filter_environment(good_vars): | 627 | def filter_environment(good_vars): |
612 | """ | 628 | """ |
613 | Create a pristine environment for bitbake. This will remove variables that | 629 | Create a pristine environment for bitbake. This will remove variables that |