redhat: pass correct RPM_VMLINUX_H to bpftool install

This is required to fix occasional racy build failures where the lack
of a correctly specified path to vmlinux.h in the %install phase can
cause the bpf Makefile to try and re-generate it against the
build-host kernel; the mistmatched built tools and host kernel can
then crash, aborting the build.  To add to the fun of this, it's
somewhat randomly tied to when bpf /sys/ files have updated
timestamps to trigger the make dependency.

By saving the file and referencing in the %install phase, we bypass
all this.

JIRA: INTERNAL
Upstream-status: https://gitlab.com/cki-project/kernel-ark
Related-issue: https://gitlab.com/cki-project/kernel-arkproject/infrastructure/-/issues/340
Related-MR: https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3105
Link: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=e7b64f9d3f5b10186038201e0b91f734cbd7fc3d

commit c3474aa82346fca416927a99671040b792e768ae
Author: Jan Stancek <jstancek@redhat.com>
Date:   Mon May 13 07:16:00 2024 -0400

    redhat: pass correct RPM_VMLINUX_H to bpftool install

    RPM doesn't carry over variables between %build and %install,
    so we end up using bpftool_make with empty RPM_VMLINUX_H.

    Signed-off-by: Jan Stancek <jstancek@redhat.com>

Signed-off-by: Ian Wienand <iwienand@redhat.com>
This commit is contained in:
Ian Wienand 2024-05-23 16:57:19 +10:00
parent 4237a9bf1f
commit 319106d32e
No known key found for this signature in database
1 changed files with 4 additions and 0 deletions

View File

@ -2720,6 +2720,7 @@ popd
if [ -f $DevelDir/vmlinux.h ]; then
RPM_VMLINUX_H=$DevelDir/vmlinux.h
fi
echo "${RPM_VMLINUX_H}" > ../vmlinux_h_path
%if %{with_bpftool}
%global bpftool_make \
@ -2876,6 +2877,9 @@ find Documentation -type d | xargs chmod u+w
cd linux-%{KVERREL}
# re-define RPM_VMLINUX_H, because it doesn't carry over from %build
RPM_VMLINUX_H="$(cat ../vmlinux_h_path)"
%if %{with_doc}
docdir=$RPM_BUILD_ROOT%{_datadir}/doc/kernel-doc-%{specversion}-%{pkgrelease}