Related Posts:
Creating a kernel module RPM Package
This HOWTO narrates three stages of creating a linux kernel module binary RPM package.
1. Creating a RPM .spec file
2. Building the the binary RPM package
3. Installing the RPM
Let us see these steps in detail further.
1. Create a .spec file
This file defines the sequence of commands and configurations to be executed while installing/uninstalling the RPM in short. Please find the given below sample (bare minimum) your_module.spec file and do the necessary modification to it wherever necessary.
%define build_kernel 2.6.18
%define current_kernel %(uname -r)
%define destdir /lib/modules/%{current_kernel}/kernel/drivers/xxxx
Summary: Driver for XXXXXXXXXXXXXXXXXX
Name: your_module
Version: 1.0.0
Release: 1
License: GPL
Group: drivers/xxxx
BuildRoot: /usr/src/build/temp
%description
Driver for XXXXXXXXXXXXXXXXXX
%prep
%install
mkdir -p %{buildroot}/%{destdir}
if [ "%{build_kernel}" != "%{current_kernel}" ]; then
echo “This rpm is for %{build_kernel} kernel version. Ensure that you are using right module/kernel”
exit 1
fi
ls %{destdir} > /dev/null 2> /dev/null
if [ $? != 0 ]; then
echo “%{destdir} is not there. Unable to install the driver.”
exit 1
fi
install -m 755 %(pwd)/your_module %{buildroot}%{destdir}/your_module.ko
%clean
rm -rf %{buildroot}
%post
/sbin/depmod -ae %{current_kernel}
%files
%defattr(-,root,root)
%{destdir}/your_module.ko
%changelog
* Mon May 19 2008 Your Company name goes here.
- Short release note for your driver goes here
2. Steps to build RPM Package
1. Change to linux kernel module directory and compile the module. Ensure that the module is compiled successfully.
2. Copying the compiled kernel object to standard path:
RHEL (Redhat): Copy your module’s .ko file to /usr/src/redhat/BUILD/
SLES (Novell): Copy your module’s .ko file to /usr/src/packages/BUILD/
3. Edit the your_module.spec file, such that is your target build kernel version is set:
(e.g): %define build_kernel 2.6.18
4. Building the rpm package file:
# rpmbuild -bb inverness.spec
5. Ensure that rpm file is generated in the following path and install the same (for 64-bit, refer the corresponding path)
(e.g): RHEL: # rpm -ivh /usr/src/redhat/RPMS/i386/your_module-xxxxx.i386.rpm
(e.g): SLES: # rpm -ivh /usr/src/packages/RPMS/i386/your_module-xxxxx.i386.rpm
3. Installing the RPM package:
Install the rpm with following command. This should load the inverness driver automatically during startup of system.
# rpm -ivh your_module-xxxxx.i386.rpm
Courtesy: Venkata Ramana, my friend who did base work on this. I just refined and learned.
Follow-up
More posts in this category
- How to get Fingerprint reader working in Fedora Linux (Upek 147e:1000 in this case)
- How to get Lilliput DisplayLink based USB Monitor UM-70 (17e9:02a9) working in Ubuntu Linux
- How to sync GMail contacts with Thunderbird address book
- How to make Slide show using GIMP in a few clicks
- How to upload pictures to Picasa from Ubuntu in simple right-click










