Hey,

The first patch committed here allows people to uninstall
raspi-firmware more easily. I suggest the attached to make things
easier for people even before that removal...

-- 
Steve McIntyre, Cambridge, UK.                                st...@einval.com
  Getting a SCSI chain working is perfectly simple if you remember that there
  must be exactly three terminations: one on one end of the cable, one on the
  far end, and the goat, terminated over the SCSI chain with a silver-handled
  knife whilst burning *black* candles. --- Anthony DeBoer
>From 75142eda35e6554d6f40ee2501e9cef1607a6f06 Mon Sep 17 00:00:00 2001
From: Steve McIntyre <st...@einval.com>
Date: Sun, 9 Jul 2023 20:29:51 +0100
Subject: [PATCH] Don't attempt to do anything with /boot/firmware unless we're

running on an arm-based system. #1032186 again.
---
 debian/kernel/postinst.d/z50-raspi-firmware | 14 ++++++++++++++
 debian/raspi-firmware.postinst              | 15 +++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/debian/kernel/postinst.d/z50-raspi-firmware b/debian/kernel/postinst.d/z50-raspi-firmware
index 9b3bfa5..b4a2d75 100755
--- a/debian/kernel/postinst.d/z50-raspi-firmware
+++ b/debian/kernel/postinst.d/z50-raspi-firmware
@@ -27,11 +27,25 @@ pi_4_family() {
   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-architecture -q DEB_TARGET_ARCH)
+  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
+  echo "$0: Not running on an arm-based system, doing nothing"
+  exit 0
 elif ! mountpoint -q /boot/firmware ; then
   echo "raspi-firmware: missing /boot/firmware, did you forget to mount it?" >&2
   exit 1
diff --git a/debian/raspi-firmware.postinst b/debian/raspi-firmware.postinst
index 8ecc5f3..22e86d3 100644
--- a/debian/raspi-firmware.postinst
+++ b/debian/raspi-firmware.postinst
@@ -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-architecture -q DEB_TARGET_ARCH)
+  case "$DPKG_ARCH" in
+    arm64|armel|armhf)
+      return 0;;
+    *)
+      return 1;;
+  esac
+}
+
 case "$1" in
   configure)
 
@@ -10,6 +22,9 @@ case "$1" in
       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
+      echo "$0: Not running on an arm-based system, doing nothing"
+      exit 0
     elif ! mountpoint -q /boot/firmware; then
       echo "Error: missing /boot/firmware, did you forget to mount it?" >&2
       exit 1
-- 
2.30.2

Reply via email to