Skip to content

Commit b60d3ac

Browse files
committed
Merge pull request dynup#560 from euspectre/get-kernel-version
Get kernel version from vmlinux if the kernel source tree is used
2 parents b781c0a + e169d82 commit b60d3ac

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

kpatch-build/kpatch-build

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,6 @@ rm -f "$LOGFILE"
283283

284284
trap cleanup EXIT INT TERM HUP
285285

286-
KVER=${ARCHVERSION%%-*}
287-
if [[ $ARCHVERSION =~ - ]]; then
288-
KREL=${ARCHVERSION##*-}
289-
KREL=${KREL%.*}
290-
fi
291-
292286
if [[ -n $USERSRCDIR ]]; then
293287
# save .config and vmlinux since they'll get removed with mrproper so
294288
# we can restore them later and be able to run kpatch-build multiple
@@ -300,6 +294,15 @@ if [[ -n $USERSRCDIR ]]; then
300294
[[ -z $VMLINUX ]] && VMLINUX="$USERSRCDIR"/vmlinux
301295
[[ ! -e "$VMLINUX" ]] && die "can't find vmlinux"
302296
[[ "$VMLINUX" = "$USERSRCDIR"/vmlinux ]] && cp -f "$VMLINUX" $TEMPDIR/vmlinux && VMLINUX=$TEMPDIR/vmlinux
297+
298+
# Extract the target kernel version from vmlinux in this case.
299+
ARCHVERSION=$(strings "$VMLINUX" | grep -e "^Linux version" | awk '{ print($3); }')
300+
fi
301+
302+
KVER=${ARCHVERSION%%-*}
303+
if [[ $ARCHVERSION =~ - ]]; then
304+
KREL=${ARCHVERSION##*-}
305+
KREL=${KREL%.*}
303306
fi
304307

305308
[[ -z $TARGETS ]] && TARGETS="vmlinux modules"

0 commit comments

Comments
 (0)