diff --git a/kmod-dinghai.spec b/kmod-dinghai.spec new file mode 100644 index 0000000000000000000000000000000000000000..a107b2fe001145c987be286d86cf83c989b32ac7 --- /dev/null +++ b/kmod-dinghai.spec @@ -0,0 +1,110 @@ +%global pkg dinghai +%define pkg_version 2.24.20.02 +%define release 1 + +%global debug_package %{nil} + +Name: kmod-%{pkg} +Version: %{pkg_version} +Release: %{release}%{?dist} +Summary: ZTE SmartNIC and DPU driver +License: GPLv2 +URL: https://gitee.com/anolis/kmod-dinghai +Source0: kmod-%{pkg}.tar.gz +Epoch: 1 + +# 安装依赖, 和内核版本对应 +Requires(posttrans): %{_sbindir}/depmod +Requires(postun): %{_sbindir}/depmod +Requires(posttrans): %{_sbindir}/weak-modules +Requires(postun): %{_sbindir}/weak-modules +Requires(posttrans): %{_bindir}/sort +Requires(postun): %{_bindir}/sort + +# 构建依赖, 和内核版本对应 +BuildRequires: elfutils-libelf-devel +BuildRequires: gcc +BuildRequires: kmod +BuildRequires: make +BuildRequires: system-rpm-config +BuildRequires: perl-Data-Dumper +BuildRequires: kernel +BuildRequires: kernel-headers + +%define kernel_version %(uname -r) + + +%description +RPM Package for ZXDH Driver + +%prep +%setup -q -n kmod-%{pkg} + +%build +pushd crypto/zsda +%{__make} %{?_smp_mflags} M=$PWD modules CONFIG_ACC_ZSDA_COMMON=m CONFIG_ACC_ZSDA_PF=m CONFIG_ACC_ZSDA_VF=m +popd +pushd net +./build.sh m +popd + +%install +mkdir -p %{buildroot}/lib/modules/%{kernel_version}/extra/drivers/dinghai/crypto/zsda/ +mkdir -p %{buildroot}/lib/modules/%{kernel_version}/extra/drivers/dinghai/net/ethernet/ +for ko in $(find crypto/zsda/accdevice/ net/drivers/ -name '*.ko'); do + if [[ $ko == crypto/zsda/accdevice/* ]]; then + target_dir=%{buildroot}/lib/modules/%{kernel_version}/extra/drivers/dinghai/crypto/zsda/ + elif [[ $ko == net/drivers/* ]]; then + target_dir=%{buildroot}/lib/modules/%{kernel_version}/extra/drivers/dinghai/net/ethernet/ + fi + %{__install} -D -t $target_dir $ko +done + +ls -l /lib/modules/%{kernel_version} + + +# Make .ko objects temporarily executable for automatic stripping +find %{buildroot}/lib/modules -type f -name \*.ko -exec chmod u+x \{\} \+ + +# Generate depmod.conf +%{__install} -d %{buildroot}/%{_sysconfdir}/depmod.d/ +for kmod in $(find %{buildroot}/lib/modules/%{kernel_version}/extra -type f -name \*.ko -printf "%%P\n" | sort) +do + echo "override $(basename $kmod .ko) * weak-updates/$(dirname $kmod)" >> %{buildroot}/%{_sysconfdir}/depmod.d/%{pkg}.conf + echo "override $(basename $kmod .ko) * extra/$(dirname $kmod)" >> %{buildroot}/%{_sysconfdir}/depmod.d/%{pkg}.conf +done + +%clean +%{__rm} -rf %{buildroot} + +%post +depmod -a > /dev/null 2>&1 + + +%preun +list_file="/var/run/rpm-%{pkg}-modules.list" +mkdir -p /var/run +for ko in $(find %{buildroot}/lib/modules/%{kernel_version}/extra/drivers/dinghai/crypto/zsda/ %{buildroot}/lib/modules/%{kernel_version}/extra/drivers/dinghai/net/ethernet/ -name '*.ko'); do + echo "${ko#%{buildroot}}" >> $list_file +done + +%postun +depmod -a > /dev/null 2>&1 + +if [ -x "/usr/sbin/weak-modules" ]; then + modules=( $(cat /var/run/rpm-%{pkg}-modules.list) ) + printf '%s\n' "${modules[@]}" | /usr/sbin/weak-modules --no-initramfs --remove-modules +fi +rm /var/run/rpm-%{pkg}-modules.list + +%files +%defattr(644,root,root,755) +/lib/modules/%{kernel_version} +%config(noreplace) %{_sysconfdir}/depmod.d/%{pkg}.conf + +%changelog +* Thu Jul 25 2024 hcf - 1:2.24.20.02-1 +- Dinghai driver init + + + diff --git a/kmod-dinghai.tar.gz b/kmod-dinghai.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..02e02f26c6090d64a35abf2e8dfcc54aa740984b Binary files /dev/null and b/kmod-dinghai.tar.gz differ