mirror of https://github.com/dynup/kpatch
kpatch-build: Allow setting kernel version if --sourcedir and --vmlinux are used
Using -a/--archversion to explicitly set target kernel version was not allowed if the kernel source directory and/or path to vmlinux with debug info were set. This seems too strict, however. vmlinux with debug info is used during the build to get symbol data, the size of special structures, GCC version used to build the kernel, and the target kernel version. As it turned out, some kernels, e.g. the ones from OpenSUSE and derivatives, contain all that data except the Linux version string in the file with debug info for vmlinux. Instead, that string is present in vmlinux itself but that file does not contain debug info. A simple workaround is to allow specifying the target kernel version explicitly using -a/--archversion even if --sourcedir and/or --vmlinux are set. If vmlinux with debug info does contain the Linux version string and the version is different, kpatch-build will report an error. Signed-off-by: Evgenii Shatokhin <evgenii.shatokhin@openvz.org>
This commit is contained in:
parent
75f220233b
commit
fea0192104
|
@ -638,10 +638,6 @@ if [[ $DEBUG -eq 1 ]] || [[ $DEBUG -ge 3 ]]; then
|
|||
set -o xtrace
|
||||
fi
|
||||
|
||||
if [[ -n "$ARCHVERSION" ]] && [[ -n "$VMLINUX" ]]; then
|
||||
die "--archversion is incompatible with --vmlinux"
|
||||
fi
|
||||
|
||||
if [[ -n "$SRCRPM" ]]; then
|
||||
if [[ -n "$ARCHVERSION" ]]; then
|
||||
warn "--archversion is incompatible with --sourcerpm"
|
||||
|
@ -664,17 +660,23 @@ rm -rf "${TEMPDIR:?}"/*
|
|||
rm -f "$LOGFILE"
|
||||
|
||||
if [[ -n "$USERSRCDIR" ]]; then
|
||||
if [[ -n "$ARCHVERSION" ]]; then
|
||||
warn "--archversion is incompatible with --sourcedir"
|
||||
exit 1
|
||||
fi
|
||||
KERNEL_SRCDIR="$USERSRCDIR"
|
||||
|
||||
[[ -z "$VMLINUX" ]] && VMLINUX="$KERNEL_SRCDIR"/vmlinux
|
||||
[[ ! -e "$VMLINUX" ]] && die "can't find vmlinux"
|
||||
|
||||
# Extract the target kernel version from vmlinux in this case.
|
||||
ARCHVERSION="$(strings "$VMLINUX" | grep -m 1 -e "^Linux version" | awk '{ print($3); }')"
|
||||
VMLINUX_VER="$(strings "$VMLINUX" | grep -m 1 -e "^Linux version" | awk '{ print($3); }')"
|
||||
if [[ -n "$ARCHVERSION" ]]; then
|
||||
if [[ -n "$VMLINUX_VER" ]] && [[ "$ARCHVERSION" != "$VMLINUX_VER" ]]; then
|
||||
die "Kernel version mismatch: $ARCHVERSION was specified but vmlinux was built for $VMLINUX_VER"
|
||||
fi
|
||||
else
|
||||
if [[ -z "$VMLINUX_VER" ]]; then
|
||||
die "Unable to determine the kernel version from vmlinux"
|
||||
fi
|
||||
ARCHVERSION="$VMLINUX_VER"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "$OOT_MODULE" ]]; then
|
||||
|
|
Loading…
Reference in New Issue