From a57389693ceae6daabd2a78ce488795a8d0125dd Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Mon, 10 Apr 2023 20:36:18 +0100 Subject: [PATCH] Remove garbage before "Linux version" Kernel 6.1 onwards seems to have strings re-arranged so that a newline no long happens right before the "Linux version" string. Tested with: 4650945eaabe1297985759ef8e3d4153 archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-kernel_1.20230306-1_armhf.deb 93830b458685feabf2262f474be4a0e0 archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-kernel_1.20230317-1_armhf.deb 5449f3dd337c594491f3e73b6ee97cbf archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-kernel_1.20230405-1_armhf.deb 29384 5.15.84+ 28712 6.1.19+ 6.1.21+ --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 8c84be9..73df624 100755 --- a/install.sh +++ b/install.sh @@ -68,7 +68,7 @@ function get_kernel_version() { ZIMAGE=/boot/kernel.img [ -f /boot/firmware/vmlinuz ] && ZIMAGE=/boot/firmware/vmlinuz IMG_OFFSET=$(LC_ALL=C grep -abo $'\x1f\x8b\x08\x00' $ZIMAGE | head -n 1 | cut -d ':' -f 1) - _VER_RUN=$(dd if=$ZIMAGE obs=64K ibs=4 skip=$(( IMG_OFFSET / 4)) 2>/dev/null | zcat | grep -a -m1 "Linux version" | strings | awk '{ print $3; }') + _VER_RUN=$(dd if=$ZIMAGE obs=64K ibs=4 skip=$(( IMG_OFFSET / 4)) 2>/dev/null | zcat | grep -a -m1 "Linux version" | LC_ALL=C sed -e 's/^.*Linux/Linux/' | strings | awk '{ print $3; }') } echo "$_VER_RUN" return 0