feat: enhance kernel image version detection for some old kernels

This commit is contained in:
Stéphane Lesimple 2018-03-10 14:56:10 +01:00
parent 2f6a6554a2
commit d2f46740e9
1 changed files with 6 additions and 0 deletions

View File

@ -1004,6 +1004,10 @@ if [ -z "$vmlinux" ] || [ ! -r "$vmlinux" ]; then
[ -z "$vmlinux_err" ] && vmlinux_err="couldn't extract your kernel from $opt_kernel"
else
vmlinux_version=$(strings "$vmlinux" 2>/dev/null | grep '^Linux version ' | head -1)
if [ -z "$vmlinux_version" ]; then
# try harder with some kernels (such as Red Hat) that don't have ^Linux version before their version string
vmlinux_version=$(strings "$vmlinux" 2>/dev/null | grep -E '^[[:alnum:]][^[:space:]]+ \([^[:space:]]+\) #[0-9]+ .+ (19|20)[0-9][0-9]$' | head -1)
fi
if [ -n "$vmlinux_version" ]; then
# in live mode, check if the img we found is the correct one
if [ "$opt_live" = 1 ]; then
@ -1015,6 +1019,8 @@ else
else
_info "Kernel image is \033[35m$vmlinux_version"
fi
else
_verbose "Kernel image version is unknown"
fi
fi