diff mbox series

[v2,2/3] bitbake-setup: create top-dir later in init

Message ID 20251117-bitbake-setup-abort-v2-2-a73f44e83bc0@bootlin.com
State Accepted, archived
Commit 0ae46d39c505643f46541b9205e4146a5529a8bf
Headers show
Series bitbake-setup init improvements | expand

Commit Message

Antonin Godard Nov. 17, 2025, 8:15 a.m. UTC
Calling init_bb_cache() before init_config() creates the top-directory
already, before the user has accepted to proceed after the first few
messages:

  Bitbake-setup is using <topdir> as top directory ("bitbake-setup settings --help" shows how to change it).

  A common site.conf file will be created, please edit or replace before running builds
      <topdir>/site.conf

  Proceed? (y/N):

Saying N here would leave an empty top directory which is unexpected.

Move the init_bb_cache() call later in init_config().

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 bin/bitbake-setup | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index adf19ab09f..db6428f8d2 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -452,14 +452,16 @@  def obtain_config(top_dir, settings, args, source_overrides, d):
     upstream_config['skip-selection'] = args.skip_selection
     return upstream_config
 
-def init_config(top_dir, settings, args, d):
+def init_config(top_dir, settings, args):
+    create_siteconf(top_dir, args.non_interactive, settings)
+
+    d = init_bb_cache(top_dir, settings, args)
     stdout = sys.stdout
     def handle_task_progress(event, d):
         rate = event.rate if event.rate else ''
         progress = event.progress if event.progress > 0 else 0
         print("{}% {}                ".format(progress, rate), file=stdout, end='\r')
 
-    create_siteconf(top_dir, args.non_interactive, settings)
     source_overrides = json.load(open(args.source_overrides)) if args.source_overrides else {'sources':{}}
     upstream_config = obtain_config(top_dir, settings, args, source_overrides, d)
     print("\nRun 'bitbake-setup init --non-interactive {}' to select this configuration non-interactively.\n".format(" ".join(upstream_config['non-interactive-cmdline-options'])))
@@ -898,8 +900,12 @@  def main():
 
         print('Bitbake-setup is using {} as top directory ("bitbake-setup settings --help" shows how to change it).\n'.format(top_dir, global_settings_path(args)))
 
-        d = init_bb_cache(top_dir, all_settings, args)
-        args.func(top_dir, all_settings, args, d)
+        if args.func == init_config:
+            init_config(top_dir, all_settings, args)
+        else:
+            d = init_bb_cache(top_dir, all_settings, args)
+            args.func(top_dir, all_settings, args, d)
+
         save_bb_cache()
     else:
         from argparse import Namespace