Skip to content

fix(interactive): parse case alternatives in get_kernel_info_for_branch#9798

Open
iav wants to merge 2 commits into
mainfrom
fix/interactive-kernel-desc-case-alt
Open

fix(interactive): parse case alternatives in get_kernel_info_for_branch#9798
iav wants to merge 2 commits into
mainfrom
fix/interactive-kernel-desc-case-alt

Conversation

@iav
Copy link
Copy Markdown
Contributor

@iav iav commented May 10, 2026

Summary

Fixes #8957.

The awk parser in get_kernel_info_for_branch() searched the family conf for ^[[:space:]]*<branch>\), which matches a single-pattern case label like current) but not a case label with alternation like vendor | vendor-rt). With no match, the function returned an empty description and the menu fell back to a hardcoded label ("Vendor BSP kernel" for the vendor branch), so any custom KERNEL_DESCRIPTION inside an alternation block was silently lost.

Fix: extract the label (everything before the closing paren), split on | (with optional surrounding whitespace) and check each alternative against the requested branch.

Real-world impact: families/k3.conf and families/k3-beagle.conf both use vendor | vendor-rt) to share kernel/u-boot config between the two branches. Their KERNEL_DESCRIPTION was effectively dead code before this fix.

Single-label labels (vendor-edge), current) etc.) continue to match — they are just an n=1 case of the new alternation logic.

Commits

  1. style(interactive): shfmt -w — pre-existing mixed indentation (4-space vs tabs) normalised by shfmt. Isolated as a style-only commit so the follow-up fix diff stays small.
  2. fix(interactive): parse case alternatives ... — the actual fix (13+/3-).

Test plan

Verified via standalone scaffold (.tmp/test-kernel-info-8957.sh) against real fixtures in the repo:

  • vendor in k3 family (alternation) → returns "Texas Instruments currently supported Processor SDK kernel" (was: empty → fallback "Vendor BSP kernel")
  • vendor-rt in k3 family (alternation) → returns same description (was: empty)
  • vendor in k3-beagle family (alternation) → returns "BeagleBoard.org (vendor) kernel" (was: empty)
  • vendor-rt in k3-beagle family (alternation) → returns same (was: empty)
  • vendor-edge in k3 family (single label, regression check) → returns "Texas Instruments latest pre-released Processor SDK kernel" (unchanged)
  • Unknown branch → returns empty (caller's fallback path handles)

Notes

  • Userpatches/board-conf overrides of KERNEL_DESCRIPTION are not addressed here — that's a separate architectural problem (text awk on a single file vs runtime evaluation of the full config flow). This PR fixes only the pat | pat) parser shortfall.

Summary by CodeRabbit

  • Bug Fixes
    • Improved kernel information parsing to correctly identify and process kernel branch labels, including single and multi-alternative formats, ensuring accurate kernel version and description retrieval across all supported board configurations.

Review Change Stack

iav added 2 commits May 10, 2026 21:36
Pre-existing mixed indentation (4-space vs tabs) normalised by shfmt.
No functional changes; isolated as a style-only commit so the
follow-up fix diff stays small and reviewable.

Assisted-by: Claude:claude-opus-4.7
…ch (#8957)

Fixes #8957.

The awk parser in get_kernel_info_for_branch() searched the family
conf for `^[[:space:]]*<branch>\)`, which matches a single-pattern
case label like `current)` but NOT a case label with alternation
like `vendor | vendor-rt)`. With no match, the function returned
an empty description and the menu fell back to a hardcoded label
("Vendor BSP kernel" for the vendor branch), so any custom
KERNEL_DESCRIPTION inside an alternation block was silently lost.

Fix: extract the label (everything before the closing paren),
split on `|` (with optional surrounding whitespace) and check each
alternative against the requested branch.

Real-world impact: families/k3.conf and families/k3-beagle.conf
both use `vendor | vendor-rt)` to share kernel/u-boot config
between the two branches. Their `KERNEL_DESCRIPTION` was effectively
dead code before this fix.

Single-label labels (`vendor-edge)`, `current)` etc.) continue to
match — they are just an n=1 case of the new alternation logic.

Assisted-by: Claude:claude-opus-4.7
@iav iav requested a review from a team as a code owner May 10, 2026 18:38
@iav iav requested review from catalinii and martinayotte and removed request for a team May 10, 2026 18:38
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 76418131-2a99-4c09-9095-33a908b762ac

📥 Commits

Reviewing files that changed from the base of the PR and between 38c583f and b0fd31e.

📒 Files selected for processing (1)
  • lib/functions/configuration/interactive.sh

📝 Walkthrough

Walkthrough

This PR improves kernel information extraction from board configuration files by rewriting the pattern-matching logic in get_kernel_info_for_branch to recognize both single case labels (branch)) and compound labels with pipe-separated alternatives (pat1 | pat2 | ...)). The calling function interactive_config_ask_branch is reformatted with no semantic changes.

Changes

Kernel Configuration Parser

Layer / File(s) Summary
Kernel Info Parser Logic
lib/functions/configuration/interactive.sh (lines 183–200)
The awk matcher is rewritten to expand the case-label regex and split pipe-separated alternatives on |, then compare each alternative against the requested branch to extract KERNEL_MAJOR_MINOR and KERNEL_DESCRIPTION.
Interactive Config Function
lib/functions/configuration/interactive.sh (lines 223–280)
Whitespace and indentation adjustments throughout interactive_config_ask_branch while preserving the control flow: early return when BRANCH is set, kernel option list building via the improved parser, fallback descriptions, version appending, dialog presentation, and error handling on empty selection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through config lines with care,
Where case labels hide in formatted pairs—
Now single and compound both shine so bright,
The kernel descriptions will show just right! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(interactive): parse case alternatives in get_kernel_info_for_branch' directly describes the main functional change: improving case-label parsing in the get_kernel_info_for_branch function to handle alternation patterns.
Linked Issues check ✅ Passed The PR directly addresses issue #8957 by fixing the root cause: the awk parser now correctly handles case-label alternations (e.g., 'vendor | vendor-rt)'), allowing KERNEL_DESCRIPTION blocks to be matched and used instead of falling back to defaults.
Out of Scope Changes check ✅ Passed All changes are focused on fixing the case-label parsing logic in get_kernel_info_for_branch and formatting in interactive_config_ask_branch, directly addressing the linked issue without introducing unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/interactive-kernel-desc-case-alt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added 05 Milestone: Second quarter release Needs review Seeking for review Framework Framework components size/medium PR with more then 50 and less then 250 lines labels May 10, 2026
@igorpecovnik
Copy link
Copy Markdown
Member

I guess its correct now:
image

@Grippy98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release Framework Framework components Needs review Seeking for review size/medium PR with more then 50 and less then 250 lines

Development

Successfully merging this pull request may close these issues.

[Bug]: Kernel Description and Version revert to defaults even if set as part of Board Config.

2 participants