PKGBUILDs/core/mkinitcpio/0003-check-for-ALARM-kernels-in-run_post_hooks.patch

75 lines
2.9 KiB
Diff
Raw Normal View History

2024-05-04 03:02:06 +00:00
From 5742e332299eb12222f626a247c936b777de2ce9 Mon Sep 17 00:00:00 2001
2023-03-22 01:05:52 +00:00
From: Kevin Mihelich <kevin@archlinuxarm.org>
Date: Tue, 21 Mar 2023 17:56:32 -0600
Subject: [PATCH 3/3] check for ALARM kernels in run_post_hooks
---
2024-05-04 03:02:06 +00:00
functions | 27 +++++++++++++++++++++------
2023-03-22 01:05:52 +00:00
mkinitcpio | 11 +++++++++++
2024-05-04 03:02:06 +00:00
2 files changed, 32 insertions(+), 6 deletions(-)
2023-03-22 01:05:52 +00:00
diff --git a/functions b/functions
2024-05-04 03:02:06 +00:00
index 4e77418..bd9723a 100755
2023-03-22 01:05:52 +00:00
--- a/functions
+++ b/functions
2024-05-04 03:02:06 +00:00
@@ -440,13 +440,28 @@ kver_generic() {
local kver=''
2023-06-03 19:36:23 +00:00
2024-05-04 03:02:06 +00:00
- # Loosely grep for `linux_banner`:
- # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/init/version-timestamp.c?h=v6.7#n28
- read -r _ _ kver _ < <(decompress_cat "$1" | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]+]+)+')
2023-03-26 22:27:16 +00:00
+ if [[ $1 =~ "/zImage" || $1 =~ /kernel7.img ]]; then
2023-03-22 22:03:20 +00:00
+ # Check for xz zImage
+ skip=$(LC_ALL=C grep -a -b -o $'\xFD\x37\x7A\x58\x5A\x00' $1 | tail -n 1 | cut -d ':' -f 1)
+ if [[ ! -z $skip ]]; then
+ read -r _ _ kver _ < <(dd if=$1 iflag=skip_bytes skip=$skip | xzcat | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]+]+)+')
+ fi
+ if [[ -z "$kver" ]]; then
+ # Check for gzip zImage
+ skip=$(LC_ALL=C grep -a -b -o $'\x1f\x8b\x08\x00\x00\x00\x00\x00' $1 | head -n 1 | cut -d ':' -f 1)
+ if [[ ! -z $skip ]]; then
+ read -r _ _ kver _ < <(dd if=$1 iflag=skip_bytes skip=$skip | zcat | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]+]+)+')
+ fi
+ fi
2023-03-22 01:05:52 +00:00
+ else
2024-05-04 03:02:06 +00:00
+ # Loosely grep for `linux_banner`:
+ # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/init/version-timestamp.c?h=v6.7#n28
+ read -r _ _ kver _ < <(decompress_cat "$1" | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]+]+)+')
2023-03-22 01:05:52 +00:00
- # try if the image is gzip compressed
- if [[ -z "$kver" ]]; then
- read _ _ kver _ < <(gzip -c -d "$1" | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]]+)+')
+ # try if the image is gzip compressed
+ if [[ -z "$kver" ]]; then
+ read _ _ kver _ < <(gzip -c -d "$1" | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]]+)+')
+ fi
fi
printf '%s' "$kver"
diff --git a/mkinitcpio b/mkinitcpio
2024-05-04 03:02:06 +00:00
index 17eae23..0d0dd40 100755
2023-03-22 01:05:52 +00:00
--- a/mkinitcpio
+++ b/mkinitcpio
2024-05-04 03:02:06 +00:00
@@ -1085,6 +1085,17 @@ if [[ "$KERNELVERSION" != 'none' ]]; then
2023-03-22 01:05:52 +00:00
done
fi
+ if [[ -z "$KERNELIMAGE" ]]; then
+ # check version of ALARM kernels in /boot
2023-03-22 22:03:20 +00:00
+ for img in /boot/*Image* /boot/kernel*.img; do
+ if [[ -f $img && "$(kver "$img")" == "$KERNELVERSION" ]]; then
2023-03-22 01:05:52 +00:00
+ KERNELIMAGE="$img"
+ quiet "located kernel image: '%s'" "$KERNELIMAGE"
+ break
+ fi
+ done
+ fi
+
if [[ -z "$KERNELIMAGE" ]]; then
# check version of all kernels in /boot
for img in /boot/vmlinuz-*; do
--
2.36.1