Skip to contentSkip to conversation

bitbake-setup: Prompt setup directory name

PATCH Superseded Joshua Watt 2 participants 4 messages Nov 11, 2025 – Nov 12, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake-setup: Prompt setup directory name

If the setup directory is not specified on the command line, prompt the user if they would like to change it. This allows the user to use an alternative name (e.g. a terser one) at setup time.

---
 bin/bitbake-setup | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
bin/bitbake-setup +12 -1
index c32381e50..86c556944 100755
@@ -466,7 +466,18 @@ def init_config(top_dir, settings, args, d):
     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'])))
 
-    setupdir = os.path.join(os.path.abspath(top_dir), args.setup_dir_name or "{}-{}".format(upstream_config['name']," ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_")))
+    if args.setup_dir_name:
+        setup_dir_name = args.setup_dir_name
+    else:
+        setup_dir_name = "{}-{}".format(upstream_config['name']," ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_"))
+        if not args.non_interactive:
+            n = input(f"Enter setup directory name, or 'N' to quit ({setup_dir_name}): ")
+            if n == 'N':
+                exit()
+            elif n:
+                setup_dir_name = n
+
+    setupdir = os.path.join(os.path.abspath(top_dir), setup_dir_name)
     if os.path.exists(os.path.join(setupdir, "layers")):
         print(f"Setup already initialized in:\n    {setupdir}\nUse 'bitbake-setup status' to check if it needs to be updated, or 'bitbake-setup update' to perform the update.\nIf you would like to start over and re-initialize in this directory, remove it, and run 'bitbake-setup init' again.")
         return
Signature · 1 line
2.51.1
#1 lore raw
Quoted 1 line · Joshua Watt via lists.openembedded.org

+ n = input(f"Enter setup directory name, or 'N' to quit ({setup_dir_name}): ")

Isn't the convention to put the default in [ ] in such interactive prompts? Otherwise it is not clear that hitting enter will proceed with the default.

I'd also not special-case N, one can hit ctrl-c to stop rather (and that could be hinted).

Alex

#2 lore raw
Quoted 8 lines · Alexander Kanavin
Quoted 1 line · Joshua Watt via lists.openembedded.org

+ n = input(f"Enter setup directory name, or 'N' to quit ({setup_dir_name}): ")

Isn't the convention to put the default in [ ] in such interactive prompts? Otherwise it is not clear that hitting enter will proceed with the default.

You are correct, I thought is was ( ) for some reason. I'll send a V2

Quoted 5 lines

I'd also not special-case N, one can hit ctrl-c to stop rather (and that could be hinted).

Alex

#3 lore raw

PATCH v2 1/1 bitbake-setup: Prompt setup directory name

In reply to Joshua Watt

If the setup directory is not specified on the command line, prompt the user if they would like to change it. This allows the user to use an alternative name (e.g. a terser one) at setup time.

---
 bin/bitbake-setup | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
bin/bitbake-setup +10 -1
index c32381e50..3df8f120b 100755
@@ -466,7 +466,16 @@ def init_config(top_dir, settings, args, d):
     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'])))
 
-    setupdir = os.path.join(os.path.abspath(top_dir), args.setup_dir_name or "{}-{}".format(upstream_config['name']," ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_")))
+    if args.setup_dir_name:
+        setup_dir_name = args.setup_dir_name
+    else:
+        setup_dir_name = "{}-{}".format(upstream_config['name']," ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_"))
+        if not args.non_interactive:
+            n = input(f"Enter setup directory name: [{setup_dir_name}] ")
+            if n:
+                setup_dir_name = n
+
+    setupdir = os.path.join(os.path.abspath(top_dir), setup_dir_name)
     if os.path.exists(os.path.join(setupdir, "layers")):
         print(f"Setup already initialized in:\n    {setupdir}\nUse 'bitbake-setup status' to check if it needs to be updated, or 'bitbake-setup update' to perform the update.\nIf you would like to start over and re-initialize in this directory, remove it, and run 'bitbake-setup init' again.")
         return
Signature · 1 line
2.51.1