From 119c592530e82ab2a9bdddb532640c345b58cf8b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 13 Nov 2021 16:17:21 +0000 Subject: bitbake: cookerdata: Set TOPDIR explicitly and fix broken findTopdir() TOPDIR is set internally deep within the parser to os.getcwd(). Rather than do that, set it explicitly if not set. Note that modern code will almost always have a bblayers.conf file which would have already set TOPDIR before this new code. Also fix findTopdir since the conf/bitbake.conf codepath is just plain incorrect, it would find build metadata, not the current build directory that bitbake would use. Again, the use of bblayers.conf means hitting the fallback code was unlikely. This change makes everything clear and explicit. (Bitbake rev: c03df5283408dfd089b6317677d2b7af6fa73936) Signed-off-by: Richard Purdie --- bitbake/lib/bb/cookerdata.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'bitbake/lib') diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py index 592bc2968e..397b43dfa7 100644 --- a/bitbake/lib/bb/cookerdata.py +++ b/bitbake/lib/bb/cookerdata.py @@ -210,7 +210,7 @@ def findConfigFile(configfile, data): # # We search for a conf/bblayers.conf under an entry in BBPATH or in cwd working -# up to /. If that fails, we search for a conf/bitbake.conf in BBPATH. +# up to /. If that fails, bitbake would fall back to cwd. # def findTopdir(): @@ -223,11 +223,8 @@ def findTopdir(): layerconf = findConfigFile("bblayers.conf", d) if layerconf: return os.path.dirname(os.path.dirname(layerconf)) - if bbpath: - bitbakeconf = bb.utils.which(bbpath, "conf/bitbake.conf") - if bitbakeconf: - return os.path.dirname(os.path.dirname(bitbakeconf)) - return None + + return os.path.abspath(os.getcwd()) class CookerDataBuilder(object): @@ -417,6 +414,9 @@ class CookerDataBuilder(object): " invoked bitbake from the wrong directory?") raise SystemExit(msg) + if not data.getVar("TOPDIR"): + data.setVar("TOPDIR", os.path.abspath(os.getcwd())) + data = parse_config_file(os.path.join("conf", "bitbake.conf"), data) # Parse files for loading *after* bitbake.conf and any includes -- cgit v1.2.3-54-g00ecf