From c7b362f5ec380bea7dcce9790f739d3b507b4341 Mon Sep 17 00:00:00 2001 From: Chris Laplante Date: Fri, 6 Dec 2024 11:24:40 -0500 Subject: [PATCH] bitbake: knotty: print an error if MACHINE is not set 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. (Bitbake rev: 7d3f3655b2f610f76898c84b8b97ef2e26529c41) Signed-off-by: Chris Laplante Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/knotty.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py index 3784c93ad8..881df9e5fb 100644 --- a/bitbake/lib/bb/ui/knotty.py +++ b/bitbake/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)