bitbake-setup: use a transient temporary top_dir to list available configs
PATCH 1/1 bitbake-setup: use a transient temporary top_dir to list available configs
From: Alexander Kanavin <[email protected]>
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 <[email protected]>
--- bin/bitbake-setup | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
bin/bitbake-setup +10 -2
@@ -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)))
Signature · 1 line
2.39.5