Package: raspi-firmware
Version: 1.20210303+ds-2
Severity: normal
File: /etc/kernel/postinst.d/z50-raspi-firmware
Tags: patch

Hi Debian Raspberry Pi Maintainers,

I noticed that /etc/kernel/postinst.d/z50-raspi-firmware is meant to
include a comment with a warning when generating
/boot/firmware/config.txt:

---
# Truncate the config.txt file so that we start with a blank slate
echo <<EOF >/boot/firmware/config.txt
# Do not modify this file!
#
# It is automatically generated upon install or update of either the
# firmware or the Linux kernel.
#
# If you need to set boot-time parameters, do so via the
# /etc/default/raspi-firmware or /etc/default/raspi-extra-cmdline
#files.

EOF
---

But echo was used by mistake instead of cat, so the comment is not
actually included:

---
$ cat /boot/firmware/config.txt 

enable_uart=1
upstream_kernel=1

kernel=vmlinuz-5.10.0-11-rpi
# For details on the initramfs directive, see
# https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=10532
initramfs initrd.img-5.10.0-11-rpi
---

This has the potential to frustrate users who aren't aware that the
file is automatically generated, and find their changes disappear upon
upgrading their kernel.

Additionally, for arm64 users, the comment would be overwritten due to
use of > instead of >>:

---
if [ "$arch" = "arm64" ]; then
  cat >/boot/firmware/config.txt <<EOF
---

I also propose changing the reference to
/etc/default/raspi-extra-cmdline inside that comment to
/etc/default/raspi-firmware-custom instead, since the latter file (and
not the former) affects what goes into /boot/firmware/config.txt.
That is, if someone needs to add something to config.txt which isn't
covered by /e/d/raspi-firmware, then it's /e/d/raspi-firmware-custom
that they will need to edit.

I've attached a patch which addresses these three concerns.  (If you
notice that I changed the order of the redirection and here-doc
operators in the first fix, it's to be consistent with the other uses
throughout the file: output first, then here-doc.)

Thanks for taking a look,
-Jean-Paul

-- System Information:
Debian Release: 11.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: armel (armv6l)

Kernel: Linux 5.10.0-11-rpi
Kernel taint flags: TAINT_CRAP, TAINT_UNSIGNED_MODULE
Locale: LANG=C, LC_CTYPE=C (charmap=UTF-8) (ignored: LC_ALL set to 
en_US.UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages raspi-firmware depends on:
ii  dosfstools  4.2-1
ii  dpkg        1.20.9

raspi-firmware recommends no packages.

raspi-firmware suggests no packages.

-- no debconf information
--- /etc/kernel/postinst.d/z50-raspi-firmware.dpkg-dist	2021-04-20 22:52:21.000000000 -0700
+++ /etc/kernel/postinst.d/z50-raspi-firmware	2022-01-23 21:31:53.178811042 -0800
@@ -94,20 +94,20 @@
 
 
 # Truncate the config.txt file so that we start with a blank slate
-echo <<EOF >/boot/firmware/config.txt
+cat >/boot/firmware/config.txt <<EOF
 # Do not modify this file!
 #
 # It is automatically generated upon install or update of either the
 # firmware or the Linux kernel.
 #
 # If you need to set boot-time parameters, do so via the
-# /etc/default/raspi-firmware or /etc/default/raspi-extra-cmdline
-#files.
+# /etc/default/raspi-firmware or /etc/default/raspi-firmware-custom
+# files.
 
 EOF
 
 if [ "$arch" = "arm64" ]; then
-  cat >/boot/firmware/config.txt <<EOF
+  cat >>/boot/firmware/config.txt <<EOF
 # Switch the CPU from ARMv7 into ARMv8 (aarch64) mode
 arm_64bit=1
 

Reply via email to