Bug#1049902: [Pkg-raspi-maintainers] Bug#1049902: bookworm-pu: package raspi-firmware/20220830+ds-1+deb12u1

2023-08-16 Thread Cyril Brulebois
Hi Gunnar,

Gunnar Wolf  (2023-08-16):
> [ Risks ]
> The code is very simple.

Cassandra being my middle name, I'd advocate for more caution: The code
change is relatively simple, but raspi-firmware hooks are not trivial…

> The only risk I can think of is that the bug might still impact users
> of non-Raspberry ARM systems. However, the likelihood of having it
> installed is minor (due to the available hardware being different).

Live images as of 12.0.0 installed all firmware packages, including that
one, so that likelihood is *definitely not minor*.

> [ Changes ]
> Postinst will now check whether the architecture is ARM*, and exit
> otherwise without doing the firmware install dance.
> 
> [ Other info ]
> A more proper fix would be to create a separate package with the wireless
> Broadcom firmware. I have requested for the kernel team (maintainers of
> firmware-brcm80211) to do so, but have got no positive response.

I'd call that an orthogonal topic.


In the extra checks department, I'd suggest making sure that once
raspi-firmware is installed on say an amd64 machine, upgrading it to the
proposed version makes it possible to upgrade a kernel (which has been
the major pain point up to now) and also to… remove raspi-firmware.

As far as I can remember from user horror stories, they couldn't even
remove the package, and had to manually remove hooks under /etc before
being able to finally remove the package. Pinch of salt, don't trust my
memory.


Cheers,
-- 
Cyril Brulebois -- Debian Consultant @ DEBAMAX -- https://debamax.com/


signature.asc
Description: PGP signature


Bug#1049902: bookworm-pu: package raspi-firmware/20220830+ds-1+deb12u1

2023-08-16 Thread Gunnar Wolf
Package: release.debian.org
Severity: normal
Tags: bookworm
User: release.debian@packages.debian.org
Usertags: pu
X-Debbugs-Cc: raspi-firmw...@packages.debian.org
Control: affects -1 + src:raspi-firmware

[ Reason ]
raspi-firmware was built assuming it would be installed only in Raspberry
systems. However, now that firmware-nonfree is a proper section of Debian, and
there is firmware autodetection, it gets pulled in several AMD64 systems as
well.

When /boot/firmware is not mounted (as is the case in AMD64), postinst
fails. This yields a failure on kernel upgrades.

[ Impact ]
Many users have reported issues when upgrading the kernel.

[ Tests ]
I have not yet tested this particular version (but intend to do so soon and
report -- I want to get this reported to you first, though!), but the debdiff is
trivial, and is backported identically to the fix I sent to unstable (and is now
in testing) several weeks ago.

[ Risks ]
The code is very simple.

The only risk I can think of is that the bug might still impact users of
non-Raspberry ARM systems. However, the likelihood of having it installed is
minor (due to the available hardware being different). Besides, fixing this
(i.e. via detectng the Raspberry model from entries in /sys) would break other
use cases, such as VM-based image building.

[ Checklist ]
  [X] *all* changes are documented in the d/changelog
  [X] I reviewed all changes and I approve them
  [X] attach debdiff against the package in (old)stable
  [X] the issue is verified as fixed in unstable

[ Changes ]
Postinst will now check whether the architecture is ARM*, and exit otherwise
without doing the firmware install dance.

[ Other info ]
A more proper fix would be to create a separate package with the wireless
Broadcom firmware. I have requested for the kernel team (maintainers of
firmware-brcm80211) to do so, but have got no positive response.

-- 

diff -Nru raspi-firmware-1.20220830+ds/debian/changelog 
raspi-firmware-20220830+ds/debian/changelog
--- raspi-firmware-1.20220830+ds/debian/changelog   2022-10-03 
09:11:55.0 -0500
+++ raspi-firmware-20220830+ds/debian/changelog 2023-08-16 09:51:39.0 
-0600
@@ -1,3 +1,10 @@
+raspi-firmware (20220830+ds-1+deb12u1) bookworm; urgency=medium
+
+  * Skip running postinst if installing on a system that's not arch:arm*
+(Closes: #1040896, #1040485, #1042070, #1040669, #1049448)
+
+ -- Gunnar Wolf   Wed, 16 Aug 2023 09:51:39 -0600
+
 raspi-firmware (1.20220830+ds-1) unstable; urgency=medium
 
   [ Gunnar Wolf ]
diff -Nru 
raspi-firmware-1.20220830+ds/debian/kernel/postinst.d/z50-raspi-firmware 
raspi-firmware-20220830+ds/debian/kernel/postinst.d/z50-raspi-firmware
--- raspi-firmware-1.20220830+ds/debian/kernel/postinst.d/z50-raspi-firmware
2022-10-03 09:11:55.0 -0500
+++ raspi-firmware-20220830+ds/debian/kernel/postinst.d/z50-raspi-firmware  
2023-08-16 09:51:39.0 -0600
@@ -27,11 +27,25 @@
   grep -q 'Raspberry Pi \(Compute Module \)*4' 
/sys/firmware/devicetree/base/model 2>/dev/null
 }
 
+is_arm_system() {
+  # Check to see if the host is running an arm-based system
+  # (i.e. whether the raspi-firmware package is useful)
+  DPKG_ARCH=$(dpkg --print-architecture)
+  case "$DPKG_ARCH" in
+arm64|armel|armhf)
+  return 0;;
+*)
+  return 1;;
+  esac
+}
 
 if ischroot ; then
   true # chroot detected - skip mount point check
 elif [ -e /usr/bin/systemd-detect-virt ] && systemd-detect-virt -q ; then
   true # virtualization detected - skip mount point check
+elif ! is_arm_system ; then
+  # Not running on an arm-based system, skip postinst.
+  exit 0
 elif ! mountpoint -q /boot/firmware ; then
   echo "raspi-firmware: missing /boot/firmware, did you forget to mount it?" 
>&2
   exit 1
diff -Nru raspi-firmware-1.20220830+ds/debian/raspi-firmware.postinst 
raspi-firmware-20220830+ds/debian/raspi-firmware.postinst
--- raspi-firmware-1.20220830+ds/debian/raspi-firmware.postinst 2022-10-03 
09:11:55.0 -0500
+++ raspi-firmware-20220830+ds/debian/raspi-firmware.postinst   2023-08-16 
09:51:39.0 -0600
@@ -3,6 +3,18 @@
 
 set -e
 
+is_arm_system() {
+  # Check to see if the host is running an arm-based system
+  # (i.e. whether the raspi-firmware package is useful)
+  DPKG_ARCH=$(dpkg --print-architecture)
+  case "$DPKG_ARCH" in
+arm64|armel|armhf)
+  return 0;;
+*)
+  return 1;;
+  esac
+}
+
 case "$1" in
   configure)
 
@@ -10,6 +22,9 @@
   true # chroot detected - skip mount point check
 elif test -e /usr/bin/systemd-detect-virt && systemd-detect-virt -q ; then
   true # virtualization detected - skip mount point check
+elif ! is_arm_system ; then
+  # Not running on an arm-based system, skip the postinst
+  exit 0
 elif ! mountpoint -q /boot/firmware; then
   echo "Error: missing /boot/firmware, did you forget to mount it?" >&2
   exit 1


signature.asc
Description: PGP signature