Skip to content

Commit

Permalink
rpmbuild: Handle bare --with-dpdk argument
Browse files Browse the repository at this point in the history
This is done in order to detect if user wants to build spdk RPMs
against DPDK RPMs that might have been installed on the system.

This boils down to the following:

 - if --with-dpdk, with no argument, is detected don't build
   separate RPM holding DPDK libs since user in this case is
   most likely interested only in packaging the SPDK so it
   can coexist with separate DPDK packaging workflow
 - define install and build requirements for the SPDK RPMs
   to depend on dpdk-devel RPM

Signed-off-by: Michal Berger <[email protected]>
Change-Id: I4dd587009da282a114524c74d833fd35ebc5b985
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8349
Community-CI: Broadcom CI <[email protected]>
Tested-by: SPDK CI Jenkins <[email protected]>
Reviewed-by: Tomasz Zawadzki <[email protected]>
Reviewed-by: Ben Walker <[email protected]>
Reviewed-by: Karol Latecki <[email protected]>
Reviewed-by: Jim Harris <[email protected]>
  • Loading branch information
Michal Berger authored and tomzawadzki committed Jul 12, 2021
1 parent 68b6d0e commit 6317642
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
44 changes: 36 additions & 8 deletions rpmbuild/rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ if [[ $ID != fedora && $ID != centos && $ID != rhel ]]; then
exit 1
fi

get_config() {
# Intercept part of the ./configure's cmdline we are interested in
configure_opts=($(getopt -l "$1::" -o "" -- $configure 2> /dev/null))
# Drop "--"
configure_opts=("${configure_opts[@]::${#configure_opts[@]}-1}")
((${#configure_opts[@]} > 0)) || return 1

if [[ $2 == has-arg ]]; then
[[ -n ${configure_opts[1]} && ${configure_opts[1]} != "''" ]]
elif [[ $2 == print ]]; then
echo "${configure_opts[1]//\'/}"
fi
}

fedora_python_sys_path_workaround() {
[[ -z $NO_WORKAROUND ]] || return 0

Expand Down Expand Up @@ -59,17 +73,25 @@ build_rpm() (
macros+=(-D "_${dir}dir $rpmbuild_dir/$dir")
done

if [[ $configure == *"with-shared"* || $configure == *"with-dpdk"* ]]; then
macros+=(-D "dpdk 1")
if get_config with-shared; then
macros+=(-D "shared 1")
macros+=(-D "dpdk 1")
fi

if [[ $configure == *"with-dpdk"* ]]; then
dpdk_build_path=${configure#*with-dpdk=}
dpdk_build_path=${dpdk_build_path%% *}
dpdk_path=${dpdk_build_path%/*}
macros+=(-D "dpdk_build_path $dpdk_build_path")
macros+=(-D "dpdk_path $dpdk_path")
if get_config with-dpdk; then
if ! get_config with-dpdk has-arg; then
# spdk is requested to build against installed dpdk (i.e. provided by the dist).
# Don't build dpdk rpm rather define proper requirements for the spdk.
macros+=(-D "dpdk 0")
macros+=(-D "shared 1")
requirements=${requirements:+$requirements, }"dpdk-devel >= 19.11"
build_requirements=${build_requirements:+$build_requirements, }"dpdk-devel >= 19.11"
else
dpdk_build_path=$(get_config with-dpdk print)
dpdk_path=$(dirname "$dpdk_build_path")
macros+=(-D "dpdk_build_path $dpdk_build_path")
macros+=(-D "dpdk_path $dpdk_path")
fi
fi

if [[ $deps == no ]]; then
Expand All @@ -81,6 +103,11 @@ build_rpm() (
macros+=(-D "requirements_list $requirements")
fi

if [[ -n $build_requirements ]]; then
macros+=(-D "build_requirements 1")
macros+=(-D "build_requirements_list $build_requirements")
fi

cd "$rootdir"

fedora_python_sys_path_workaround
Expand All @@ -100,6 +127,7 @@ deps=${DEPS:-yes}
make="${MAKEFLAGS:--j $(nproc)}"
release=${RPM_RELEASE:-1}
requirements=${REQUIREMENTS:-}
build_requirements=${BUILD_REQUIREMENTS:-}
version=${SPDK_VERSION:-$(get_version)}

rpmbuild_dir=${BUILDDIR:-"$HOME/rpmbuild"}
Expand Down
5 changes: 5 additions & 0 deletions rpmbuild/spdk.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
%{!?dpdk_build_path:%define dpdk_build_path "dpdk/build"}
%{!?dpdk_path:%define dpdk_path "dpdk"}
%{!?requirements:%define requirements 0}
%{!?build_requirements:%define build_requirements 0}
%{!?shared:%define shared 0}

# Spec metadata
Expand All @@ -32,6 +33,10 @@ Requires: zlib
Requires: %(echo "%{requirements_list}")
%endif

%if %{build_requirements}
BuildRequires: %(echo "%{build_requirements_list}")
%endif

License: BSD
URL: https://spdk.io
Source: spdk-%{version}.tar.gz
Expand Down

0 comments on commit 6317642

Please sign in to comment.