mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-31 04:45:39 +01:00
Add akmod (Automatic Kernel Module) support to ZFS, providing a third packaging option alongside the existing DKMS and kmod packages. Akmod packages automatically build binary kmod RPMs when new kernels are installed, enabling: - Automatic kernel module rebuilds on kernel updates - Distribution of binary kmod RPMs without recompilation - Seamless minor version upgrades on RHEL/Fedora and clones Key changes: - rpm/generic/zfs-kmod.spec.in: Add conditional akmod support via rpmbuild --define '_enable_akmod 1'. When enabled, sets buildforkernels=akmod and repo=rpmfusion so kmodtool generates an akmod-zfs package. Add -common subpackage for shared license/doc files. Guard chmod and %files sections for empty kernel_versions. Make kmod-devel packages opt-in via %bcond_with devel to prevent akmods from installing unnecessary devel packages on every kernel update. When devel is not enabled, devel header files are cleaned from the buildroot to avoid unpackaged-files errors. - config/rpm.am: Add 'make rpm-akmod' and 'make srpm-akmod' targets. These targets use the generic spec with _enable_akmod and intentionally omit kernel-specific defines (kernels, ksrc, kobj) so kmodtool enters its akmod-only code path. The existing rpm-kmod/srpm-kmod targets pass --with devel to preserve the current behavior of producing devel packages. - config/zfs-build.m4: Update comments to document the akmod vs regular kmod distinction for RPM_DEFINE_KMOD. - scripts/kmodtool: Fix a pre-existing bug where print_rpmtemplate_kmoddevelpkg (the common kmod-NAME-devel package) was called inside the per-kernel loop in print_customrpmtemplate and print_rpmtemplate, causing duplicate %package definitions when multiple kernel-devel packages are installed. Move it outside the loop so it is emitted once. The akmod infrastructure requires the 'akmods' package on the target system. When the akmod-zfs RPM is installed, it places a zfs-kmod src.rpm in /usr/src/akmods/. The akmods service then automatically rebuilds it for the running kernel via rpmbuild --define 'kernels <uname-r>' --rebuild. Usage: make rpm-akmod # Build akmod-zfs, kmod-zfs, zfs-kmod-common make rpm-kmod # Build kmod with devel packages (unchanged) Tested on Fedora 43 (kernel 7.1), RHEL 9.8 (kernel 5.14), and Alma Linux 10 (kernel 6.12). Verified akmods rebuilds produce only kmod-zfs (no devel packages) after kernel updates. Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Vincent S. Cojot <[email protected]> Closes #19099