diff mbox series

bitbake-setup: use a transient temporary top_dir to list available configs

Message ID 20251119162408.3793924-1-alex.kanavin@gmail.com
State New
Headers show
Series bitbake-setup: use a transient temporary top_dir to list available configs | expand

Commit Message

Alexander Kanavin Nov. 19, 2025, 4:24 p.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

As pointed out here:
https://lists.openembedded.org/g/bitbake-devel/topic/116374639

reusing the standard top_dir is prone to issues: the user, if they're just starting,
may not want anything to be left over after issuing 'list' or even want to decide where
the top_dir should be, they just want a list of configs.

Also if the top_dir is set to . (which is the default) and the user is in
a directory that cannot be written into, there'll be a baffling traceback.

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

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index a8da10e4f..792f5579f 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -681,10 +681,15 @@  def list_registry(registry_path, with_expired):
                     json_data[config_name] = {"description": config_desc}
     return json_data
 
-def list_configs(top_dir, settings, args, d):
+def list_configs(settings, args):
+    import tempfile
+    top_dir = tempfile.mkdtemp(prefix="bitbake-setup-list-")
+    d = init_bb_cache(top_dir, settings, args)
     registry_path = update_registry(settings["default"]["registry"], cache_dir(top_dir), d)
     json_data = list_registry(registry_path, args.with_expired)
-    print("\nAvailable configurations:")
+    shutil.rmtree(top_dir)
+
+    print("Available configurations:")
     for config_name, config_data in json_data.items():
         expiry_date = config_data.get("expires", None)
         config_desc = config_data["description"]
@@ -983,6 +988,9 @@  def main():
         if args.func == settings_func:
             settings_func(top_dir, all_settings, args)
             return
+        if args.func == list_configs:
+            list_configs(all_settings, args)
+            return
 
         print('Bitbake-setup is using {} as top directory.\n'.format(top_dir, global_settings_path(args)))