[Pkg-raspi-maintainers] Bug#983409: raspi-firmware: /etc/kernel/postinst.d/z50-raspi-firmware fails to ignore old-dkms initrds
Colm Buckley
colm at tuatha.org
Tue Feb 23 18:56:59 GMT 2021
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 dpkg 1.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 </dev/null >&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 <<EOF
arm_64bit=1
EOF
fi
cat >>/boot/firmware/config.txt <<EOF
enable_uart=1
upstream_kernel=1
kernel=${KERNEL}
EOF
if [ "$INITRAMFS" != "no" ]; then
cat >>/boot/firmware/config.txt <<EOF
initramfs ${latest_initrd_basename}
EOF
fi
firmware_custom="/etc/default/raspi-firmware-custom"
if [ -f "$firmware_custom" ]; then
cat >>/boot/firmware/config.txt <<EOF
`cat ${firmware_custom}`
EOF
fi
pre_cmdline="console=tty0 console=${serial}"
if [ "$CONSOLES" != "auto" ]; then
pre_cmdline=""
for console in $CONSOLES; do
pre_cmdline="${pre_cmdline} console=${console}"
done
fi
if [ "$CMA" = "64M" ] && grep -q 'Raspberry Pi 4' /proc/device-tree/model ; then
SET_CMA=''
else
SET_CMA="cma=$CMA"
fi
cat >/boot/firmware/cmdline.txt <<EOF
${pre_cmdline} root=$ROOTPART rw elevator=deadline fsck.repair=yes net.ifnames=0 $SET_CMA rootwait
EOF
cd /boot/firmware
for file in vmlinuz-* initrd.img-*; do
if [ ! -e "/boot/$file" ]; then
echo "raspi-firmware: deleting obsolete /boot/firmware/$file (no longer in /boot)"
# Keep going if cleanup of individual files fails. It is better for the end
# user to have a working package upgrade and a slight waste of space than a
# broken upgrade.
rm -f "$file" || true
fi
done
-- no debconf information
More information about the Pkg-raspi-maintainers
mailing list