diff mbox series

oeqa/selftest: add a newline in local.conf (newbuilddir)

Message ID 20250222125822.385265-1-gavrosc@yahoo.com
State New
Headers show
Series oeqa/selftest: add a newline in local.conf (newbuilddir) | expand

Commit Message

Christos Gavros Feb. 22, 2025, 12:58 p.m. UTC
If the build-st/conf/local.conf does not end with a newline
when is generated then add one
Fixes [YOCTO #15734]

CC: Yoann Congal <yoann.congal@smile.fr>
CC: Randy MacLeod <randy.macleod@windriver.com>
Signed-off-by: Christos Gavros <gavrosc@yahoo.com>
---
 meta/lib/oeqa/selftest/context.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py
index 5eb4cc44fd..986fe8e1db 100644
--- a/meta/lib/oeqa/selftest/context.py
+++ b/meta/lib/oeqa/selftest/context.py
@@ -102,6 +102,16 @@  class OESelftestTestContext(OETestContext):
         oe.path.copytree(builddir + "/cache", newbuilddir + "/cache")
         oe.path.copytree(selftestdir, newselftestdir)
 
+        # if the last line of local.conf in newbuilddir is not empty or does not end with newline then add one
+        localconf_path = newbuilddir + "/conf/local.conf"
+        last_line = ""
+        with open(localconf_path, "r", encoding="utf-8") as f:
+            for line in f:
+                last_line = line
+
+        if last_line != "" and not last_line.endswith("\n"):
+            subprocess.check_output("echo >> %s/conf/local.conf" % newbuilddir, cwd=newbuilddir, shell=True)
+
         subprocess.check_output("git init && git add * && git commit -a -m 'initial'", cwd=newselftestdir, shell=True)
 
         # Tried to used bitbake-layers add/remove but it requires recipe parsing and hence is too slow