DevHeads.net

rpmbuild how to know we are building kernel module package

Hi,

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
Version: 26.00.00.00
Release: 1
Summary: RHEL Driver Update Program package

Group: System/Kernel
License: GPLv2
URL: <a href="http://www.lsilogic.com" title="http://www.lsilogic.com">http://www.lsilogic.com</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

%description
LSI MPT Fusion HBA drivers (12gb SAS)

%prep
%setup
set -- *
mkdir source
mv "$@" source/
mkdir obj

%build
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
done

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

sed -e s/this_weakupdate/`uname -r | cut -f1 -d-`/ \
../../SOURCES/mpt3sas.conf > \
../../SOURCES/mpt3sas.a
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

%clean
rm -rf $RPM_BUILD_ROOT

%changelog

Comments

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.