| Message ID | 20251117194840.2322115-1-JPEWhacker@gmail.com |
|---|---|
| State | New |
| Headers | show |
| Series | [bitbake-devel,1/2] bitbake-setup: Allow setup-dir-name to be specified in JSON | expand |
On Mon, 17 Nov 2025 at 20:48, Joshua Watt via lists.openembedded.org <JPEWhacker=gmail.com@lists.openembedded.org> wrote: > - setup_dir_name = "{}-{}".format(upstream_config['name']," ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_")) > + if 'setup-dir-name' in upstream_config['bitbake-config']: > + mapping = { > + k: v.replace(" ", "-").replace("/", "_") > + for k, v in upstream_config['bitbake-config']['oe-fragment-choices'].items() > + } > + setup_dir_name = string.Template(upstream_config['bitbake-config']['setup-dir-name']).substitute(mapping) > + else: > + setup_dir_name = "{}-{}".format(upstream_config['name']," ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_")) This (and the actual json tweaks) greatly increases the chances of directory names clashing, so there should be a check for existence, and a logic to deal with it (probably just fall back to the full style)? Alex
On Mon, 17 Nov 2025 at 20:53, Alexander Kanavin via lists.openembedded.org <alex.kanavin=gmail.com@lists.openembedded.org> wrote: > This (and the actual json tweaks) greatly increases the chances of > directory names clashing, so there should be a check for existence, > and a logic to deal with it (probably just fall back to the full > style)? Also see my proposal for a setting. There are pros and cons for either approach, I just would like you to read and consider it. Alex
On Mon, Nov 17, 2025, 12:55 PM Alexander Kanavin <alex.kanavin@gmail.com> wrote: > On Mon, 17 Nov 2025 at 20:53, Alexander Kanavin via > lists.openembedded.org <alex.kanavin=gmail.com@lists.openembedded.org> > wrote: > > This (and the actual json tweaks) greatly increases the chances of > > directory names clashing, so there should be a check for existence, > > and a logic to deal with it (probably just fall back to the full > > style)? > > Also see my proposal for a setting. There are pros and cons for either > approach, I just would like you to read and consider it. > Ya this was more just to show how to do the template string per request, not necessarily the complete solution. I probably should have sent it as an RFC. > Alex >
On Mon, 17 Nov 2025 at 20:58, Joshua Watt <jpewhacker@gmail.com> wrote: >> > This (and the actual json tweaks) greatly increases the chances of >> > directory names clashing, so there should be a check for existence, >> > and a logic to deal with it (probably just fall back to the full >> > style)? >> >> Also see my proposal for a setting. There are pros and cons for either >> approach, I just would like you to read and consider it. > > > Ya this was more just to show how to do the template string per request, not necessarily the complete solution. I probably should have sent it as an RFC. My C is that I'm okay with this, if it also comes with a 'force-full-setup-dir-name' setting :) Alex
diff --git a/bin/bitbake-setup b/bin/bitbake-setup index 7e9491fac..7ee182bf3 100755 --- a/bin/bitbake-setup +++ b/bin/bitbake-setup @@ -17,6 +17,7 @@ import glob import subprocess import copy import textwrap +import string default_registry = os.path.normpath(os.path.dirname(__file__) + "/../default-registry") @@ -467,7 +468,15 @@ def init_config(top_dir, settings, args, d): 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 'setup-dir-name' in upstream_config['bitbake-config']: + mapping = { + k: v.replace(" ", "-").replace("/", "_") + for k, v in upstream_config['bitbake-config']['oe-fragment-choices'].items() + } + setup_dir_name = string.Template(upstream_config['bitbake-config']['setup-dir-name']).substitute(mapping) + 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:
Enables the JSON file to specify the preferred name of the setup directory with a 'setup-dir-name' key. This key can have variable expansions in the same format as python string.Template strings (which matches the shell variable expansion rules). Variables that can be expanded are any fragment configuration prompted by the user (e.g. the keys in "oe-fragments-one-of"), or "$name" to use the name of the configuration (e.g. the .conf.json file). Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> --- bin/bitbake-setup | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)