diff mbox series

bitbake-setup: correctly deduce top directory from BBPATH environment variable

Message ID 20260112130358.3165670-1-alex.kanavin@gmail.com
State New
Headers show
Series bitbake-setup: correctly deduce top directory from BBPATH environment variable | expand

Commit Message

Alexander Kanavin Jan. 12, 2026, 1:03 p.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

This fixes running 'bitbake-setup init' in an active bitbake session when
a top dir settings file is absent. In this case, bitbake-setup was trying to make
a whole new top directory under the current directory. It will will now use
the existing top directory, deducing it from BBPATH (similar to status and
update operations), which was always the intent.

The code was relying on an existence of a top directory settings file, which was
always present in earlier prototypes, but is currently created
only when a setting is explicitly written into it. This logic is changed
to use the bitbake-setup's cache directory, which is also explicitly created.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 bin/bitbake-setup | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index abe7614c8..7f6ea550c 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -43,6 +43,7 @@  def cache_dir(top_dir):
 def init_bb_cache(top_dir, settings, args):
     dldir = settings["default"]["dl-dir"]
     bb_cachedir = os.path.join(cache_dir(top_dir), 'bitbake-cache')
+    os.makedirs(bb_cachedir, exist_ok=True)
 
     d = bb.data.init()
     d.setVar("DL_DIR", dldir)
@@ -920,7 +921,7 @@  def get_top_dir(args, settings):
     setup_dir_via_bbpath = get_setup_dir_via_bbpath()
     if setup_dir_via_bbpath:
         top_dir = os.path.dirname(setup_dir_via_bbpath)
-        if os.path.exists(topdir_settings_path(top_dir)):
+        if os.path.exists(cache_dir(top_dir)):
             return top_dir
 
     if hasattr(args, 'setup_dir'):