* [bitbake][kirkstone][2.0][PATCH 0/1] Patch review
@ 2023-04-15 15:29 Steve Sakoman
2023-04-15 15:29 ` [bitbake][kirkstone][2.0][PATCH 1/1] bin/utils: Ensure locale en_US.UTF-8 is available on the system Steve Sakoman
0 siblings, 1 reply; 2+ messages in thread
From: Steve Sakoman @ 2023-04-15 15:29 UTC (permalink / raw)
To: bitbake-devel
Please review this set of patches for kirkstone/2.0 and have comments back by
end of day Tuesday.
Passed a-full on autobuilder:
https://autobuilder.yoctoproject.org/typhoon/#/builders/83/builds/5185
The following changes since commit 2802adb572eb73a3eb2725a74a9bbdaafc543fa7:
fetch/git: Fix local clone url to make it work with repo (2023-03-31 04:28:22 -1000)
are available in the Git repository at:
https://git.openembedded.org/bitbake-contrib stable/2.0-nut
http://cgit.openembedded.org/bitbake-contrib/log/?h=stable/2.0-nut
Frank de Brabander (1):
bin/utils: Ensure locale en_US.UTF-8 is available on the system
bin/bitbake | 3 +--
bin/bitbake-server | 5 +++--
bin/bitbake-worker | 3 +--
lib/bb/utils.py | 16 ++++++++++++++++
4 files changed, 21 insertions(+), 6 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [bitbake][kirkstone][2.0][PATCH 1/1] bin/utils: Ensure locale en_US.UTF-8 is available on the system
2023-04-15 15:29 [bitbake][kirkstone][2.0][PATCH 0/1] Patch review Steve Sakoman
@ 2023-04-15 15:29 ` Steve Sakoman
0 siblings, 0 replies; 2+ messages in thread
From: Steve Sakoman @ 2023-04-15 15:29 UTC (permalink / raw)
To: bitbake-devel
From: Frank de Brabander <debrabander@gmail.com>
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>
---
bin/bitbake | 3 +--
bin/bitbake-server | 5 +++--
bin/bitbake-worker | 3 +--
lib/bb/utils.py | 16 ++++++++++++++++
4 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/bin/bitbake b/bin/bitbake
index 042c9180..0b9cc629 100755
--- a/bin/bitbake
+++ b/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.0.0"
diff --git a/bin/bitbake-server b/bin/bitbake-server
index f53f88b6..d00bb068 100755
--- a/bin/bitbake-server
+++ b/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) != 10 or not sys.argv[1].startswith("decafbad"):
diff --git a/bin/bitbake-worker b/bin/bitbake-worker
index 2f3e9f72..5e62bc20 100755
--- a/bin/bitbake-worker
+++ b/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"):
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index cdb3c686..3f7f82d1 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
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-15 15:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-15 15:29 [bitbake][kirkstone][2.0][PATCH 0/1] Patch review Steve Sakoman
2023-04-15 15:29 ` [bitbake][kirkstone][2.0][PATCH 1/1] bin/utils: Ensure locale en_US.UTF-8 is available on the system Steve Sakoman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).