* [PATCH v2 0/3] bitbake-setup init improvements
@ 2025-11-17 8:15 Antonin Godard
2025-11-17 8:15 ` [PATCH v2 1/3] bitbake-setup: fix top_dir creation in create_siteconf Antonin Godard
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Antonin Godard @ 2025-11-17 8:15 UTC (permalink / raw)
To: bitbake-devel; +Cc: Thomas Petazzoni, Antonin Godard
Improve the init user experience by:
- Creating the top directory only when we need it (and avoid leaving
empty directories behind)
- Print a message when a user sends Ctrl+C
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
Changes in v2:
- In the first patch mention that the top dir was created by chance.
- Add if..else so save_bb_cache() is still called after init.
- Make the sigint handler global, print message based on called
function.
- Link to v1: https://lore.kernel.org/r/20251114-bitbake-setup-abort-v1-0-d2f9967df3b1@bootlin.com
---
Antonin Godard (3):
bitbake-setup: fix top_dir creation in create_siteconf
bitbake-setup: create top-dir later in init
bitbake-setup: handle ctrl+c
bin/bitbake-setup | 33 ++++++++++++++++++++++++++++-----
1 file changed, 28 insertions(+), 5 deletions(-)
---
base-commit: fff23f8ce8f60aba6b89512a734623067661816e
change-id: 20251114-bitbake-setup-abort-8a5333c049ea
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/3] bitbake-setup: fix top_dir creation in create_siteconf
2025-11-17 8:15 [PATCH v2 0/3] bitbake-setup init improvements Antonin Godard
@ 2025-11-17 8:15 ` Antonin Godard
2025-11-17 8:15 ` [PATCH v2 2/3] bitbake-setup: create top-dir later in init Antonin Godard
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Antonin Godard @ 2025-11-17 8:15 UTC (permalink / raw)
To: bitbake-devel; +Cc: Thomas Petazzoni, Antonin Godard
The intent of the create_siteconf() is to create the site.conf file
common to all setups. For this it needs the top directory to be created.
Create the top directory instead of its parent.
Previously, this directory was created by chance by init_bb_cache().
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
bin/bitbake-setup | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index 3a281defac..adf19ab09f 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -677,7 +677,7 @@ def create_siteconf(top_dir, non_interactive, settings):
if y_or_n != 'y':
exit()
- os.makedirs(os.path.dirname(top_dir), exist_ok=True)
+ os.makedirs(top_dir, exist_ok=True)
with open(siteconfpath, 'w') as siteconffile:
siteconffile.write(
textwrap.dedent(
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] bitbake-setup: create top-dir later in init
2025-11-17 8:15 [PATCH v2 0/3] bitbake-setup init improvements Antonin Godard
2025-11-17 8:15 ` [PATCH v2 1/3] bitbake-setup: fix top_dir creation in create_siteconf Antonin Godard
@ 2025-11-17 8:15 ` Antonin Godard
2025-11-17 8:15 ` [PATCH v2 3/3] bitbake-setup: handle ctrl+c Antonin Godard
2025-11-17 10:38 ` [bitbake-devel] [PATCH v2 0/3] bitbake-setup init improvements Alexander Kanavin
3 siblings, 0 replies; 5+ messages in thread
From: Antonin Godard @ 2025-11-17 8:15 UTC (permalink / raw)
To: bitbake-devel; +Cc: Thomas Petazzoni, Antonin Godard
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 --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
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] bitbake-setup: handle ctrl+c
2025-11-17 8:15 [PATCH v2 0/3] bitbake-setup init improvements Antonin Godard
2025-11-17 8:15 ` [PATCH v2 1/3] bitbake-setup: fix top_dir creation in create_siteconf Antonin Godard
2025-11-17 8:15 ` [PATCH v2 2/3] bitbake-setup: create top-dir later in init Antonin Godard
@ 2025-11-17 8:15 ` Antonin Godard
2025-11-17 10:38 ` [bitbake-devel] [PATCH v2 0/3] bitbake-setup init improvements Alexander Kanavin
3 siblings, 0 replies; 5+ messages in thread
From: Antonin Godard @ 2025-11-17 8:15 UTC (permalink / raw)
To: bitbake-devel; +Cc: Thomas Petazzoni, Antonin Godard
Instead of printing the stack trace, print "Shutting down..." when the
user presses Ctrl+C during command executions. Mention that the
top-directory's setups might be incomplete if the topdir was already
created at this point.
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
bin/bitbake-setup | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index db6428f8d2..d0a932a6b2 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -17,6 +17,8 @@ import glob
import subprocess
import copy
import textwrap
+import signal
+import functools
default_registry = os.path.normpath(os.path.dirname(__file__) + "/../default-registry")
@@ -783,6 +785,15 @@ def merge_settings(builtin_settings, global_settings, topdir_settings, cmdline_s
return all_settings
+def sigint_handler(sig, frame, func, top_dir):
+ print(f'\nShutting down...')
+ if isinstance(top_dir, str) and os.path.exists(top_dir):
+ if func in [init_config, build_update]:
+ print(f'{top_dir} may contain an incomplete setup!')
+ elif func == install_buildtools:
+ print(f'{top_dir} may contain an incomplete buildtools installation!')
+ exit()
+
def main():
def add_setup_dir_arg(parser):
setup_dir = get_setup_dir_via_bbpath()
@@ -888,6 +899,12 @@ def main():
global_settings = load_settings(global_settings_path(args))
top_dir = get_top_dir(args, merge_settings(builtin_settings, global_settings, {}, args.cmdline_settings))
+ # register handler now to pass top_dir
+ _handler = functools.partial(sigint_handler,
+ func=args.func,
+ top_dir=os.path.abspath(top_dir))
+ signal.signal(signal.SIGINT, _handler)
+
# This cannot be set with the rest of the builtin settings as top_dir needs to be determined first
builtin_settings['default']['dl-dir'] = os.path.join(top_dir, '.bitbake-setup-downloads')
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [bitbake-devel] [PATCH v2 0/3] bitbake-setup init improvements
2025-11-17 8:15 [PATCH v2 0/3] bitbake-setup init improvements Antonin Godard
` (2 preceding siblings ...)
2025-11-17 8:15 ` [PATCH v2 3/3] bitbake-setup: handle ctrl+c Antonin Godard
@ 2025-11-17 10:38 ` Alexander Kanavin
3 siblings, 0 replies; 5+ messages in thread
From: Alexander Kanavin @ 2025-11-17 10:38 UTC (permalink / raw)
To: antonin.godard; +Cc: bitbake-devel, Thomas Petazzoni
Thanks, v2 lgtm.
Alex
On Mon, 17 Nov 2025 at 09:16, Antonin Godard via
lists.openembedded.org
<antonin.godard=bootlin.com@lists.openembedded.org> wrote:
>
> Improve the init user experience by:
>
> - Creating the top directory only when we need it (and avoid leaving
> empty directories behind)
> - Print a message when a user sends Ctrl+C
>
> Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
> ---
> Changes in v2:
> - In the first patch mention that the top dir was created by chance.
> - Add if..else so save_bb_cache() is still called after init.
> - Make the sigint handler global, print message based on called
> function.
> - Link to v1: https://lore.kernel.org/r/20251114-bitbake-setup-abort-v1-0-d2f9967df3b1@bootlin.com
>
> ---
> Antonin Godard (3):
> bitbake-setup: fix top_dir creation in create_siteconf
> bitbake-setup: create top-dir later in init
> bitbake-setup: handle ctrl+c
>
> bin/bitbake-setup | 33 ++++++++++++++++++++++++++++-----
> 1 file changed, 28 insertions(+), 5 deletions(-)
> ---
> base-commit: fff23f8ce8f60aba6b89512a734623067661816e
> change-id: 20251114-bitbake-setup-abort-8a5333c049ea
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#18415): https://lists.openembedded.org/g/bitbake-devel/message/18415
> Mute This Topic: https://lists.openembedded.org/mt/116334413/1686489
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-17 10:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-17 8:15 [PATCH v2 0/3] bitbake-setup init improvements Antonin Godard
2025-11-17 8:15 ` [PATCH v2 1/3] bitbake-setup: fix top_dir creation in create_siteconf Antonin Godard
2025-11-17 8:15 ` [PATCH v2 2/3] bitbake-setup: create top-dir later in init Antonin Godard
2025-11-17 8:15 ` [PATCH v2 3/3] bitbake-setup: handle ctrl+c Antonin Godard
2025-11-17 10:38 ` [bitbake-devel] [PATCH v2 0/3] bitbake-setup init improvements Alexander Kanavin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.