Kernel module standards
Ignacio Vazquez-Abrams
ivazquez at ivazquez.net
Thu May 26 01:22:25 UTC 2005
I was asked by Warren to post the standards that I use for building
kernel modules, so here they are.
> %{!?kernelroot: %define kernelroot "" }
When building a kernel for multiple archs it's handy to have the
kernel/kernel-devel package for the archs all installed at the same
time. While UP/SMP/hugemem/Xen kernels can be installed on the same
root, two UP kernels for different archs cannot. The way I get around
this is to install the kernel in /$arch, then pass '--define
"kernelroot /$arch"' to rpmbuild. In this way I can build the module for
all archs in one go instead of having to deal with switching kernels in
and out, *PLUS* it still builds properly if someone just does 'rpmbuild
-bb kernel-module-foo.spec' provided they have the kernel-devel package
for the kernel they're running.
> %{!?kernelversion: %define kernelversion %(uname -r) }
Like above, except this is used for selecting between parallel-installed
kernel versions.
> %package %{kernelversion}
Yes, it's ugly, but it does allow multiple copies of a module to be
installed, one per kernel version.
> Provides: %{name} = %{version}
I'm sure this will come in handy one day...
The attached script is how I invoke rpmbuild to build it on FC3/i386.
It's easy enough to modify it for other archs/distros, I just haven't
needed to as of yet.
--
Ignacio Vazquez-Abrams <ivazquez at ivazquez.net>
http://fedora.ivazquez.net/
gpg --keyserver hkp://subkeys.pgp.net --recv-key 38028b72
-------------- next part --------------
%{!?kernelroot: %define kernelroot "" }
%{!?kernelversion: %define kernelversion %(uname -r) }
Name: kernel-module-qla4xxx
Version: 5.00.02
Release: 0.iva.1
Summary: Driver for QLogic QLA4xxx iSCSI cards
Group: System Environment/Base
License: GPL
URL: http://www.qlogic.com/
Source0: http://download.qlogic.com/drivers/27588/qla4xxx-5.00.02.tar.gz
Patch: qla4xxx-5.00.02-inline.patch
Patch1: qla4xxx-5.00.02-build.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
ExclusiveArch: i586 i686 x86_64
%description
This package contains the driver for QLogic's QLA4xxx series of iSCSI cards.
%package %{kernelversion}
Summary: Driver for QLogic QLA4xxx iSCSI cards
Group: System Environment/Base
Provides: %{name} = %{version}
%description %{kernelversion}
This package contains the driver for QLogic's QLA4xxx series of iSCSI cards for
kernel %{kernelversion} for the %{_target_cpu} architecture.
%prep
%setup -q -n 5.00.02
chmod u+x extras
%patch -p1 -b .inline
%patch1 -p1 -b .build
%build
K_LIBS=%{kernelroot}/lib/modules/%{kernelversion} extras/build.sh
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/lib/modules/%{kernelversion}/kernel/drivers/scsi/qla4xxx
install -m 0644 qla4xxx.ko $RPM_BUILD_ROOT/lib/modules/%{kernelversion}/kernel/drivers/scsi/qla4xxx
%clean
rm -rf $RPM_BUILD_ROOT
%post %{kernelversion}
depmod -ae
%postun %{kernelversion}
if [ $1 -eq 0 ]; then
depmod -aq
fi
%files %{kernelversion}
%defattr(-,root,root,-)
%doc ../release.txt revision.notes
/lib/modules/%{kernelversion}/kernel/drivers/scsi/qla4xxx/qla4xxx.ko
%changelog
* Wed May 25 2005 Ignacio Vazquez-Abrams <ivazquez at ivazquez.net> 5.00.02-0.iva.1
- Initial RPM release
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ivazquez-buildkernelmodule
Type: application/x-shellscript
Size: 1005 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-extras-list/attachments/20050525/ed47f32d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/fedora-extras-list/attachments/20050525/ed47f32d/attachment.sig>
More information about the fedora-extras-list
mailing list