Bug#983409: raspi-firmware: /etc/kernel/postinst.d/z50-raspi-firmware fails to ignore old-dkms initrds

2021-04-28 Thread Gunnar Wolf
Control: tags -1 - patch
Control: tags -1 + pending

Hi,

While your patch would work for arm64 (RPi 3 and 4 families), it would
not work for armel (RPi 0/1) or armhf (RPi 2). The suffix of the
kernel version denotes the machine type, not just the architecture;
our working armel kernel is -rpi, and our working armhf kernel is
-armmp.

We could set those suffixes based on the output of "dpkg
--print-architecture", but I fear that would also end up in unbootable
systems for some people who built their own kernels or so.

I will go the other route, and -same as I'm doing grep -v \.dpkg-bak$-
will exclude the known suffix you report for DKMS kernels. I hope that
solves the issue!



Bug#983409: raspi-firmware: /etc/kernel/postinst.d/z50-raspi-firmware fails to ignore old-dkms initrds

2021-02-23 Thread Colm Buckley
Package: raspi-firmware
Version: 1.20200601-3~bpo10+1
Severity: normal
Tags: patch

Dear Maintainer,

The /etc/kernel/postinst.d/z50-raspi-firmware script which copies the kernel
and initrd to /boot/firmware, fails to ignore any old initrds which were renamed
by DKMS (usually of the form initrd.img-version-arch.old-dkms). These usually 
compare
as "newer" than the correct initrd, so lead to incorrect config.txt contents and
possible boot failure.

I'd suggest modifying this script as below; summarized as:

  # move this line to earlier in the script
  arch=$(dpkg --print-architecture)

  latest_kernel=$(ls -1 /boot/vmlinuz-*$arch | sort -V -r | head -1)
  [...]
  latest_initrd=$(ls -1 /boot/initrd.img-*$arch | sort -V -r | head -1)

- ie: looking specifically for kernels and initrds which end in the current
architecture name.

Not sure if this needs to go upstream. I suspect that the kernel and initrd
detection in this script could use a real reworking, see also bug #966503.

Thanks,

Colm


-- System Information:
Debian Release: 10.8
  APT prefers stable-updates
  APT policy: (900, 'stable-updates'), (900, 'stable')
Architecture: arm64 (aarch64)

Kernel: Linux 5.9.0-0.bpo.5-arm64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_CRAP, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_IE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages raspi-firmware depends on:
ii  dosfstools  4.1-2
ii  dpkg1.19.7

raspi-firmware recommends no packages.

raspi-firmware suggests no packages.

-- Configuration Files:
/etc/kernel/postinst.d/z50-raspi-firmware changed:
set -e
exec &2
eval set -- "$DEB_MAINT_PARAMS"
case "$1" in
  configure|remove)
;;
  *)
exit 0
;;
esac
if ischroot ; then
  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 ! mountpoint -q /boot/firmware; then
  echo "raspi-firmware: missing /boot/firmware, did you forget to mount it?" >&2
  exit 1
fi
mkdir -p /boot/firmware
arch=$(dpkg --print-architecture)
latest_kernel=$(ls -1 /boot/vmlinuz-*$arch | sort -V -r | head -1)
if [ -z "$latest_kernel" ]; then
  echo "raspi-firmware: no kernel found in /boot/vmlinuz-*$arch, cannot 
populate /boot/firmware"
  exit 0
fi
latest_initrd=$(ls -1 /boot/initrd.img-*$arch | sort -V -r | head -1)
if [ -z "$latest_initrd" ]; then
  echo "raspi-firmware: no initrd found in /boot/initrd.img-*$arch, cannot 
populate /boot/firmware"
  exit 0
fi
CMA=64M
ROOTPART=$(findmnt -n --output=source /) || true
if [ -z "$ROOTPART" ]; then ROOTPART=/dev/mmcblk0p2;fi
KERNEL="auto"
INITRAMFS="auto"
CONSOLES="auto"
if [ -r /etc/default/raspi-firmware ]; then
. /etc/default/raspi-firmware
fi
if [ "arm64" = "$arch" ]; then
  dtb_path="/usr/lib/linux-image-${latest_kernel#/boot/vmlinuz-}/broadcom"
else
  # there is no vendor subdirectory for armhf
  dtb_path="/usr/lib/linux-image-${latest_kernel#/boot/vmlinuz-}"
fi
if [ "$KERNEL" = "auto" ]; then
  for dtb in ${dtb_path}/bcm*.dtb; do
[ -e "${dtb}" ] && 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/
  if [ "$CONSOLES" = "auto" ]; then
  serial="ttyS1,115200"
  fi
fi
: >/boot/firmware/config.txt
if [ "$arch" = "arm64" ]; then
  cat >/boot/firmware/config.txt <>/boot/firmware/config.txt <>/boot/firmware/config.txt <>/boot/firmware/config.txt