Skip to content

Commit fd6a122

Browse files
committed
kpatch-build: building OOT livepatch modules for kernels built from source
Ability to build out-of-tree modules for non-host kernel is currently missing. This commit introduces that ability for any kernel built from source, including cross-compiled ones. The workaround checks for existence of /lib/modules/$ARCHVERSION/build, and if nonexistent, assumes the kernel source directory to be a build directory.
1 parent 61fc3f1 commit fd6a122

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

kpatch-build/kpatch-build

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,9 +1050,12 @@ ERROR=0
10501050

10511051
# Prepare OOT module symvers file
10521052
if [[ -n "$OOT_MODULE" ]]; then
1053-
BUILDDIR="/lib/modules/$ARCHVERSION/build/"
1054-
cp -f "$SRCDIR/Module.symvers" "$TEMPDIR/Module.symvers" || die
1055-
awk '{ print $1 "\t" $2 "\t" $3 "\t" $4}' "${BUILDDIR}/Module.symvers" >> "$TEMPDIR/Module.symvers"
1053+
cp -f "$SRCDIR/Module.symvers" "$TEMPDIR/Module.symvers" || die
1054+
# merge host symbols only if we do compile for host kernel
1055+
if [[ -e "/lib/modules/$ARCHVERSION/build/" ]]; then
1056+
BUILDDIR="/lib/modules/$ARCHVERSION/build/"
1057+
awk '{ print $1 "\t" $2 "\t" $3 "\t" $4}' "${BUILDDIR}/Module.symvers" >> "$TEMPDIR/Module.symvers"
1058+
fi
10561059
fi
10571060

10581061
for i in $FILES; do
@@ -1164,7 +1167,12 @@ cd "$TEMPDIR/patch" || die
11641167
if [[ -z "$OOT_MODULE" ]]; then
11651168
KPATCH_BUILD="$SRCDIR"
11661169
else
1167-
KPATCH_BUILD="/lib/modules/$ARCHVERSION/build"
1170+
if [[ ! -e "/lib/modules/$ARCHVERSION/build" ]]; then
1171+
#assume we build for kernel built from source
1172+
KPATCH_BUILD="$(dirname "$CONFIGFILE")"
1173+
else
1174+
KPATCH_BUILD="/lib/modules/$ARCHVERSION/build"
1175+
fi
11681176
fi
11691177

11701178
# We no longer need kpatch-cc

0 commit comments

Comments
 (0)