rpmbuild how to know we are building kernel module package


When I build a mpt3sas rpm package, I found something interesting:
1. package name is prefixed with kmod- automatically
2. so many requirements are added automatically, most of them are kabi

So my question is rpmbuild how to know he is building kernel module package?
Based on which condition?

Here is mpt3sas.spec:

Name: mpt3sas
Release: 1
Summary: RHEL Driver Update Program package

Group: System/Kernel
License: GPLv2
URL: <a href="" title=""></a>
Distribution: LSI Corporation
Source0: %{name}-%{version}.tar.bz2
Source1: %{name}.files
Source2: %{name}.conf
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: %kernel_module_package_buildreqs

%global kernel_version `uname -r`
%kernel_module_package -f %{SOURCE1} default

LSI MPT Fusion HBA drivers (12gb SAS)

set -- *
mkdir source
mv "$@" source/
mkdir obj

for flavor in %flavors_to_build; do
rm -rf obj/$flavor
cp -r source obj/$flavor
make -C %{kernel_source $flavor} M=$PWD/obj/$flavor

export INSTALL_MOD_DIR=extra/%{name}
for flavor in %flavors_to_build ; do
make -C %{kernel_source $flavor} modules_install \
# Cleanup unnecessary kernel-generated module dependency files.
find $INSTALL_MOD_PATH/lib/modules -iname 'modules.*' -exec rm {} \;

sed -e s/this_weakupdate/`uname -r | cut -f1 -d-`/ \
../../SOURCES/mpt3sas.conf > \
mv ../../SOURCES/mpt3sas.a ../../SOURCES/mpt3sas.conf

install -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT/etc/depmod.d/%{name}.conf
install -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT/etc/modules-load.d/%{name}.conf




Re: rpmbuild how to know we are building kernel module

By Gordon Messmer at 04/12/2019 - 11:12

On 4/12/19 7:04 AM, wuzhouhui wrote:

I believe the %kernel_module_package macro defined in
/usr/lib/rpm/redhat/macros is used to invoke
/usr/lib/rpm/redhat/kmodtool, which provides some overrides.

Re: rpmbuild how to know we are building kernel module

By wuzhouhui at 04/12/2019 - 21:55

I checked these macros and files, and I think you are right, although I haven't verify it.