diff mbox series

[1/2] knotty: print an error if MACHINE is not set

Message ID 20241206162441.894274-1-chris.laplante@agilent.com
State Accepted, archived
Commit 7d3f3655b2f610f76898c84b8b97ef2e26529c41
Headers show
Series [1/2] knotty: print an error if MACHINE is not set | expand

Commit Message

chris.laplante@agilent.com Dec. 6, 2024, 4:24 p.m. UTC
From: Chris Laplante <chris.laplante@agilent.com>

When the user forgets to set MACHINE, bitbake just exits without
printing anything.

This is because BB_CONSOLELOG ends up with an unexpanded '${MACHINE}', which
bb.utils.mkdirhier tries to report using bb.fatal. But bb.fatal utilizes the
very logging infrastructure that this code was trying to setup.

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
---
 lib/bb/ui/knotty.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

--
2.43.0
diff mbox series

Patch

diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index 3784c93ad8..881df9e5fb 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -555,8 +555,18 @@  def main(server, eventHandler, params, tf = TerminalFilter):
                 }
             })

-        bb.utils.mkdirhier(os.path.dirname(consolelogfile))
-        loglink = os.path.join(os.path.dirname(consolelogfile), 'console-latest.log')
+        consolelogdirname = os.path.dirname(consolelogfile)
+        # `bb.utils.mkdirhier` has this check, but it reports failure using bb.fatal, which logs
+        # to the very logger we are trying to set up.
+        if '${' in str(consolelogdirname):
+            print(
+                "FATAL: Directory name {} contains unexpanded bitbake variable. This may cause build failures and WORKDIR pollution.".format(
+                    consolelogdirname))
+            if '${MACHINE}' in consolelogdirname:
+                print("HINT: It looks like you forgot to set MACHINE in local.conf.")
+
+        bb.utils.mkdirhier(consolelogdirname)
+        loglink = os.path.join(consolelogdirname, 'console-latest.log')
         bb.utils.remove(loglink)
         try:
            os.symlink(os.path.basename(consolelogfile), loglink)