From ce479043d97ae86e4ad72ee5fb7ffc3008c5667f Mon Sep 17 00:00:00 2001 From: David Matlack Date: Tue, 11 Aug 2026 21:47:27 +0000 Subject: [PATCH] kselftests: Dynamically pack symlink targets during installation The kernel selftests can contain symbolic links extending outside of the 'tools/' or 'arch/x86/' trees. For example, the VFIO selftests library contains symlinks pointing to headers in 'drivers/dma/', and the powerpc selftests include symlinks pointing to various assembly files in 'arch/powerpc/'. Since install_kernel_selftests() explicitly restricted packaging to only a few rigid directories like 'tools' and 'arch/x86', the symlinks for VFIO and powerpc would be shipped broken, breaking downstream compilation on test nodes. Fix this by introducing a dynamic find-and-pack loop that checks all symlinks under 'tools/'. If any symlink correctly resolves back into a file within the Linux tree that was not part of the standard packages (e.g., inside 'drivers/' or 'arch/powerpc/'), those specific target files are automatically copied in. Closes: https://lore.kernel.org/kvm/202608071656.86e9fd06-lkp@intel.com/ Signed-off-by: David Matlack --- lib/tests/pkgbuild.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/tests/pkgbuild.sh b/lib/tests/pkgbuild.sh index b3959cb76..cc5d701e4 100755 --- a/lib/tests/pkgbuild.sh +++ b/lib/tests/pkgbuild.sh @@ -484,4 +484,16 @@ install_kernel_selftests() for dir in arch/x86 scripts kernel/bpf samples Makefile tools include lib; do pack_contents $dir "$(dirname "${benchmark_path}/$dir")" done + + # Pack any missing symlink targets referenced from tools/ + local link target rel_target + while IFS= read -r -d '' link; do + target=$(realpath "$link" 2>/dev/null || true) + if [[ -n "$target" && -e "$target" && "$target" == "$PWD/"* ]]; then + rel_target="${target#$PWD/}" + if [[ ! -e "${benchmark_path}/$rel_target" ]]; then + pack_contents "$rel_target" "$(dirname "${benchmark_path}/$rel_target")" + fi + fi + done < <(find tools -type l -print0) }