Skip to content

Commit 5446018

Browse files
oshovalcursoragent
andcommitted
kpatch-build: fix Fedora 42+ kernel source directory nesting
Starting with Fedora 42, the kernel SRPM unpacks with an extra level of nesting: BUILD/kernel-6.14.0-build/kernel-6.14/linux-6.14.0-63.fc42.x86_64/ The existing glob BUILD/kernel-*/linux-* only matches one level deep and fails with "cannot stat" on this layout. Try the traditional flat glob first for backward compatibility. If it fails, fall back to a recursive find (up to 4 levels) to locate the linux-* source directory regardless of nesting depth. Tested on Fedora 42 with kernel 6.14.0-63.fc42.x86_64. Signed-off-by: Or Shoval <oshoval@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 7552b46 commit 5446018

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

kpatch-build/kpatch-build

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,15 @@ else
10821082
elif [[ "$DISTRO" = photon ]]; then
10831083
mv "$RPMTOPDIR"/BUILD/linux-"$KVER" "$KERNEL_SRCDIR" 2>&1 | logger || die
10841084
else
1085-
mv "$RPMTOPDIR"/BUILD/kernel-*/linux-* "$KERNEL_SRCDIR" 2>&1 | logger || die
1085+
# Fedora 42+ nests the source deeper:
1086+
# BUILD/kernel-X.Y.Z-build/kernel-X.Y/linux-X.Y.Z-NN.fcNN.ARCH/
1087+
# Try the traditional flat glob first, fall back to a recursive find.
1088+
if ! mv "$RPMTOPDIR"/BUILD/kernel-*/linux-* "$KERNEL_SRCDIR" 2>/dev/null; then
1089+
LINUX_SRC=$(find "$RPMTOPDIR/BUILD" -maxdepth 4 -type d -name "linux-*" \
1090+
! -path "*/configs/*" | head -1)
1091+
[[ -n "$LINUX_SRC" ]] || die "Could not find linux source directory under $RPMTOPDIR/BUILD"
1092+
mv "$LINUX_SRC" "$KERNEL_SRCDIR" 2>&1 | logger || die
1093+
fi
10861094
fi
10871095

10881096
rm -rf "$RPMTOPDIR"

0 commit comments

Comments
 (0)