1# Global macros 2%define debug_package %{nil} 3 4%{!?deps:%define deps 1} 5%{!?dpdk:%define dpdk 0} 6%{!?fio:%define fio 0} 7%{!?requirements:%define requirements 0} 8%{!?build_requirements:%define build_requirements 0} 9%{!?shared:%define shared 0} 10%{!?rbd:%define rbd 0} 11%{!?libdir:%define libdir /usr/local/lib} 12%{!?vfio_user:%define vfio_user 0} 13 14# Spec metadata 15Name: spdk 16Version: %{version} 17Release: %{release} 18Summary: Storage Performance Development Kit 19 20# This is a minimal set of requirements needed for SPDK apps to run when built with 21# default configuration. These are also predetermined by rpmbuild. Extra requirements 22# can be defined through a comma-separated list passed via $requirements when building 23# the spec. 24Requires: glibc 25Requires: libaio 26Requires: libgcc 27Requires: libstdc++ 28Requires: libuuid 29Requires: ncurses-libs 30Requires: numactl-libs 31Requires: openssl-libs 32Requires: zlib 33 34%if %{requirements} 35Requires: %(echo "%{requirements_list}") 36%endif 37 38BuildRequires: python3-devel 39 40%if %{build_requirements} 41BuildRequires: %(echo "%{build_requirements_list}") 42%endif 43 44License: BSD 45URL: https://spdk.io 46Source: spdk-%{version}.tar.gz 47 48%description 49 50The Storage Performance Development Kit (SPDK) provides a set of tools and libraries for 51writing high performance, scalable, user-mode storage applications. It achieves high 52performance by moving all of the necessary drivers into userspace and operating in a 53polled mode instead of relying on interrupts, which avoids kernel context switches and 54eliminates interrupt handling overhead. 55 56%prep 57make clean %{make} &>/dev/null || : 58%setup 59 60%build 61set +x 62 63cfs() { 64 (($# > 1)) || return 0 65 66 local dst=$1 f 67 68 mkdir -p "$dst" 69 shift; for f; do [[ -e $f ]] && cp -a "$f" "$dst"; done 70} 71 72cl() { 73 [[ -e $2 ]] || return 0 74 75 cfs "$1" $(find "$2" -name '*.so*' -type f -o -type l | grep -v .symbols) 76} 77 78%if %{deps} 79_PKGDEP_OPTS="--docs --pmem --rdma --uring" 80%if %{rbd} 81_PKGDEP_OPTS="$_PKGDEP_OPTS --rbd" 82%endif 83./scripts/pkgdep.sh $_PKGDEP_OPTS 84%endif 85 86# Rely mainly on CONFIG 87git submodule update --init 88./configure --disable-unit-tests --disable-tests %{configure} 89make %{make} 90make DESTDIR=%{buildroot} install %{make} 91# DPDK always builds both static and shared, so we need to remove one or the other 92# SPDK always builds static, so remove it if we want shared. 93%if %{shared} 94 rm -f %{buildroot}/usr/local/lib/lib*.a 95%endif 96%if "%{shared}" != "1" 97 rm -f %{buildroot}/usr/local/lib/lib*.so* 98 rm -rf %{buildroot}/usr/local/lib/dpdk 99%endif 100%if %{dpdk} 101# DPDK also installs some python scripts to bin that we do not want to package here 102rm -f %{buildroot}/usr/local/bin/dpdk-*.py 103# DPDK examples do not need to be packaged in our RPMs 104rm -rf %{buildroot}/usr/local/share/dpdk 105# In case sphinx-build is available, DPDK will leave some files we don't need 106rm -rf %{buildroot}/usr/local/share/doc/dpdk 107%endif 108 109# The ISA-L install may have installed some binaries that we do not want to package 110rm -f %{buildroot}/usr/local/bin/igzip 111rm -rf %{buildroot}/usr/local/share/man 112 113# Include libvfio-user libs in case --with-vfio-user is in use together with --with-shared 114%if %{vfio_user} && %{shared} 115cl %{buildroot}/usr/local/lib/libvfio-user build/libvfio-user/ 116%endif 117 118# And some useful setup scripts SPDK uses 119mkdir -p %{buildroot}/usr/libexec/spdk 120mkdir -p %{buildroot}/etc/bash_completion.d 121mkdir -p %{buildroot}/etc/profile.d 122mkdir -p %{buildroot}/etc/ld.so.conf.d 123 124%if %{shared} 125cat <<-EOF > %{buildroot}/etc/ld.so.conf.d/spdk.conf 126%{libdir} 127/usr/local/lib/dpdk 128/usr/local/lib/libvfio-user 129EOF 130%endif 131 132cat <<-'EOF' > %{buildroot}/etc/profile.d/spdk_path.sh 133PATH=$PATH:/usr/libexec/spdk/scripts 134PATH=$PATH:/usr/libexec/spdk/scripts/vagrant 135PATH=$PATH:/usr/libexec/spdk/test/common/config 136export PATH 137EOF 138 139cfs %{buildroot}/usr/libexec/spdk scripts 140ln -s /usr/libexec/spdk/scripts/bash-completion/spdk %{buildroot}/etc/bash_completion.d/ 141 142# We need to take into the account the fact that most of the scripts depend on being 143# run directly from the repo. To workaround it, create common root space under dir 144# like /usr/libexec/spdk and link all potential relative paths the script may try 145# to reference. 146 147# setup.sh uses pci_ids.h 148ln -s /usr/local/include %{buildroot}/usr/libexec/spdk 149 150%files 151/usr/local/bin/* 152/usr/local/lib/python%{python3_version}/site-packages/spdk*/* 153 154%package devel 155%if %{shared} 156Summary: SPDK development libraries and headers 157%endif 158%if "%{shared}" != "1" 159Summary: SPDK static development libraries and headers 160%endif 161 162%description devel 163%if %{shared} 164SPDK development libraries and header 165%endif 166%if "%{shared}" != "1" 167SPDK static development libraries and header 168%endif 169 170%files devel 171/usr/local/include/* 172%{libdir}/pkgconfig/*.pc 173%{libdir}/*.la 174%if %{fio} 175%{libdir}/fio 176%endif 177%if %{shared} 178%{libdir}/*.so* 179/etc/ld.so.conf.d/spdk.conf 180%if %{dpdk} 181%{libdir}/dpdk 182%endif 183%if %{vfio_user} 184/usr/local/lib/libvfio-user 185%endif 186%endif 187%if "%{shared}" != "1" 188%{libdir}/*.a 189%endif 190 191%post devel 192ldconfig 193 194%package scripts 195Summary: SPDK scripts and utilities 196 197%description scripts 198SPDK scripts and utilities 199 200%files scripts 201/usr/libexec/spdk/* 202/etc/profile.d/* 203/etc/bash_completion.d/* 204 205%post scripts 206ldconfig 207 208%changelog 209* Tue Feb 16 2021 Michal Berger <michalx.berger@intel.com> 210- Initial RPM .spec for the SPDK 211