在%post section kickstart RHEL7

时间:2017-09-11 22:55:28

标签: linux linux-kernel rpmbuild rpm-spec

我正在尝试安装自定义构建的自定义驱动程序rpm。我有一个kickstart文件捆绑到一个带有%post部分的RHEL7.2 iso中。在%post中,我有一个驱动程序rpm的yum安装似乎已安装,但我注意到depmod会在安装驱动程序rpm时记录致命错误:

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!

当rpm安装完毕后,它会运行depmod -a并重新启动以重建ramdisk。我不确定为什么在anaconda post安装过程中会出现这些错误?我已经确认在帖子中使用了相同的内核“3.10.0-327.el7.x86_64”,所以我不知道为什么没有“depmod”错误就无法正确安装模块。我从过去回忆起,anaconda安装过程中运行的内核与实际安装的内核存在差异。我不确定这是否归因于我在帖子中遇到的问题。关于如何克服这个问题的任何建议都会很棒。谢谢!

下面是我用来构建针对内核3.10.0-327.el7.x86_64的内核驱动程序rpm(kmod)的spec文件:

%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

0 个答案:

没有答案