raspberry-pi/4/dtmerge: fix application of overlays

Previously whenever an overlay was found to be incompatible with a base
device tree blob, the entire base dtb would be skipped in favor of
processing the next one. This had the unfortunate effect where overlays
would not fully be applied if any incompatibility was found. For
example, this is an issue with build device trees specific for one
flavor of raspberry pi if the overlay was not compatible _everywhere_.

The solution is to forego the `continue` keyword if an overlay is in
compatible and instead use a compound conditional statement to skip
incompatible overlays but continue trying to apply it to any remaining
dtbs.
This commit is contained in:
Ivan Petkov 2023-01-16 19:57:10 -08:00
parent 7bd6b87b37
commit 320866b985
No known key found for this signature in database
GPG key ID: BB6F9EFC065832B6

View file

@ -24,26 +24,24 @@ with lib; (base: overlays': stdenvNoCC.mkDerivation {
# skip incompatible and non-matching overlays # skip incompatible and non-matching overlays
if [[ ! "$dtbCompat" =~ "$overlayCompat" ]]; then if [[ ! "$dtbCompat" =~ "$overlayCompat" ]]; then
echo "Skipping overlay ${o.name}: incompatible with $(basename "$dtb")" echo "Skipping overlay ${o.name}: incompatible with $(basename "$dtb")"
continue elif ${if ((o.filter or null) == null) then "false" else ''
fi [[ "''${dtb//${o.filter}/}" == "$dtb" ]]
${optionalString ((o.filter or null) != null) ''
if [[ "''${dtb//${o.filter}/}" == "$dtb" ]]; then
echo "Skipping overlay ${o.name}: filter does not match $(basename "$dtb")"
continue
fi
''} ''}
then
echo "Skipping overlay ${o.name}: filter does not match $(basename "$dtb")"
else
echo -n "Applying overlay ${o.name} to $(basename "$dtb")... "
mv "$dtb"{,.in}
echo -n "Applying overlay ${o.name} to $(basename "$dtb")... " # dtmerge requires a .dtbo ext for dtbo files, otherwise it adds it to the given file implicitly
mv "$dtb"{,.in} dtboWithExt="$TMPDIR/$(basename "${o.dtboFile}").dtbo"
cp -r ${o.dtboFile} "$dtboWithExt"
# dtmerge requires a .dtbo ext for dtbo files, otherwise it adds it to the given file implicitly dtmerge "$dtb.in" "$dtb" "$dtboWithExt"
dtboWithExt="$TMPDIR/$(basename "${o.dtboFile}").dtbo"
cp -r ${o.dtboFile} "$dtboWithExt"
dtmerge "$dtb.in" "$dtb" "$dtboWithExt" echo "ok"
rm "$dtb.in" "$dtboWithExt"
echo "ok" fi
rm "$dtb.in" "$dtboWithExt"
'')} '')}
done''; done'';