Unable to install kernel driver rpm during custom kickstart install RHEL7

Latest response

I've built a kernel driver rpm that I'm attempting to include into my custom rhel7 kickstart install that's packaged inside of a rhel7 iso. As the rpm gets installed, it runs a depmod -a 3.10.0-327.el7.x86_64 and dracut -f -v /boot/initramfs-3.10.0-327.el7.x86_64.img 3.10.0-327.el7.x86_64. The rpm gets installed, but I notice that the depmod command logs fatal errors when the driver rpm gets installed:

Installing : kmod-xnxx-1.0-1_test.x86_64
depmod: FATAL: could not load 3.10.0-327.el7.x86_64: No such file or directory
warning: %post(kmod-xnxx-1.0-1_test.x86_64) scriptlet failed, exit status 1
Non-fatal POSTIN scriptlet failure in rpm package kmod-xnxx-1.0-1_test.x86_64
     Verifying  :  kmod-xnxx-1.0-1_test.x86_64

Installed :
      kmod-xnxx-1.0-1_test.x86_64

Complete!

I've confirmed that the same kernel 3.10.0-327.el7.x86_64 is being used during the post so I have no idea why the module doesn't get installed correctly without the "depmod" errors. I'm able to install and run the depmod & dracut commands successfully after the system gets installed, but not during the anaconda installation post section in my kickstart. I recall from the past that the running kernel during the anaconda install has differences with the kernel that actually gets installed by anaconda. I'm not sure if this is attributed to the issue I'm having with the post. Any suggestions on how to overcome this would be great. Thanks!

Below is the spec file that I'm using to build the kernel driver rpm(kmod) against kernel 3.10.0-327.el7.x86_64:

%define build_kernel 3.10.0-327.el7.x86_64
%define current_kernel %(uname -r)
%define destdir /lib/modules/3.10.0-327.el7.x86_64/kernel/drivers/net/

Summary: driver
Name: kmod-xnxx
Version: 1.0
Release: 1_test
License: GPL
Group: Hardware driver
BuildArch: x86_64
BuildRoot: %{buildroot}


%description
Creating a xn4xx kernel module RPM

%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 644 %(pwd)/BUILD/xnxx.ko %{buildroot}%{destdir}xnxx.ko

%clean
rm -rf %{buildroot}

%post
/sbin/depmod -a %{current_kernel}
/sbin/dracut -v -f /boot/initramfs-%{current_kernel}.img %{current_kernel}

%files
%defattr(-,root,root)
%{destdir}xnxx.ko


%changelog
* Mon September 11 2017 

Responses