Date: Sunday, February 12, 2023 @ 17:36:45 Author: tpowa Revision: 468649
upgpkg: hwdetect 2023.02.12-1: remove file depends, kver is now detected by od Modified: hwdetect/trunk/PKGBUILD hwdetect/trunk/hwdetect ----------+ PKGBUILD | 6 +++--- hwdetect | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2023-02-12 15:24:35 UTC (rev 468648) +++ PKGBUILD 2023-02-12 17:36:45 UTC (rev 468649) @@ -1,17 +1,17 @@ # Maintainer: Tobias Powalowski <[email protected]> pkgname=hwdetect -pkgver=2023.01.30 +pkgver=2023.02.12 pkgrel=1 pkgdesc="Hardware detection script with loading modules and mkinitcpio.conf" arch=(any) url="https://archlinux.org/packages/extra/any/hwdetect/" license=('GPL') -depends=('sh' 'awk' 'grep' 'coreutils' 'file' 'sed' 'e2fsprogs' 'gzip') +depends=('sh' 'awk' 'grep' 'coreutils' 'sed' 'e2fsprogs' 'gzip') optdepends=('cryptsetup: for encrypt mkinitcpio config support' 'lvm2: for lvm2 mkinitcpio config support' 'mdadm: for raid mkinitcpio config support') source=(hwdetect) -sha512sums=('546d48f85c4518cb9b8f0de8226a3c2eba991caeb33959559cb85d6de05317f597dbdb98174d711247a39fd0516635515af2d5c8dbf9de02c6a38f719cfe4bb3') +sha512sums=('915ba67023f1e2ded5d306c9fbca6d3048e17750efc5f7bb68ed3156155c4f025f50546897be6102bdd71d9f510d26b2ea75913099fded69ecb14c37aff7c9bd') package() { install -D -m 755 "${srcdir}/hwdetect" "${pkgdir}/usr/bin/hwdetect" Modified: hwdetect =================================================================== --- hwdetect 2023-02-12 15:24:35 UTC (rev 468648) +++ hwdetect 2023-02-12 17:36:45 UTC (rev 468649) @@ -100,8 +100,22 @@ # get kernel version from installed kernel [[ "$(uname -m)" == "x86_64" || "$(uname -m)" == "riscv64" ]] && VMLINUZ=/boot/vmlinuz-linux [[ "$(uname -m)" == "aarch64" ]] && VMLINUZ=/boot/Image + if [[ -f "${VMLINUZ}" ]]; then + offset="$(od -An -j0x20E -dN2 "${VMLINUZ}")" + read -r _HWKVER _ < <(dd if="${VMLINUZ}" bs=1 count=127 skip=$((offset + 0x200)) 2>/dev/null) + fi + + if [[ -f "${VMLINUZ}" ]]; then reader="cat" + # try if the image is gzip compressed + bytes="$(od -An -t x2 -N2 "${VMLINUZ}" | tr -dc '[:alnum:]')" + [[ $bytes == '8b1f' ]] && reader="zcat" + read -r _ _ _HWKVER _ < <($reader "${VMLINUZ}" | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]]+)+') + fi + + if [[ -f "${VMLINUZ}" ]]; then + reader="cat" [[ $(file -b --mime-type "${VMLINUZ}") == 'application/gzip' ]] && reader="zcat" read -r _ _ kver _ < <($reader "${VMLINUZ}" | grep -m1 -aoE 'Linux version .(\.[-[:alnum:]]+)+') fi
