Fix kmodtool for packaging mainline Linux

kmodtool currently incorrectly identifies official
RHEL kernels, as opposed to custom kernels. This
can cause the openZFS kmod RPM build to break.

The issue can be reproduced by building a set of
mainline Linux RPMs, installing them, and then
attempting to build the openZFS kmod package
against them.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Timothy Day <timday@amazon.com>
Closes #14617
This commit is contained in:
Timothy Day 2023-03-22 12:22:52 -04:00 committed by GitHub
parent 0f9e735414
commit 1eca40f3ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 16 deletions

View File

@ -333,7 +333,22 @@ print_customrpmtemplate ()
{
for kernel in ${1}
do
if [[ -e "${buildroot}/usr/src/kernels/${kernel}" ]] ; then
if [[ -e "${prefix}/lib/modules/${kernel}/build/Makefile" ]]; then
# likely a user-build-kernel with available buildfiles
# fixme: we should check if uname from Makefile is the same as ${kernel}
kernel_versions="${kernel_versions}${kernel}___${prefix}/lib/modules/${kernel}/build/ "
print_rpmtemplate_per_kmodpkg --custom "${kernel}"
# create development package
if [[ -n "${devel}" ]]; then
# create devel package including common headers
print_rpmtemplate_kmoddevelpkg --custom "${kernel}"
# create devel package
print_rpmtemplate_per_kmoddevelpkg --custom "${kernel}"
fi
elif [[ -e "${buildroot}/usr/src/kernels/${kernel}" ]]; then
# this looks like a Fedora/RH kernel -- print a normal template (which includes the proper BR) and be happy :)
kernel_versions="${kernel_versions}${kernel}___${buildroot}%{_usrsrc}/kernels/${kernel} "
@ -349,21 +364,6 @@ print_customrpmtemplate ()
# create devel package
print_rpmtemplate_per_kmoddevelpkg --redhat ${kernel} ${kernel##${kernel_verrelarch}}
fi
elif [[ -e "${prefix}/lib/modules/${kernel}/build/Makefile" ]]; then
# likely a user-build-kernel with available buildfiles
# fixme: we should check if uname from Makefile is the same as ${kernel}
kernel_versions="${kernel_versions}${kernel}___${prefix}/lib/modules/${kernel}/build/ "
print_rpmtemplate_per_kmodpkg --custom "${kernel}"
# create development package
if [[ -n "${devel}" ]]; then
# create devel package including common headers
print_rpmtemplate_kmoddevelpkg --custom "${kernel}"
# create devel package
print_rpmtemplate_per_kmoddevelpkg --custom "${kernel}"
fi
else
error_out 2 "Don't know how to handle ${kernel} -- ${prefix}/lib/modules/${kernel}/build/Makefile not found"
fi