mbox series

[v3,00/14] bitbake-setup: improvements, VSCode workspace generation

Message ID 20260329183332.1996183-1-adrian.freihofer@siemens.com
Headers show
Series bitbake-setup: improvements, VSCode workspace generation | expand

Message

Freihofer, Adrian March 29, 2026, 6:32 p.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

Changes from v2 to v3:
- Rebased on master-next from 29.3.2026:
- New commit:
  bitbake-setup: Fix type annotation for descriptions parameter in print_configs
  might be squashed into commit on master-next
- New exception: bb.fetch2.RebaseError
  - Adapted tests accordingly
  - Simplified code in bitbake-setup accordingly
- New commit:
  bitbake-setup: catch unexpected exceptions and show a clean error message
- Documentation
  - git fetcher unpack_update
  - bitbake-setup non destructive update mode

Adds:

- fetch2: new LocalModificationsError and RebaseError exception subclasses of
  UnpackError, raised by unpack_update() to give callers a precise handle on
  the two blocking update conditions (uncommitted working-tree changes vs.
  local commits that conflict with upstream). Both carry a user-facing message
  with the affected path and, for RebaseError, the git rebase output and a
  hint about the 'dldir' remote.

- Tests for bitbake fetcher unpack_update: add GitUnpackUpdateTest covering
  the full unpack_update workflow — fast-forward rebase with local commits,
  dldir remote setup, conflict detection, staged/modified file blocking,
  shallow clone rejection, and stale dldir remote.

- bitbake-setup bug fixes: always restore sys.stdout after fetch log
  redirection (try/finally); fix dead guards in check_setupdir_files that
  used stale key names; clean up imports in tests/setup; fix the type
  annotation for the 'descriptions' parameter of print_configs (list[str] |
  None instead of list[str]).

- bitbake-setup: catch unexpected exceptions and show a clean error message:
  a top-level try/except in main() converts any unhandled exception into a
  single ERROR log line and non-zero exit. Full traceback is still shown with
  --debug; SystemExit and KeyboardInterrupt are re-raised normally.

- VSCode workspace generation (--init-vscode / --no-init-vscode):
  bitbake-setup init generates a bitbake.code-workspace file that configures
  the Yocto BitBake VS Code extension (pathToBuildFolder, pathToEnvScript,
  disableConfigModification), Python analysis extra paths, file associations
  for *.conf and *.inc, and a top-level folder for each layer git repository
  and for build/conf. User-added folders and settings are preserved on update;
  a corrupt workspace file is detected and left unchanged. The flag defaults
  to True when the 'code' binary is found on PATH.

- bitbake-setup --rebase-conflicts-strategy (abort|backup):
  When unpack_update() raises LocalModificationsError or RebaseError, the
  'abort' strategy (default) stops with a structured error that names the
  affected source and hints at --rebase-conflicts-strategy=backup. The
  'backup' strategy renames the affected layer directory to a timestamped
  backup and re-clones from upstream, preserving local work while delivering
  a clean tree. Strategy is threaded from CLI through build_status() and
  update_build() to checkout_layers().

- Documentation: new "Non-Destructive Update (unpack_update)" section in the
  fetching chapter describing the three-step internal process (dldir remote,
  fetch, rebase), the two error conditions, and the shallow/stale-dldir
  limitation. Updated bitbake-setup chapter documents --init-vscode,
  --rebase-conflicts-strategy, the in-place update behaviour, and four update
  scenario examples with real output.

Adrian Freihofer (14):
  bitbake-setup: Fix type annotation for descriptions parameter in
    print_configs
  fetch2: add LocalModificationsError and RebaseError exceptions
  bitbake-selftest: add GitUnpackUpdateTest
  tests/fetch: remove unused import, fix trailing whitespace
  doc: document the unpack_update() non-destructive git update method
  bitbake-setup: always restore sys.stdout
  tests/setup: cleanup imports
  tests/setup: fix dead check_setupdir_files guards
  bitbake-setup: generate config files for VSCode
  tests/setup: add test_vscode for VSCode workspace generation
  bitbake-setup: add --rebase-conflicts-strategy to the update command
  tests/setup: add test_update_rebase_conflicts_strategy
  bitbake-setup: catch unexpected exceptions and show a clean error
    message
  doc: document new bitbake-setup init and update features

 bin/bitbake-setup                             | 235 +++++++-
 .../bitbake-user-manual-environment-setup.rst | 205 +++++++
 .../bitbake-user-manual-fetching.rst          |  45 ++
 lib/bb/fetch2/__init__.py                     |  17 +
 lib/bb/fetch2/git.py                          |   7 +-
 lib/bb/tests/fetch.py                         | 566 +++++++++++++++++-
 lib/bb/tests/setup.py                         | 202 ++++++-
 7 files changed, 1243 insertions(+), 34 deletions(-)

Comments

Richard Purdie March 30, 2026, 7:09 a.m. UTC | #1
On Sun, 2026-03-29 at 20:32 +0200, Adrian Freihofer via lists.openembedded.org wrote:
> From: Adrian Freihofer <adrian.freihofer@siemens.com>
> 
> Changes from v2 to v3:
> - Rebased on master-next from 29.3.2026:
> - New commit:
>   bitbake-setup: Fix type annotation for descriptions parameter in print_configs
>   might be squashed into commit on master-next
> - New exception: bb.fetch2.RebaseError
>   - Adapted tests accordingly
>   - Simplified code in bitbake-setup accordingly
> - New commit:
>   bitbake-setup: catch unexpected exceptions and show a clean error message
> - Documentation
>   - git fetcher unpack_update
>   - bitbake-setup non destructive update mode

Sorry Adrian, this caused an issue on the autobuilder:

https://autobuilder.yoctoproject.org/valkyrie/#/builders/5/builds/3443
https://autobuilder.yoctoproject.org/valkyrie/#/builders/92/builds/3471
(and probably a few more)

Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/qemuarm64-
tc/build/repos/bitbake/bin/bitbake-setup", line 49, in <module>
    def print_configs(prompt: str, choices: list[str], descriptions:
list[str] | None = None):
TypeError: unsupported operand type(s) for |: 'types.GenericAlias' and 'NoneType'

python version specific?

Cheers,

Richard
Freihofer, Adrian March 30, 2026, 9:01 a.m. UTC | #2
On Mon, 2026-03-30 at 08:09 +0100, Richard Purdie wrote:
> On Sun, 2026-03-29 at 20:32 +0200, Adrian Freihofer via
> lists.openembedded.org wrote:
> > From: Adrian Freihofer <adrian.freihofer@siemens.com>
> >
> > Changes from v2 to v3:
> > - Rebased on master-next from 29.3.2026:
> > - New commit:
> >   bitbake-setup: Fix type annotation for descriptions parameter in
> > print_configs
> >   might be squashed into commit on master-next
> > - New exception: bb.fetch2.RebaseError
> >   - Adapted tests accordingly
> >   - Simplified code in bitbake-setup accordingly
> > - New commit:
> >   bitbake-setup: catch unexpected exceptions and show a clean error
> > message
> > - Documentation
> >   - git fetcher unpack_update
> >   - bitbake-setup non destructive update mode
>
> Sorry Adrian, this caused an issue on the autobuilder:
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/5/builds/3443
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/92/builds/3471
> (and probably a few more)
>
> Traceback (most recent call last):
>   File "/srv/pokybuild/yocto-worker/qemuarm64-
> tc/build/repos/bitbake/bin/bitbake-setup", line 49, in <module>
>     def print_configs(prompt: str, choices: list[str], descriptions:
> list[str] | None = None):
> TypeError: unsupported operand type(s) for |: 'types.GenericAlias'
> and 'NoneType'
>
> python version specific?

It's the first patch which adds only this little (as I just learned
problematic) detail. It requires Python 3.10+.
Would you like to try this series without patch

[PATCH v3 01/14] bitbake-setup: Fix type annotation for descriptions
parameter in print_configs

Thank you
Adrian


>
> Cheers,
>
> Richard