PKGBUILDs/core/linux-rpi/linux-rpi.install
graysky 534261c88c core/linux-rpi to 6.1.66-5
Upstream bump and modernize and rework $pkgname.install to use EOF
statements and to advertise linux-rpi-16k for users of RPi5
2023-12-13 08:05:43 -05:00

59 lines
1.3 KiB
Text

disable_cma() {
if [[ -f /boot/config.txt && $(grep '^cma' /boot/config.txt) != '' ]]; then
cat <<END
>>> You appear to have dynamic memory (CMA) enabled, which is currently broken
in newer kernels and will cause many issues if left enabled. Disabling that
for you now.
END
sed -i 's/^cma_/#cma_/g' /boot/config.txt
fi
}
correct_fstab() {
# starting with v5.10.y, fstab requires a padded zero in the path to /boot
if [[ -f /etc/fstab ]]; then
if grep -q mmcblk1p1 /etc/fstab; then
sed -i 's/mmcblk1p1/mmcblk0p1/' /etc/fstab
fi
fi
}
advertise_rpi5() {
if [[ -f /sys/firmware/devicetree/base/model ]]; then
if grep -a -q 5 /sys/firmware/devicetree/base/model; then
cat <<END
>>> For optimal performance on RPi5, consider installing the
linux-rpi-16k kernel package instead of linux-rpi.
END
fi
fi
}
post_install () {
post_upgrade
}
post_upgrade() {
advertise_rpi5
correct_fstab
disable_cma
if grep "^[^#]*[[:space:]]/boot" etc/fstab 2>&1 >/dev/null; then
if ! grep "[[:space:]]/boot" etc/mtab 2>&1 >/dev/null; then
cat <<END
>>> WARNING: /boot appears to be a separate partition but is not mounted.
You probably just broke your system. Congratulations.
END
fi
fi
}
post_remove() {
rm -f boot/initramfs-linux.img
}