From f1a83abe60b4ef8b2652e4c8e1d11a9afc909b71 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 11 Apr 2021 16:27:28 +1200 Subject: buildman: Use bytes for the environment At present we sometimes see problems in gitlab where the environment has 0x80 characters or sequences which are not valid UTF-8. Avoid this by using bytes for the environment, both internal to buildman and when writing out the 'env' file. Add a test to make sure this works as expected. Reported-by: Marek Vasut Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file") Signed-off-by: Simon Glass --- tools/buildman/builderthread.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'tools/buildman/builderthread.py') diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index ddb3eab8c0..48128cf673 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -351,10 +351,9 @@ class BuilderThread(threading.Thread): # Write out the image and function size information and an objdump env = result.toolchain.MakeEnvironment(self.builder.full_path) - with open(os.path.join(build_dir, 'out-env'), 'w', - encoding='utf-8') as fd: + with open(os.path.join(build_dir, 'out-env'), 'wb') as fd: for var in sorted(env.keys()): - print('%s="%s"' % (var, env[var]), file=fd) + fd.write(b'%s="%s"' % (var, env[var])) lines = [] for fname in BASE_ELF_FILENAMES: cmd = ['%snm' % self.toolchain.cross, '--size-sort', fname] -- cgit v1.2.3