Hi, it looks like this bug was introduced in the suggested patch for #1032186 [1].

I've attached a simple patch which rearranges the conditionals to make sure the variables containing the Kernel and Initrd names are populated even if the command is "remove".

Daniel

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1032186#5

On Fri, 14 Jul 2023 15:52:24 -0500 Andreas Kloeckner <inf...@tiker.net> wrote:
Package: raspi-firmware
Version: 1.20230405+ds-1
Severity: important

Dear Maintainer,

When removing a no-longer-in-use kernel recently, the raspi-firmware
postrm script, presumably the fact that this line [1] is not executed
on kernel removals, left me with a /boot/firmware/config.txt containing
the line

kernel=auto

which in turn left the Raspi (Model 4B in case it matters) firmware
very confused, and the machine unbootable.

Andreas

[1] 
https://salsa.debian.org/debian/raspi-firmware/-/blob/9cafcd85f8aed1ec0c0f609b98af591fae367ba2/debian/kernel/postinst.d/z50-raspi-firmware#L128


-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 
'stable-security'), (500, 'unstable'), (500, 'stable'), (1, 
'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.3.0-1-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), 
LANGUAGE=de_DE:de
Shell: /bin/sh linked to /usr/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.21.22

raspi-firmware recommends no packages.

Versions of packages raspi-firmware suggests:
pn  bluez-firmware         <none>
pn  firmware-brcm80211     <none>
ii  firmware-misc-nonfree  20230515-3

From bdf757722770155e9e885b2fff7f229100ca898c Mon Sep 17 00:00:00 2001
From: Daniel Moran <dij...@gmail.com>
Date: Sun, 6 Aug 2023 14:49:31 +0100
Subject: [PATCH 1/1] Ensure kernel and initrd names are set, even on remove

---
 debian/kernel/postinst.d/z50-raspi-firmware | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/debian/kernel/postinst.d/z50-raspi-firmware b/debian/kernel/postinst.d/z50-raspi-firmware
index 9b3bfa502744..86d5d95fa683 100755
--- a/debian/kernel/postinst.d/z50-raspi-firmware
+++ b/debian/kernel/postinst.d/z50-raspi-firmware
@@ -115,18 +115,18 @@ else
   dtb_path="/usr/lib/linux-image-${latest_kernel#/boot/vmlinuz-}"
 fi
 
-# Do not copy DTBs or kernel/initramfs when removing packages (#1032186)
-if [ "$1" != "remove" ]; then
-  if [ "$KERNEL" = "auto" ] ; then
+if [ "$KERNEL" = "auto" ] ; then
+  latest_kernel_basename=$(basename "$latest_kernel")
+  latest_initrd_basename=$(basename "$latest_initrd")
+  KERNEL=${latest_kernel_basename}
+
+  # Do not copy DTBs or kernel/initramfs when removing packages (#1032186)
+  if [ "$1" != "remove" ]; then
     for dtb in "${dtb_path}"/bcm*.dtb; do
       [ -e "${dtb}" ] || continue
       cp "${dtb}" /boot/firmware/
     done
 
-    latest_kernel_basename=$(basename "$latest_kernel")
-    latest_initrd_basename=$(basename "$latest_initrd")
-    KERNEL=${latest_kernel_basename}
-
     cp "$latest_kernel" /boot/firmware/
     cp "$latest_initrd" /boot/firmware/
   fi
-- 
2.40.1

Reply via email to