Skip to content

Commit

Permalink
Merge pull request #560 from euspectre/get-kernel-version
Browse files Browse the repository at this point in the history
Get kernel version from vmlinux if the kernel source tree is used
  • Loading branch information
sjenning committed Nov 18, 2015
2 parents b781c0a + e169d82 commit b60d3ac
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions kpatch-build/kpatch-build
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,6 @@ rm -f "$LOGFILE"

trap cleanup EXIT INT TERM HUP

KVER=${ARCHVERSION%%-*}
if [[ $ARCHVERSION =~ - ]]; then
KREL=${ARCHVERSION##*-}
KREL=${KREL%.*}
fi

if [[ -n $USERSRCDIR ]]; then
# save .config and vmlinux since they'll get removed with mrproper so
# we can restore them later and be able to run kpatch-build multiple
Expand All @@ -300,6 +294,15 @@ if [[ -n $USERSRCDIR ]]; then
[[ -z $VMLINUX ]] && VMLINUX="$USERSRCDIR"/vmlinux
[[ ! -e "$VMLINUX" ]] && die "can't find vmlinux"
[[ "$VMLINUX" = "$USERSRCDIR"/vmlinux ]] && cp -f "$VMLINUX" $TEMPDIR/vmlinux && VMLINUX=$TEMPDIR/vmlinux

# Extract the target kernel version from vmlinux in this case.
ARCHVERSION=$(strings "$VMLINUX" | grep -e "^Linux version" | awk '{ print($3); }')
fi

KVER=${ARCHVERSION%%-*}
if [[ $ARCHVERSION =~ - ]]; then
KREL=${ARCHVERSION##*-}
KREL=${KREL%.*}
fi

[[ -z $TARGETS ]] && TARGETS="vmlinux modules"
Expand Down

0 comments on commit b60d3ac

Please sign in to comment.