加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
kmod-dinghai.spec 7.02 KB
一键复制 编辑 原始数据 按行查看 历史
%global pkg dinghai
%global kernel kernel version
%define pkg_version 2.24.20.02
%define anolis_release 1
%global debug_package %{nil}
Name: kmod-%{pkg}
Version: %(echo %{kernel} | sed -E 's/-/~/g; s/\.(an|al)[0-9]+$//g')
Release: %{pkg_version}~%{anolis_release}%{?dist}
Summary: ZTE SmartNIC and DPU driver
License: GPLv2
URL: https://gitee.com/anolis/kmod-dinghai
Source0: kmod-%{pkg}-%{pkg_version}.tar.gz
Epoch: 1
# 安装依赖, 和内核版本对应
Requires: kernel >= %{kernel}
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: kernel-devel = %{kernel}
BuildRequires: elfutils-libelf-devel
BuildRequires: gcc
BuildRequires: kmod
BuildRequires: make
BuildRequires: system-rpm-config
BuildRequires: perl-Data-Dumper
Provides: kmod-%{pkg}-%{kernel}.%{_arch} = %{version}-%{release}
Obsoletes: kmod-%{pkg}-%{kernel}.%{_arch} < %{version}-%{release}
%description
RPM Package for ZXDH Driver
%prep
%setup -q -n kmod-%{pkg}-%{pkg_version}
%build
pushd src/crypto/zsda
%{__make} -C /usr/src/kernels/%{kernel}.%{_arch} %{?_smp_mflags} M=$PWD modules CONFIG_ACC_ZSDA_COMMON=m CONFIG_ACC_ZSDA_PF=m CONFIG_ACC_ZSDA_VF=m
popd
pushd src/net/build
./build.pl -t clean --ksrc /usr/src/kernels/%{kernel}.%{_arch}
./build.pl -t kernel -m CONFIG_DINGHAI_ETH -m CONFIG_DINGHAI_PF -m CONFIG_ZXDH_SF -m CONFIG_DINGHAI_EN_AUX \
-m HAVE_DEVLINK_ALLOC_GET_1_PARAMS -m HAVE_DEV_PM_DOMAIN_ATTACH -m HAVE_BUS_FIND_DEVICE_GET_CONST \
-m CONFIG_DINGHAI_DH_CMD -m CONFIG_DINGHAI_NP -m CONFIG_ZXDH_MSGQ -m CONFIG_ZXDH_1588 -m CONFIG_DINGHAI_PTP \
--ksrc /usr/src/kernels/%{kernel}.%{_arch}
popd
pushd src/rdma
./build.sh --ksrc /usr/src/kernels/%{kernel}.%{_arch} --use_rel_net_path
popd
%install
mkdir -p %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/crypto/zsda/
mkdir -p %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/
mkdir -p %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/infiniband/hw/
%{__install} -D -t %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/crypto/zsda/ src/crypto/zsda/accdevice/zsda_common/zsda_common.ko
%{__install} -D -t %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/crypto/zsda/ src/crypto/zsda/accdevice/zsda_pf/zsda_pf.ko
%{__install} -D -t %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/crypto/zsda/ src/crypto/zsda/accdevice/zsda_vf/zsda_vf.ko
%{__install} -D -t %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/ src/net/drivers/net/ethernet/dinghai/zxdh_cmd.ko
%{__install} -D -t %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/ src/net/drivers/net/ethernet/dinghai/zxdh_np.ko
%{__install} -D -t %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/ src/net/drivers/net/ethernet/dinghai/zxdh_ptp.ko
%{__install} -D -t %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/ src/net/drivers/net/ethernet/dinghai/zxdh_pf.ko
%{__install} -D -t %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/ src/net/drivers/net/ethernet/dinghai/zxdh_en_aux.ko
%{__install} -D -t %{buildroot}/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/infiniband/hw/ src/rdma/src/zrdma.ko
# 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}.%{_arch}/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
if [ -x "/usr/sbin/weak-modules" ]; then
printf '%s\n' "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/crypto/zsda/zsda_common.ko" | /usr/sbin/weak-modules --no-initramfs --add-modules
printf '%s\n' "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/crypto/zsda/zsda_pf.ko" | /usr/sbin/weak-modules --no-initramfs --add-modules
printf '%s\n' "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/crypto/zsda/zsda_vf.ko" | /usr/sbin/weak-modules --no-initramfs --add-modules
printf '%s\n' "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/zxdh_cmd.ko" | /usr/sbin/weak-modules --no-initramfs --add-modules
printf '%s\n' "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/zxdh_np.ko" | /usr/sbin/weak-modules --no-initramfs --add-modules
printf '%s\n' "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/zxdh_ptp.ko" | /usr/sbin/weak-modules --no-initramfs --add-modules
printf '%s\n' "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/zxdh_pf.ko" | /usr/sbin/weak-modules --no-initramfs --add-modules
printf '%s\n' "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/zxdh_en_aux.ko" | /usr/sbin/weak-modules --no-initramfs --add-modules
printf '%s\n' "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/infiniband/hw/zrdma.ko" | /usr/sbin/weak-modules --no-initramfs --add-modules
fi
%preun
echo "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/crypto/zsda/zsda_common.ko" >> /var/run/rpm-%{pkg}-modules.list
echo "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/crypto/zsda/zsda_pf.ko" >> /var/run/rpm-%{pkg}-modules.list
echo "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/crypto/zsda/zsda_vf.ko" >> /var/run/rpm-%{pkg}-modules.list
echo "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/zxdh_cmd.ko" >> /var/run/rpm-%{pkg}-modules.list
echo "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/zxdh_np.ko" >> /var/run/rpm-%{pkg}-modules.list
echo "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/zxdh_ptp.ko" >> /var/run/rpm-%{pkg}-modules.list
echo "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/zxdh_pf.ko" >> /var/run/rpm-%{pkg}-modules.list
echo "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/net/ethernet/zxdh_en_aux.ko" >> /var/run/rpm-%{pkg}-modules.list
echo "/lib/modules/%{kernel}.%{_arch}/extra/drivers/dinghai/infiniband/hw/zrdma.ko" >> /var/run/rpm-%{pkg}-modules.list
%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)
%license licenses
/lib/modules/%{kernel}.%{_arch}
%config(noreplace) %{_sysconfdir}/depmod.d/%{pkg}.conf
%changelog
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化