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 <chris.laplante@agilent.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Chris Laplante
2024-12-06 11:24:40 -05:00
committed by Richard Purdie
parent 1859213e67
commit c7b362f5ec

View File

@@ -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)