Skip to content

Conversation

@The-going
Copy link
Contributor

@The-going The-going commented Jun 1, 2025

Description

  • Fix errors in detecting and printing the overlay names to the configuration file.
  • This refactoring changes behavior from showing all overlays to only showing prefix-matching overlays

Issue reference: #592

Testing Procedure

Check the fixes on the working board.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 1, 2025

"""

Walkthrough

The device tree overlay management script was updated to set the Raspberry Pi overlay configuration file path to /boot/firmware/config.txt earlier in the function. A detection mechanism was added to parse /boot/boot.scr and determine one of four overlay loading scenarios based on prefix usage. This scenario controls how overlays are listed, replacing previous ls and sed commands with find and awk pipelines for prefix stripping and sorting. The dialog checklist now displays the current overlay prefix, and the overlay iteration loop combines available and builtin overlays for display and toggling. No changes were made to function signatures or exported entities.

Possibly related PRs

Suggested labels

05
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 309e933 and 63dd880.

📒 Files selected for processing (1)
  • tools/modules/system/manage_dtoverlays.sh (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tools/modules/system/manage_dtoverlays.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Home Assistant install (bookworm)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added size/small PR with less then 50 lines 08 Milestone: Third quarter release labels Jun 1, 2025
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label Jun 1, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
tools/modules/system/manage_dtoverlays.sh (2)

23-23: Add fallback for Raspberry Pi config path
Right now we unconditionally set overlayconf="/boot/firmware/config.txt". On some Pi variants or boot setups (e.g. older firmware), the config file may instead reside at /boot/config.txt. Consider testing for both locations and failing gracefully if neither exists:

-    overlayconf="/boot/firmware/config.txt"
+    if [[ -f /boot/firmware/config.txt ]]; then
+      overlayconf="/boot/firmware/config.txt"
+    elif [[ -f /boot/config.txt ]]; then
+      overlayconf="/boot/config.txt"
+    else
+      echo "Error: Raspberry Pi config file not found" >&2
+      return 1
+    fi

70-70: Ensure dialog prompt newlines render correctly
In a double-quoted shell string, \n is literal, so dialog may display \n instead of a line break. Switch to $'…' quoting or embed real newlines for proper formatting:

-        --checklist "\nUse <space> to toggle functions and save them.\nExit when you are done.\n\n    overlay_prefix=$overlay_prefix\n " \
+        --checklist $'\nUse <space> to toggle functions and save them.\nExit when you are done.\n\n    overlay_prefix='"$overlay_prefix"$'\n' \
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 658f9aa and 763b3e7.

📒 Files selected for processing (1)
  • tools/modules/system/manage_dtoverlays.sh (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Duplicati install (noble)
  • GitHub Check: OpenMediaVault install (bookworm)

@github-actions github-actions bot removed the Ready to merge Reviewed, tested and ready for merge label Jun 1, 2025
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label Jun 1, 2025
@The-going
Copy link
Contributor Author

I'm sorry. I must have lost my mind.
I'm arguing with a robot.

@The-going
Copy link
Contributor Author

"If the stars are lighting up in the sky, then someone needs it."
The_Little_Prince
Antoine de Saint-Exupéry

What was the reason to display all the overlays and give the user the opportunity to select even those that do not match the overlay prefix?

@igorpecovnik
Copy link
Member

What was the reason to display all the overlays and give the user the opportunity to select even those that do not match the overlay prefix?

Naming inconsistency - it was not displaying those that should.

@The-going
Copy link
Contributor Author

What was the reason to display all the overlays and give the user the opportunity to select even those that do not match the overlay prefix?

Naming inconsistency - it was not displaying those that should.

Naming overlays: ${overlay_prefix}-${some_name}.dtbo
I see that everything is consistent with the naming.
Or is it really not for all families? RPI ? rockchip ?
In this case, we can handle these exceptions.

@igorpecovnik
Copy link
Member

Or is it really not for all families? RPI ? rockchip ?

Yes, this is not consistent across families. We also have mainline naming and vendor (board vendor) specifics. It's a mess.

In this case, we can handle these exceptions.

This can only be done by different maintainers. That's the main problem.

@The-going
Copy link
Contributor Author

This can only be done by different maintainers. That's the main problem.

We have only two options.

  1. we find the necessary overlays and record the ones selected by the user with the full name containing the prefix.
  2. we find the necessary overlays and write them down with a name that does not contain a prefix.

Is that true?

Let's resolve this issue in this pull request.
I will rewrite part of the code for this function in AWK.
We will get a code made of reinforced concrete. And we will not return to this topic again.

@The-going
Copy link
Contributor Author

I will be able to check the code for sunxi, sunxi64, rockcip64.

@igorpecovnik
Copy link
Member

Without those changes, things works ...

Example of problem:
image

This board comes with LCD overlay and when we want to add overclocking overlay, nothing is changed ...

@The-going
Copy link
Contributor Author

This board comes with LCD overlay and when we want to add overclocking overlay, nothing is changed ...

I'm still working on it.
There are many hidden (yet to be discovered) problems in the code.
By the way, nothing works for sunxi without these changes.

@The-going
Copy link
Contributor Author

Analyze which scripts can load the ${overlay_prefix}-${overlay_file}.dtbo file:

armbian/build> awk -F"/" '/if load.*overlay\/\${overlay_prefix}-\${overlay_file}.dtbo/ {print FILENAME":", FNR}' config/bootscripts/*
config/bootscripts/boot-jethub.cmd: 75
config/bootscripts/boot-meson64.cmd: 152
config/bootscripts/boot-meson-gx.cmd: 42
config/bootscripts/boot-meson-s4t7.cmd: 62
config/bootscripts/boot-mvebu.cmd: 63
config/bootscripts/boot-rk322x.cmd: 54
config/bootscripts/boot-rk3576.cmd: 51
config/bootscripts/boot-rk35xx.cmd: 51
config/bootscripts/boot-rockchip64.cmd: 51
config/bootscripts/boot-rockchip64-ttyS0.cmd: 51
config/bootscripts/boot-rockchip.cmd: 54
config/bootscripts/boot-sun50i-next.cmd: 90
config/bootscripts/boot-sunxi.cmd: 106

13 files.

Analyze which scripts can load the ${overlay_file}.dtbo file:

armbian/build> awk -F"/" '/if load.*overlay\/\${overlay_file}.dtbo/ {print FILENAME":", FNR}' config/bootscripts/*
config/bootscripts/boot-rk3576.cmd: 54
config/bootscripts/boot-rk35xx.cmd: 54

Just two files.

Analyze which scripts can load a custom overlay file:

armbian/build> awk -F"/" '/if load.*overlay-user\/\${overlay_file}.dtbo/ {print FILENAME":", FNR}' config/bootscripts/*
config/bootscripts/boot-jethub.cmd: 82
config/bootscripts/boot-meson64.cmd: 159
config/bootscripts/boot-meson-gx.cmd: 48
config/bootscripts/boot-meson-s4t7.cmd: 69
config/bootscripts/boot-mvebu.cmd: 73
config/bootscripts/boot-rk322x.cmd: 60
config/bootscripts/boot-rk3576.cmd: 60
config/bootscripts/boot-rk35xx.cmd: 60
config/bootscripts/boot-rockchip64.cmd: 57
config/bootscripts/boot-rockchip64-ttyS0.cmd: 57
config/bootscripts/boot-rockchip.cmd: 60
config/bootscripts/boot-sun50i-next.cmd: 96
config/bootscripts/boot-sun50iw9.cmd: 58
config/bootscripts/boot-sunxi.cmd: 112

14 files.


Only two scripts will be able to load both spellings of the overlay file name.
The custom overlay will be uploaded only if we write the full name of the overlay file.

The script can be changed by the user for some of their tasks directly on the device.

Based on these assumptions, we need to analyze the existing script and write the names
of the overlays so that they can be loaded.

@The-going
Copy link
Contributor Author

The-going commented Jun 11, 2025

to add overclocking overlay, nothing is changed ...

Maybe this is a mistake:
config/bootscripts/boot-rk3576.cmd
bootscripts/boot-rk35xx.cmd
As far as I know, the u-boot command line does not support if...;then ... elif...; fi construction.
I think that's the right thing to do: if ...; then ... else if ...; then ....; fi; fi

@The-going
Copy link
Contributor Author

An amateur's question.
Is it possible to display overlays in the selection list in different colors?
For example, those that correspond to the prefix are green and all others are yellow.

@igorpecovnik
Copy link
Member

Is it possible to display overlays in the selection list in different colors?

I don't think that this is possible. Perhaps @Tearran knows more?

@The-going
Copy link
Contributor Author

Maybe this is a mistake:
config/bootscripts/boot-rk3576.cmd
bootscripts/boot-rk35xx.cmd

The current syntax in these two files works correctly at least in u-boot version 2025.01.
However, it will not work in outdated versions.
the elif condition will simply be ignored.

Due to backward compatibility with older versions of u-boot, the following syntax was implemented for sunxi:
config/bootscripts/boot-sunxi.cmd

@github-actions github-actions bot added size/medium PR with more then 50 and less then 250 lines and removed size/small PR with less then 50 lines Ready to merge Reviewed, tested and ready for merge labels Jun 12, 2025
@coderabbitai coderabbitai bot requested a review from igorpecovnik June 12, 2025 14:19
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label Jun 12, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
tools/modules/system/manage_dtoverlays.sh (2)

75-83: Mirror improvements for builtin_overlays pipeline
Same issues here:

  • Quote ${overlaydir} in find.
  • Use sub(/\.dtbo$/, "", $NF) instead of gsub(".dtbo", "", $0).
  • Simplify with find ... ! -name "${overlay_prefix}-*.dtbo" and a leaner awk.

53-53: Remove unused variable j
The variable j is assigned but never used (SC2034). Consider deleting this line to clean up dead code.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 53-53: j appears unused. Verify use (or export if used externally).

(SC2034)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f62f0b and bd87b58.

📒 Files selected for processing (1)
  • tools/modules/system/manage_dtoverlays.sh (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: The-going
PR: armbian/configng#609
File: tools/modules/system/manage_dtoverlays.sh:41-51
Timestamp: 2025-06-01T20:51:38.861Z
Learning: In tools/modules/system/manage_dtoverlays.sh, the original code behavior was to list ALL .dtbo files in the overlay directory regardless of overlay_prefix, but the refactored code filters to only show files starting with overlay_prefix. This behavioral change can break systems where overlay_prefix is empty/misconfigured or where users expect to see all available overlays.
Learnt from: The-going
PR: armbian/configng#609
File: tools/modules/system/manage_dtoverlays.sh:41-51
Timestamp: 2025-06-01T20:51:38.861Z
Learning: In tools/modules/system/manage_dtoverlays.sh, the original code behavior was to list ALL .dtbo files in the overlay directory regardless of overlay_prefix, but the refactored code filters to only show files starting with overlay_prefix. This behavioral change can break systems where overlay_prefix is empty/misconfigured or where users expect to see all available overlays.
tools/modules/system/manage_dtoverlays.sh (2)
Learnt from: The-going
PR: armbian/configng#609
File: tools/modules/system/manage_dtoverlays.sh:41-51
Timestamp: 2025-06-01T20:51:38.861Z
Learning: In tools/modules/system/manage_dtoverlays.sh, the original code behavior was to list ALL .dtbo files in the overlay directory regardless of overlay_prefix, but the refactored code filters to only show files starting with overlay_prefix. This behavioral change can break systems where overlay_prefix is empty/misconfigured or where users expect to see all available overlays.
Learnt from: The-going
PR: armbian/configng#609
File: tools/modules/system/manage_dtoverlays.sh:41-51
Timestamp: 2025-06-01T20:51:38.861Z
Learning: In tools/modules/system/manage_dtoverlays.sh, the original code behavior was to list ALL .dtbo files in the overlay directory regardless of overlay_prefix, but the refactored code filters to only show files starting with overlay_prefix. This behavioral change can break systems where overlay_prefix is empty/misconfigured or where users expect to see all available overlays.
🧬 Code Graph Analysis (1)
tools/modules/system/manage_dtoverlays.sh (1)
tools/modules/functions/set_runtime_variables.sh (1)
  • update_kernel_env (92-110)
🪛 Shellcheck (0.10.0)
tools/modules/system/manage_dtoverlays.sh

[warning] 53-53: j appears unused. Verify use (or export if used externally).

(SC2034)

🪛 GitHub Actions: Coding style check
tools/modules/system/manage_dtoverlays.sh

[error] 45-48: EditorConfig indentation error: wrong indentation type (spaces instead of tabs) on lines 45-48.

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Uptimekuma install (noble)
  • GitHub Check: Stable repository (bookworm)
  • GitHub Check: samba install (bookworm)
  • GitHub Check: OpenHab install (bookworm)
  • GitHub Check: Rolling repository (bookworm)
  • GitHub Check: Portainer install (noble)
  • GitHub Check: Home Assistant install (bookworm)
  • GitHub Check: Navidrome install (noble)
  • GitHub Check: Duplicati install (noble)
  • GitHub Check: Cockpit install (noble)
🔇 Additional comments (1)
tools/modules/system/manage_dtoverlays.sh (1)

23-23: Moved Raspberry Pi config path earlier in function
Great: now /boot/firmware/config.txt is set before determining overlays for bcm2711. Ensures prefix parsing reads from the correct file on RPi4.

@github-actions github-actions bot removed the Ready to merge Reviewed, tested and ready for merge label Jun 12, 2025
@Tearran
Copy link
Member

Tearran commented Jun 12, 2025

Colors: Yes? No? Maybe!?

While whiptail offers fewer features, that also means there's less to manage — no need to deal with color escape sequences, attribute flags, or added formatting logic. But if you're already accepting the added complexity, it makes sense to use those features properly.

The so-called entry point armbian-config (its frontend) does not support color, as it's built with whiptail, which lacks that capability.

However, since the TUI is already improperly integrated in this module, one might as well lean into it and use dialog instead — at least for modules like this one.

The escape sequence \Z<i> (i = 0–7) sets the foreground color for each line when using dialog with --colors. This allows for colored text like so:

{ dialog --colors \
  --title "Colored Text" \
  --msgbox "\Z1First line in red\n\Z3Second line in yellow\n\Z2Third line in green" 10 50; }
{38A4D295-BA3C-4BEE-BBF4-C8DB580667C1}

For systems limited to whiptail, which doesn't support color codes, the best we can do is emphasize text through UPPERCASE. For example, using Bash:

{
  text=$(awk 'NR==1{ print toupper($0) } NR>1{ print }' <<EOF
first line to emphasize
Second line normal
EOF
)
  whiptail --title "Notice" --msgbox "$text" 10 50
}
{4779924D-9D19-4B73-B8E8-70A00CF29B98}

If we follow a color pattern — say, green, yellow, and red to suggest Go, Caution, and Stop — we can align visual emphasis accordingly:

  • Green → normal text or should work
  • Yellow → normal text or may or may not work
  • Red → uppercase or critical

Or mix them in any combination the module might require.

@The-going
Copy link
Contributor Author

The escape sequence \Z<i> (i = 0–7) sets the foreground color for each line when using dialog with --colors. This allows for colored text like so:

{ dialog --colors \
  --title "Colored Text" \
  --msgbox "\Z1First line in red\n\Z3Second line in yellow\n\Z2Third line in green" 10 50; }

Yes, it works well for text messages, but not for a selection list.
I couldn't do it.

I made changes directly on the device and then transferred them to the github.
How can I check (install from my repository) these changes?

@Tearran
Copy link
Member

Tearran commented Jun 13, 2025

tools/README.md

Assemble the modules into a production library

From the repo folder

./configng/tools/config-assemble.sh" -p 

Launch

./bin/armbian-config

alternatively can bypass menu and directly run

./bin/armbian-config --cmd DT001
./bin/armbian-config --api manage_dtoverlays # missing help message

@Tearran
Copy link
Member

Tearran commented Jun 13, 2025

@coderabbitai

manage_dtoverlays module is missing a help message and trigger
Show a help message helper for function manage_dtoverlays module called _about_manage_dtoverlays

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 13, 2025

Tip

For best results, initiate chat on the files or code changes.

@Tearran Thanks for spotting that!
Every interactive module should indeed expose its about helper so that armbian-config --help and --api can list/describe it, but manage_dtoverlays currently has none.

I’ll prepare a small patch that:

  1. Adds
_about_manage_dtoverlays() {
    cat <<-EOF
    Device-Tree Overlay Manager (DTO): enable/disable builtin or user-provided
    *.dtbo* overlays and persist the choice in /boot/*.  
    Handles prefix variations and displays the effective boot-script scenario.
    EOF
}
  1. Registers it in the dispatcher ( tools/modules/system/_dispatcher.sh ) so that:
    armbian-config --cmd DT001 or --api manage_dtoverlays [help] returns the message above.

Let me know if you’d like different wording or extra details and I’ll include that in the plan.

@The-going
Copy link
Contributor Author

@igorpecovnik I think I believed the possible options. They're working.
I tested it on OPI-5-plus using the image provided by @EvilOlaf with the vendor's core.
u-boot console with overlay_prefix=rockchip-rk3588 overlays=panthor-gpu orangepi-5-plus-ov13850:

Working FDT set to 12000000
441 bytes read in 14 ms (30.3 KiB/s)
Applying kernel provided DT overlay rockchip-rk3588-panthor-gpu.dtbo
Failed to load '/boot/dtb/rockchip/overlay/rockchip-rk3588-orangepi-5-plus-ov13850.dtbo'
1547 bytes read in 16 ms (93.8 KiB/s)
Applying kernel provided DT overlay orangepi-5-plus-ov13850.dtbo

As we can see, both overlays with the short and full spelling of the name were loaded.
The script /boot/boot.scr can do this.
But the existing version of armbian-config allowed you to write only the full name.
dtoverlays-old

After the changes in this pull request, the overlays corresponding to the prefix will be placed at the top
of the selection list (first).
And the entry in the configuration file will be made correctly.
dtoverlays-new


I tested it on an OPI-5-plus with a gnome image that I put together myself.
The script /boot/boot.scr in it cannot load both options.
Therefore, all I saw in the u-boot console was an error saying that the overlay with a double prefix could not be loaded.

With the new changes, everything happens correctly and the overlays load.
I hope my explanations are clear.

@igorpecovnik
Copy link
Member

OK, here I think we need to test on:

  • rpi
  • mainline kernel overlays
  • amlogic

I assume Allwinner and Rockchip (vendor) both works as expected?

@The-going
Copy link
Contributor Author

I assume Allwinner and Rockchip (vendor) both works as expected?

I think this will work for all the options available in Armbian today.
A naive lexical analyzer has been added here.
For this reason, it is very important for us to have an agreement on the names of the variables that we use in the script /boot/boot.scr (.cmd).
We can make the lexical analyzer more complex (universal) in this case and will not depend on any family.
On the contrary, if people change the names of variables, for example here (8287), we will get a mess and constant fixes in our overlay management module.

@The-going
Copy link
Contributor Author

By the way, this condition may be superfluous.

igorpecovnik
igorpecovnik previously approved these changes Jun 19, 2025
Copy link
Member

@igorpecovnik igorpecovnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the contrary, if people change the names of variables, for example armbian/build#8287, we will get a mess and constant fixes in our overlay management module.

OK, I assume he will pay attention.

Merge at will.

@github-actions github-actions bot removed the Ready to merge Reviewed, tested and ready for merge label Jun 19, 2025
@coderabbitai coderabbitai bot requested a review from igorpecovnik June 19, 2025 13:19
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label Jun 19, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
tools/modules/system/manage_dtoverlays.sh (4)

61-66: Consider hardening the overlay-listing pipeline.

  • Quote the -name pattern as -name "${overlay_prefix}*.dtbo".
  • Use sub with anchored regex to strip suffix only (sub(/\.dtbo$/, "", $NF)).
  • Optionally anchor prefix removal (sub("^" overlay_prefix "-", "", $NF)).

Example diff:

-find "${overlaydir}"/ -name "$overlay_prefix"'*.dtbo' 2>/dev/null | \
-awk -F'/' -v p="${overlay_prefix}-" '{
-    gsub(p, "", $NF)
-    gsub(".dtbo", "", $NF)
-    print $NF
-}' | sort
+find "${overlaydir}/" -type f -name "${overlay_prefix}*.dtbo" 2>/dev/null | \
+awk -F'/' -v p="${overlay_prefix}-" '{
+    sub("^" p, "", $NF)
+    sub(/\.dtbo$/, "", $NF)
+    print $NF
+}' | sort

77-85: Harden builtin overlay extraction similarly.

  • Quote wildcard patterns uniformly.
  • Replace gsub(".dtbo", "", $NF) with sub(/\.dtbo$/, "", $NF).
  • Drop the redundant if ($0 !~ p) since find ! -name already excludes prefix matches.

Suggested snippet:

-find "${overlaydir}/" -name '*.dtbo' ! -name "$overlay_prefix"'*.dtbo' 2>/dev/null | \
-awk -F'/' -v p="${overlay_prefix}" '{
-    if ($0 !~ p) {
-        gsub(".dtbo", "", $NF)
-        print $NF
-    }
-}' | sort
+find "${overlaydir}/" -type f -name '*.dtbo' ! -name "${overlay_prefix}*.dtbo" 2>/dev/null | \
+awk -F'/' '{
+    sub(/\.dtbo$/, "", $NF)
+    print $NF
+}' | sort

102-102: Quote variables in the loop and grep to prevent word-splitting.
Even if overlay names lack spaces, consistent quoting avoids future pitfalls.

Example:

-for overlay in ${available_overlays} ${builtin_overlays}; do
+IFS=$'\n'
+for overlay in ${available_overlays} ${builtin_overlays}; do
     local status="OFF"
-    grep '^overlays' ${overlayconf} | grep -qw ${overlay} && status=ON
-    grep '^dtoverlay' ${overlayconf} | grep -qw ${overlay} && status=ON
+    grep -qE "^overlays.*\b${overlay}\b" "${overlayconf}" && status=ON
+    grep -qE "^dtoverlay=.*\b${overlay}\b" "${overlayconf}" && status=ON
     options+=( "$overlay" "" "$status")
 done
+unset IFS

110-111: Refine the dialog prompt string for consistency.
Consider moving overlay_prefix=$overlay_prefix above the instructions and removing the trailing space/newline for a cleaner UI.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7e175a and 309e933.

📒 Files selected for processing (1)
  • tools/modules/system/manage_dtoverlays.sh (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: The-going
PR: armbian/configng#609
File: tools/modules/system/manage_dtoverlays.sh:41-51
Timestamp: 2025-06-01T20:51:38.861Z
Learning: In tools/modules/system/manage_dtoverlays.sh, the original code behavior was to list ALL .dtbo files in the overlay directory regardless of overlay_prefix, but the refactored code filters to only show files starting with overlay_prefix. This behavioral change can break systems where overlay_prefix is empty/misconfigured or where users expect to see all available overlays.
Learnt from: The-going
PR: armbian/configng#609
File: tools/modules/system/manage_dtoverlays.sh:41-51
Timestamp: 2025-06-01T20:51:38.861Z
Learning: In tools/modules/system/manage_dtoverlays.sh, the original code behavior was to list ALL .dtbo files in the overlay directory regardless of overlay_prefix, but the refactored code filters to only show files starting with overlay_prefix. This behavioral change can break systems where overlay_prefix is empty/misconfigured or where users expect to see all available overlays.
tools/modules/system/manage_dtoverlays.sh (2)
Learnt from: The-going
PR: armbian/configng#609
File: tools/modules/system/manage_dtoverlays.sh:41-51
Timestamp: 2025-06-01T20:51:38.861Z
Learning: In tools/modules/system/manage_dtoverlays.sh, the original code behavior was to list ALL .dtbo files in the overlay directory regardless of overlay_prefix, but the refactored code filters to only show files starting with overlay_prefix. This behavioral change can break systems where overlay_prefix is empty/misconfigured or where users expect to see all available overlays.
Learnt from: The-going
PR: armbian/configng#609
File: tools/modules/system/manage_dtoverlays.sh:41-51
Timestamp: 2025-06-01T20:51:38.861Z
Learning: In tools/modules/system/manage_dtoverlays.sh, the original code behavior was to list ALL .dtbo files in the overlay directory regardless of overlay_prefix, but the refactored code filters to only show files starting with overlay_prefix. This behavioral change can break systems where overlay_prefix is empty/misconfigured or where users expect to see all available overlays.
🪛 Shellcheck (0.10.0)
tools/modules/system/manage_dtoverlays.sh

[warning] 53-53: j appears unused. Verify use (or export if used externally).

(SC2034)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: OpenHab install (bookworm)
  • GitHub Check: Duplicati install (noble)
  • GitHub Check: Home Assistant install (bookworm)
🔇 Additional comments (5)
tools/modules/system/manage_dtoverlays.sh (5)

4-4: Maintainer metadata update looks correct.
The addition of @igorpecovnik,@The-going as maintainers aligns with the PR collaboration.


23-23: Early override of overlayconf for Raspberry Pi is valid.
Switching to /boot/firmware/config.txt before scanning overlays ensures downstream code points to the correct file.


36-48: Scenario detection comment and AWK patterns are clear and correct.
The overlays?\/ quantifier matches both overlay/ and overlays/, and escaping \${…} ensures literal matching in /boot/boot.scr.


55-55: Conditional branch for prefix-only scenario is implemented correctly.
The [[ "${scenario}" == "10" || "${scenario}" == "11" ]] check cleanly gates the listing of prefix-based overlays.


75-75: Vendor-kernel branch overlay support gating is correct.
The scenario check for "01" or "11", combined with the rockchip-rk3588/vender guard, ensures only relevant built-in overlays are added.

@github-actions github-actions bot removed the Ready to merge Reviewed, tested and ready for merge label Jul 12, 2025
@coderabbitai coderabbitai bot added the 05 Milestone: Second quarter release label Jul 12, 2025
@igorpecovnik igorpecovnik merged commit c40a534 into armbian:main Jul 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release 08 Milestone: Third quarter release size/medium PR with more then 50 and less then 250 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants