Skip to content

Commit 1666b8c

Browse files
authored
Update to manage_dtoverlays.sh for overlay_prefix handling (revised) (#615)
* Update manage_dtoverlays.sh, overlay_prefix handling For issues #612 and #592 where overlays don't load because the overlay_prefix gets written to armbianEnv.txt along with the overlay name. See #612 and #592 for details. * Update manage_dtoverlays.sh per rabbit review comments Updated per code rabbit suggestions and added handling the presence of a hyphen "-" following the prefix as a separate check. * Update manage_dtoverlays.sh Fixed issue with overlay status update failing due to remaining "-" not being removed along with overlay_prefix.
1 parent c40a534 commit 1666b8c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tools/modules/system/manage_dtoverlays.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ function manage_dtoverlays () {
104104
grep '^overlays' ${overlayconf} | grep -qw ${overlay} && status=ON
105105
# Raspberry Pi
106106
grep '^dtoverlay' ${overlayconf} | grep -qw ${overlay} && status=ON
107+
# handle case where overlay_prefix is part of overlay name
108+
if [[ -n $overlay_prefix ]]; then
109+
candidate="${overlay#$overlay_prefix}"
110+
candidate="${candidate#'-'}" # remove any trailing hyphen
111+
else
112+
candidate="$overlay"
113+
fi
114+
grep '^overlays' ${overlayconf} | grep -qw ${candidate} && status=ON
107115
options+=( "$overlay" "" "$status")
108116
done
109117
selection=$($DIALOG --title "Manage devicetree overlays" --cancel-button "Back" \
@@ -114,6 +122,19 @@ function manage_dtoverlays () {
114122
0)
115123
changes="true"
116124
newoverlays=$(echo $selection | sed 's/"//g')
125+
# handle case where overlay_prefix is part of overlay name
126+
IFS=' ' read -r -a ovs <<< "$newoverlays"
127+
newoverlays=""
128+
# remove prefix, if any
129+
for ov in "${ovs[@]}"; do
130+
if [[ -n $overlay_prefix && $ov == "$overlay_prefix"* ]]; then
131+
ov="${ov#$overlay_prefix}"
132+
fi
133+
# remove '-' hyphen from beginning of ov, if any
134+
ov="${ov#-}"
135+
newoverlays+="$ov "
136+
done
137+
newoverlays="${newoverlays% }"
117138
# Raspberry Pi
118139
if [[ "${LINUXFAMILY}" == "bcm2711" ]]; then
119140
# Remove any existing Armbian config block

0 commit comments

Comments
 (0)