From 280bb390a21b83e4a1290bcc6537369f3033ad82 Mon Sep 17 00:00:00 2001 From: Hin-Tak Leung Date: Sun, 16 Apr 2023 19:11:24 +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+ --- seeed-voicecard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seeed-voicecard b/seeed-voicecard index 55d6b39..dc2aa1c 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -42,7 +42,7 @@ function get_kernel_version() { [ -z "$_VER_RUN" ] && { ZIMAGE=/boot/kernel.img 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)) | 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