rpmbuild: Allow to define custom builddir

Alternative for the default of $HOME/rpmbuild.

Signed-off-by: Michal Berger <michalx.berger@intel.com>
Change-Id: Id1feb7207926b518deb87045fc17bb3d1d4c374e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8159
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Michal Berger 2021-06-02 12:30:12 +02:00 committed by Tomasz Zawadzki
parent ab7bd10ad9
commit 93e6e40442
2 changed files with 13 additions and 8 deletions

View File

@ -11,6 +11,7 @@ fi
source "$1"
rootdir=$(readlink -f $(dirname $0))
testdir=$rootdir # to get the storage space for tests
source "$rootdir/test/common/autotest_common.sh"
function build_rpms() (
@ -20,7 +21,7 @@ function build_rpms() (
unset -v LD_LIBRARY_PATH
install_uninstall_rpms() {
rpms=("$HOME/rpmbuild/RPMS/x86_64/"spdk{,-devel,{,-dpdk}-libs}-$version-1.x86_64.rpm)
rpms=("$builddir/rpm/x86_64/"spdk{,-devel,{,-dpdk}-libs}-$version-1.x86_64.rpm)
sudo rpm -i "${rpms[@]}"
rpms=("${rpms[@]##*/}") rpms=("${rpms[@]%.rpm}")
@ -31,11 +32,12 @@ function build_rpms() (
}
build_rpm() {
MAKEFLAGS="$MAKEFLAGS" SPDK_VERSION="$version" DEPS=no "$rootdir/rpmbuild/rpm.sh" "$@"
BUILDDIR=$builddir MAKEFLAGS="$MAKEFLAGS" SPDK_VERSION="$version" DEPS=no "$rootdir/rpmbuild/rpm.sh" "$@"
install_uninstall_rpms
}
version="test_shared"
builddir=$SPDK_TEST_STORAGE/test-rpm
run_test "build_shared_rpm" build_rpm --with-shared
if [[ -n $SPDK_TEST_NATIVE_DPDK ]]; then

View File

@ -46,15 +46,18 @@ get_version() {
}
build_rpm() (
local macros=()
local macros=() dir
macros+=(-D "configure $configure")
macros+=(-D "make $make")
macros+=(-D "release $release")
macros+=(-D "version $version")
# Prepare default dir structure
mkdir -p "$HOME"/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
# Adjust dir macros to update the final location of the RPMS
for dir in build buildroot rpm source spec srcrpm; do
mkdir -p "$rpmbuild_dir/$dir"
macros+=(-D "_${dir}dir $rpmbuild_dir/$dir")
done
if [[ $configure == *"with-shared"* || $configure == *"with-dpdk"* ]]; then
macros+=(-D "dpdk 1")
@ -82,10 +85,10 @@ build_rpm() (
fedora_python_sys_path_workaround
# Despite building in-place, rpmbuild still looks under SOURCES as defined
# Despite building in-place, rpmbuild still looks under source dir as defined
# in Source:. Create a dummy file to fulfil its needs and to keep Source in
# the .spec.
: > "$rpmbuild_dir/SOURCES/spdk-$version.tar.gz"
: > "$rpmbuild_dir/source/spdk-$version.tar.gz"
printf '* Starting rpmbuild...\n'
rpmbuild --clean --nodebuginfo "${macros[@]}" --build-in-place -ba "$spec"
@ -99,7 +102,7 @@ release=${RPM_RELEASE:-1}
requirements=${REQUIREMENTS:-}
version=${SPDK_VERSION:-$(get_version)}
rpmbuild_dir=$HOME/rpmbuild
rpmbuild_dir=${BUILDDIR:-"$HOME/rpmbuild"}
spec=$specdir/spdk.spec
build_rpm