Skip to content

Commit df6065c

Browse files
iavclaude
andcommitted
kernel-headers: fix modpost build in postinst, add arch tools
- Use 'make prepare' with 120s timeout to build modpost and all required files for external module compilation. Timeout is needed because 'make prepare' has a recursive call that creates infinite loop in headers-only tree, but modpost is built early before the recursion starts. - Add verification that modpost was built successfully - Include arch/${SRC_ARCH}/tools/ in headers package (contains .awk scripts like gen-cpucaps.awk needed by 'make prepare' on arm64) - Filter out excessive "overriding recipe" warnings from output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 498ff45 commit df6065c

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

lib/functions/compilation/kernel-debs.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ function kernel_package_callback_linux_headers() {
409409
[[ -d "arch/${SRC_ARCH}" ]] && {
410410
find "arch/${SRC_ARCH}" -name module.lds -o -name Kbuild.platforms -o -name Platform
411411
# shellcheck disable=SC2046 # I need to expand. Thanks.
412-
find $(find "arch/${SRC_ARCH}" -name include -o -name scripts -type d) -type f
412+
# include 'tools' for arch-specific scripts like gen-cpucaps.awk needed by 'make prepare'
413+
find $(find "arch/${SRC_ARCH}" -name include -o -name scripts -o -name tools -type d) -type f
413414
find arch/${SRC_ARCH}/include -type f
414415
}
415416
find Module.symvers include scripts -type f
@@ -534,16 +535,20 @@ function kernel_package_callback_linux_headers() {
534535
echo "Configuring kernel-headers (${kernel_version_family}) - please wait ..."
535536
make ARCH="${SRC_ARCH}" olddefconfig
536537
537-
echo "Compiling kernel-headers scripts (${kernel_version_family}) using \$NCPU CPUs - please wait ..."
538-
make ARCH="${SRC_ARCH}" -j\$NCPU scripts
539-
540-
echo "Compiling kernel-headers scripts/mod (${kernel_version_family}) using \$NCPU CPUs - please wait ..."
541-
make ARCH="${SRC_ARCH}" -j\$NCPU M=scripts/mod/
538+
echo "Preparing kernel-headers for module builds (${kernel_version_family}) using \$NCPU CPUs - please wait ..."
539+
# 'make prepare' builds scripts and scripts/mod (modpost). Use timeout because
540+
# prepare has a recursive call that creates infinite loop in headers-only tree.
541+
# modpost is built early, before the recursion starts.
542+
timeout 120 make ARCH="${SRC_ARCH}" -j\$NCPU prepare 2>&1 | grep -v "^scripts/Makefile.build:.*warning: overriding recipe" || true
543+
# Verify modpost was built successfully
544+
if [ ! -x scripts/mod/modpost ]; then
545+
echo "ERROR: modpost was not built!" >&2
546+
exit 1
547+
fi
542548
543549
echo "Compiling resolve_btfids tools for assigning stable BTF type IDs to kernel symbols"
544550
make ARCH="${SRC_ARCH}" -j\$NCPU tools/bpf/resolve_btfids
545551
546-
# make ARCH="${SRC_ARCH}" -j\$NCPU modules_prepare # depends on too much other stuff.
547552
echo "Done compiling kernel-headers (${kernel_version_family})."
548553
EOT_POSTINST
549554

0 commit comments

Comments
 (0)