From 4728c69d682451b1b50930ccb37daedcfd12fe83 Mon Sep 17 00:00:00 2001
From: Daniel Chaves <dchvs11@gmail.com>
Date: Wed, 1 Jul 2026 20:01:46 -0600
Subject: [PATCH] bitbake-setup: support --update-bb-conf on init and fix
site.conf for setup-dir == top-dir
Two fixes that work together to let `bitbake-setup init` preserve an
existing bitbake build configuration (local.conf, bblayers.conf):
1. Expose the existing `update_bb_conf` parameter through a new
`--update-bb-conf` CLI flag on `init`, matching the semantics of
`bitbake-setup update`. This lets downstream projects re-run init
(e.g., to refresh layers via --source-overrides) without losing
their tracked conf files. Default remains "yes" for backward
compatibility.
2. Fix the site.conf symlink target when the setup directory is the
same as the top directory. The symlink target was always computed
as `setupdir/../site.conf`, which only matches the actual site.conf
location (top_dir/site.conf) when the setup directory is exactly
one level below the top directory. When `--setup-dir-name` is given
an absolute path equal to the top directory, the symlink ends up
broken, which causes `diff -uNr` to fail with exit code 2 inside
setup_bitbake_build(). That exception is raised before the
`update_bb_conf == 'no'` branch can restore the original conf,
defeating the new flag from #1.
Together, these changes make `bitbake-setup init --update-bb-conf=no`
behave like Yocto's `oe-init-build-env`: the build environment is
preserved across re-initializations.
Signed-off-by: Daniel Chaves <dchvs11@gmail.com>
---
bin/bitbake-setup | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
@@ -371,7 +371,10 @@ def setup_bitbake_build(bitbake_config, layerdir, setupdir, thisdir, update_bb_c
_prepend_passthrough_to_init_build_env(bitbake_builddir)
siteconf_symlink = os.path.join(bitbake_confdir, "site.conf")
- siteconf = os.path.normpath(os.path.join(setupdir, '..', "site.conf"))
+ if os.path.exists(os.path.join(setupdir, "site.conf")):
+ siteconf = os.path.join(setupdir, "site.conf")
+ else:
+ siteconf = os.path.normpath(os.path.join(setupdir, '..', "site.conf"))
if os.path.lexists(siteconf_symlink):
os.remove(siteconf_symlink)
os.symlink(os.path.relpath(siteconf, bitbake_confdir), siteconf_symlink)
@@ -870,7 +873,7 @@ def init_config(top_dir, settings, args):
bb.event.register("bb.build.TaskProgress", handle_task_progress, data=d)
write_upstream_config(confdir, upstream_config)
- update_build(upstream_config, confdir, setupdir, layerdir, d, update_bb_conf="yes", init_vscode=args.init_vscode)
+ update_build(upstream_config, confdir, setupdir, layerdir, d, update_bb_conf=args.update_bb_conf, init_vscode=args.init_vscode)
bb.event.remove("bb.build.TaskProgress", None)
@@ -1268,6 +1271,8 @@ def main():
help='Symlink local source into a build, instead of getting it as prescribed by a configuration (useful for local development).')
parser_init.add_argument('--init-vscode', action=argparse.BooleanOptionalAction, default=bool(shutil.which('code')),
help='Generate VSCode workspace configuration (default: %(default)s)')
+ parser_init.add_argument('--update-bb-conf', choices=['prompt', 'yes', 'no'], default='yes',
+ help='Update bitbake configuration files (bblayers.conf, local.conf) when re-initializing an existing setup (default: %(default)s)')
parser_init.set_defaults(func=init_config)
parser_status = subparsers.add_parser('status', help='Check if the setup needs to be synchronized with configuration')