Bug 2002887

Summary: kmod package build macros are broken (cannot build OpenZFS)
Product: Red Hat Enterprise Linux 9 Reporter: Neal Gompa <ngompa13>
Component: kernel-srpm-macrosAssignee: Eugene Syromiatnikov <esyr>
Status: CLOSED ERRATA QA Contact: Ziqian SUN (Zamir) <zsun>
Severity: urgent Docs Contact:
Priority: urgent    
Version: CentOS StreamCC: bstinson, carl, daxelrod, dhoward, hkrzesin, jwboyer, matt, onatalen, skozina, tgummels
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: kernel-srpm-macros-1.0-10.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 13:05:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1975927    
Bug Blocks:    

Description Neal Gompa 2021-09-09 22:34:09 UTC
Description of problem:
I'm trying to build OpenZFS against CentOS Stream 9, and for some reason, the package build fails trying to detect the kernel to build against.

This package builds perfectly fine on CentOS Stream 8 using the centos-stream-8-x86_64 Mock configuration, but fails on CentOS Stream 9.

I expect this to still work, given that this is the standard macros for packaging kernel modules as RPMs.

Version-Release number of selected component (if applicable):
1.0-8.el9

How reproducible:
Always

Steps to Reproduce:
1. git clone https://pagure.io/openzfs-linux-packaging.git
2. cd openzfs-linux-packaging && git checkout 45b956a27a4cb9858c61348856fcda84c5325f0a
3. spectool -g zfs.spec
4. mock -r centos-stream-9 --sources . --spec zfs.spec

Actual results:
The build fails at the configure stage with the following error:

checking kernel source directory... /usr/src/kernels/2.1.0-1.el9.x86_64
configure: error:
        *** Please make sure the kernel devel package for your distribution
        *** is installed and then try again.  If that fails, you can specify the
        *** location of the kernel source with the '--with-linux=PATH' option.
RPM build errors:
error: Bad exit status from /var/tmp/rpm-tmp.QNtS6j (%build)
    /builddir/build/originals/zfs.spec: line 240: Macro %kmp_release defined but not used within scope
    /builddir/build/originals/zfs.spec: line 240: Macro %kmp_version defined but not used within scope
    Bad exit status from /var/tmp/rpm-tmp.QNtS6j (%build)
Child return code was: 1


Expected results:
The build should pass and produce all the necessary packages.

Comment 1 Neal Gompa 2021-09-30 19:59:54 UTC
I've determined that the problem is that somehow the %kernel_version macro is being defined incorrectly: https://gitlab.com/redhat/centos-stream/rpms/kernel-srpm-macros/-/blob/2625834549b16a87399be350c03d3874cd1c5135/macros.kmp#L19

When I use a local redefinition of %kernel_version, the options are correctly passed and it attempts to build. The local definition I put in my spec:

> %define kernel_version %(rpm -q --qf '%%{VERSION}-%%{RELEASE}' `rpm -q kernel-devel | /usr/lib/rpm/redhat/rpmsort -r | head -n 1` | head -n 1)

The build still fails, but it gets past the original issue.

Comment 2 Neal Gompa 2021-09-30 20:17:38 UTC
I think I've got a fix for this proposed: https://gitlab.com/redhat/centos-stream/rpms/kernel-srpm-macros/-/merge_requests/4

Comment 3 Neal Gompa 2021-09-30 22:02:51 UTC
Nope, it was more severe than I thought, and it looks like there were fixes done in RHEL 8 that were never synced into Fedora, so I'm updating the MR accordingly.

Comment 4 Neal Gompa 2021-09-30 22:30:42 UTC
I've also synced the changes to Fedora: https://src.fedoraproject.org/rpms/kernel-srpm-macros/pull-request/4

Comment 5 Neal Gompa 2021-09-30 22:41:51 UTC
(In reply to Neal Gompa from comment #2)
> I think I've got a fix for this proposed:
> https://gitlab.com/redhat/centos-stream/rpms/kernel-srpm-macros/-/merge_requests/4

I can confirm this works with commit b6bcc92b7f6b2a4596a59a59481d0ee8dadd6caa from my OpenZFS packaging repo. I needed to upgrade to ZFS 2.1.1 to make it work with Linux 5.14 after including the updated kernel-srpm-macros and kernel-rpm-macros packages in my local buildroot.

Comment 7 Neal Gompa 2021-11-02 21:49:29 UTC
Is there any progress on this yet? I haven't seen anything happen with my merge request since I proposed it...

Comment 16 errata-xmlrpc 2022-05-17 13:05:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: kernel-srpm-macros), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2022:2452