kpatch-build: Stop reading vmlinux after the first match

When searching for 'Linux version ...' in vmlinux, stop after the first
match so that we don't keep reading a potentially huge file.

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
This commit is contained in:
Juerg Haefliger 2017-11-09 14:02:55 +01:00
parent 7770c18f93
commit b5f77d0608
1 changed files with 1 additions and 1 deletions

View File

@ -481,7 +481,7 @@ if [[ -n "$USERSRCDIR" ]]; then
[[ ! -e "$VMLINUX" ]] && die "can't find vmlinux"
# Extract the target kernel version from vmlinux in this case.
ARCHVERSION="$(strings "$VMLINUX" | grep -e "^Linux version" | awk '{ print($3); }')"
ARCHVERSION="$(strings "$VMLINUX" | grep -m 1 -e "^Linux version" | awk '{ print($3); }')"
fi
[[ -z "$ARCHVERSION" ]] && ARCHVERSION="$(uname -r)"