From 6317642ce6296d078aeabe88e17c467d4173c5df Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Tue, 15 Jun 2021 19:04:38 +0200 Subject: [PATCH] rpmbuild: Handle bare --with-dpdk argument 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 Change-Id: I4dd587009da282a114524c74d833fd35ebc5b985 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8349 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Ben Walker Reviewed-by: Karol Latecki Reviewed-by: Jim Harris --- rpmbuild/rpm.sh | 44 ++++++++++++++++++++++++++++++++++++-------- rpmbuild/spdk.spec | 5 +++++ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/rpmbuild/rpm.sh b/rpmbuild/rpm.sh index d358d6472..8cb92d4af 100755 --- a/rpmbuild/rpm.sh +++ b/rpmbuild/rpm.sh @@ -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 @@ -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 @@ -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 @@ -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"} diff --git a/rpmbuild/spdk.spec b/rpmbuild/spdk.spec index b48a9e75e..1429914e6 100644 --- a/rpmbuild/spdk.spec +++ b/rpmbuild/spdk.spec @@ -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 @@ -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