summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbitbake/bin/bitbake3
-rwxr-xr-xbitbake/bin/bitbake-server5
-rwxr-xr-xbitbake/bin/bitbake-worker3
-rw-r--r--bitbake/lib/bb/utils.py16
4 files changed, 21 insertions, 6 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 042c91807d..0b9cc6297c 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -25,8 +25,7 @@ except RuntimeError as exc:
25from bb import cookerdata 25from bb import cookerdata
26from bb.main import bitbake_main, BitBakeConfigParameters, BBMainException 26from bb.main import bitbake_main, BitBakeConfigParameters, BBMainException
27 27
28if sys.getfilesystemencoding() != "utf-8": 28bb.utils.check_system_locale()
29 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.")
30 29
31__version__ = "2.0.0" 30__version__ = "2.0.0"
32 31
diff --git a/bitbake/bin/bitbake-server b/bitbake/bin/bitbake-server
index f53f88b6b0..d00bb068b8 100755
--- a/bitbake/bin/bitbake-server
+++ b/bitbake/bin/bitbake-server
@@ -12,8 +12,9 @@ warnings.simplefilter("default")
12import logging 12import logging
13sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) 13sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
14 14
15if sys.getfilesystemencoding() != "utf-8": 15import bb
16 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.") 16
17bb.utils.check_system_locale()
17 18
18# Users shouldn't be running this code directly 19# Users shouldn't be running this code directly
19if len(sys.argv) != 10 or not sys.argv[1].startswith("decafbad"): 20if len(sys.argv) != 10 or not sys.argv[1].startswith("decafbad"):
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index 2f3e9f72f9..5e62bc20de 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -24,8 +24,7 @@ import subprocess
24from multiprocessing import Lock 24from multiprocessing import Lock
25from threading import Thread 25from threading import Thread
26 26
27if sys.getfilesystemencoding() != "utf-8": 27bb.utils.check_system_locale()
28 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.")
29 28
30# Users shouldn't be running this code directly 29# Users shouldn't be running this code directly
31if len(sys.argv) != 2 or not sys.argv[1].startswith("decafbad"): 30if len(sys.argv) != 2 or not sys.argv[1].startswith("decafbad"):
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