kmodspec-el6

Note: This is a template file that would be edited and named "PHOO-kmod.spec" when part of the "PHOO" el6 SRPMS package.

When copying this file, please pay special attention to the override %{kmod_name} part of the %prep section (the two lines following the %{__cat} <<-EOF line). The leading white space must be a tab, not spaces.

# Define the kmod package name here.
%define  kmod_name PHOO

# If kversion isn't defined on the rpmbuild line, define it here.
%{!?kversion: %define kversion 2.6.32-44.1.el6.%{_target_cpu}}

Name:    %{kmod_name}-kmod
Version: 0.0
Release: 0.1%{?dist}
Group:   System Environment/Kernel
License: GPL v2
Summary: %{kmod_name} kernel module(s)
URL:     http://www.kernel.org/

BuildRequires:  rpm-build, redhat-rpm-config
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-build-%(%{__id_u} -n)
ExclusiveArch:  i686 x86_64

# Sources.
Source0:  %{kmod_name}-%{version}.tar.bz2
Source10: kmodtool-el6-%{kmod_name}.sh

# There are no kvariants.
%define kvariants ""

# Magic hidden here.
%define kmodtool sh %{SOURCE10}
%{expand:%(%{kmodtool} rpmtemplate %{kmod_name} %{kversion} %{kvariants} 2>/dev/null)}

# Disable the building of the debug package(s).
%define debug_package %{nil}

%description
This package provides the %{kmod_name} kernel module(s).
It is built to depend upon the specific ABI provided by a range of releases
of the same variant of the Linux kernel and not on any one specific build.

%prep
%setup -q -n %{kmod_name}-%{version}
%{__cat} <<-EOF > %{kmod_name}.conf
        override %{kmod_name} * weak-updates/%{kmod_name}
        EOF

%build
ksrc=%{_usrsrc}/kernels/%{kversion}
%{__make} -C "${ksrc}" %{?_smp_mflags} modules M=$PWD

%install
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
export INSTALL_MOD_DIR=extra/%{kmod_name}
ksrc=%{_usrsrc}/kernels/%{kversion}
%{__make} -C "${ksrc}" modules_install M=$PWD
%{__install} -d ${INSTALL_MOD_PATH}/etc/depmod.d/
%{__install} %{kmod_name}.conf ${INSTALL_MOD_PATH}/etc/depmod.d/
# Strip the module(s).
find ${INSTALL_MOD_PATH} -type f -name \*.ko -exec %{__strip} --strip-debug \{\} \;
# Remove the files that we do not require.
%{__rm} -f ${INSTALL_MOD_PATH}/lib/modules/%{kversion}/modules.*

%clean
%{__rm} -rf $RPM_BUILD_ROOT

%changelog
* Fri Aug 20 2010 Philip J Perry <phil@elrepo.org> - 0.0-0.1
- Initial el6 build of the kmod package.