Skip to content

Commit

Permalink
rpmbuild: Allow to define custom builddir
Browse files Browse the repository at this point in the history
Alternative for the default of $HOME/rpmbuild.

Signed-off-by: Michal Berger <[email protected]>
Change-Id: Id1feb7207926b518deb87045fc17bb3d1d4c374e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8159
Tested-by: SPDK CI Jenkins <[email protected]>
Reviewed-by: Jim Harris <[email protected]>
Reviewed-by: Tomasz Zawadzki <[email protected]>
  • Loading branch information
Michal Berger authored and tomzawadzki committed Jun 8, 2021
1 parent ab7bd10 commit 93e6e40
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 4 additions & 2 deletions autopackage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() (
Expand All @@ -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}")
Expand All @@ -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
Expand Down
15 changes: 9 additions & 6 deletions rpmbuild/rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"
Expand All @@ -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

0 comments on commit 93e6e40

Please sign in to comment.