From 79d689f5da5bf5eb4c5a767e10d581554e100008 Mon Sep 17 00:00:00 2001 From: Frank de Brabander Date: Tue, 6 Dec 2022 19:18:05 +0100 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/bin/bitbake | 3 +-- bitbake/bin/bitbake-server | 5 +++-- bitbake/bin/bitbake-worker | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'bitbake/bin') diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake index 7cbf88f480..f869eb4854 100755 --- a/bitbake/bin/bitbake +++ b/bitbake/bin/bitbake @@ -25,8 +25,7 @@ except RuntimeError as exc: from bb import cookerdata from bb.main import bitbake_main, BitBakeConfigParameters, BBMainException -if sys.getfilesystemencoding() != "utf-8": - sys.exit("Please use a locale setting which supports UTF-8 (such as LANG=en_US.UTF-8).\nPython can't change the filesystem locale after loading so we need a UTF-8 when Python starts or things won't work.") +bb.utils.check_system_locale() __version__ = "2.2.0" diff --git a/bitbake/bin/bitbake-server b/bitbake/bin/bitbake-server index 825e9d56af..454a3919aa 100755 --- a/bitbake/bin/bitbake-server +++ b/bitbake/bin/bitbake-server @@ -12,8 +12,9 @@ warnings.simplefilter("default") import logging sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) -if sys.getfilesystemencoding() != "utf-8": - sys.exit("Please use a locale setting which supports UTF-8 (such as LANG=en_US.UTF-8).\nPython can't change the filesystem locale after loading so we need a UTF-8 when Python starts or things won't work.") +import bb + +bb.utils.check_system_locale() # Users shouldn't be running this code directly if len(sys.argv) != 11 or not sys.argv[1].startswith("decafbad"): diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker index 3799b170cb..3cacdb0cec 100755 --- a/bitbake/bin/bitbake-worker +++ b/bitbake/bin/bitbake-worker @@ -24,8 +24,7 @@ import subprocess from multiprocessing import Lock from threading import Thread -if sys.getfilesystemencoding() != "utf-8": - sys.exit("Please use a locale setting which supports UTF-8 (such as LANG=en_US.UTF-8).\nPython can't change the filesystem locale after loading so we need a UTF-8 when Python starts or things won't work.") +bb.utils.check_system_locale() # Users shouldn't be running this code directly if len(sys.argv) != 2 or not sys.argv[1].startswith("decafbad"): -- cgit v1.2.3-54-g00ecf