diff mbox series

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

Message ID 20251114-bitbake-setup-abort-v1-2-d2f9967df3b1@bootlin.com
State New
Headers show
Series bitbake-setup init improvements | expand

Commit Message

Antonin Godard Nov. 14, 2025, 11:07 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 | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Alexander Kanavin Nov. 14, 2025, 6:25 p.m. UTC | #1
On Fri, 14 Nov 2025 at 12:07, Antonin Godard via
lists.openembedded.org
<antonin.godard=bootlin.com@lists.openembedded.org> wrote:
>          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)))
>
> +        if args.func == init_config:
> +            init_config(top_dir, all_settings, args)
> +            return
> +
>          d = init_bb_cache(top_dir, all_settings, args)
>          args.func(top_dir, all_settings, args, d)
>          save_bb_cache()

save_bb_cache() isn't called anymore with this change, so needs to be
an if..else block rather, with save_bb_cache() coming just after?

Not sure if that function still does useful things, it's been there
since the earliest prototypes so I no longer remember what it does and
why.

Alex
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index 6410504d4f..3dc46cbbfa 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,6 +900,10 @@  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)))
 
+        if args.func == init_config:
+            init_config(top_dir, all_settings, args)
+            return
+
         d = init_bb_cache(top_dir, all_settings, args)
         args.func(top_dir, all_settings, args, d)
         save_bb_cache()