Skip to content

Commit

Permalink
ci: support spec files with '!?ohpc_mpi_dependent'
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Reber <areber@redhat.com>
  • Loading branch information
adrianreber committed Jun 16, 2023
1 parent 3bf0a6b commit 1843150
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 9 deletions.
23 changes: 16 additions & 7 deletions misc/build_srpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ else
COMPILER_FAMILY=gnu12
fi

if [ $# -eq 3 ]; then
if [ $# -ge 3 ]; then
MPI_FAMILY=$3
else
MPI_FAMILY=openmpi4
fi

if [ $# -eq 4 ]; then
MPI_DEPENDENT=$4
else
MPI_DEPENDENT=1
fi

if [ ! -e "${SPEC}" ]; then
echo "Spec file ${SPEC} does not exist. Exiting."
exit 1
Expand Down Expand Up @@ -54,16 +60,19 @@ echo "Building SRPM for ${SPEC}"
prepare_git_tree "${DIR}"

# Try to build the SRPM
SRPM=$(build_srpm "${SPEC}" "${COMPILER_FAMILY}" "${MPI_FAMILY}")
SRPM=$(build_srpm "${SPEC}" "${COMPILER_FAMILY}" "${MPI_FAMILY}" "${MPI_DEPENDENT}")
RESULT=$?
if [ "${RESULT}" == "1" ]; then
echo "Building the SRPM for ${BASE} failed."
echo "Trying to fetch Source0"
"${ROOT}"/misc/get_source.sh "${BASE}"
if [ "${RESULT}" == "0" ]; then
echo "${SRPM}"
exit 0
fi

echo "Building the SRPM for ${BASE} failed."
echo "Trying to fetch Source0"
"${ROOT}"/misc/get_source.sh "${BASE}"

# Let's hope fetching the sources worked and retry building the SRPM
SRPM=$(build_srpm "${SPEC}" "${COMPILER_FAMILY}" "${MPI_FAMILY}")
SRPM=$(build_srpm "${SPEC}" "${COMPILER_FAMILY}" "${MPI_FAMILY}" "${MPI_DEPENDENT}")
RESULT=$?

if [ "${RESULT}" == "1" ]; then
Expand Down
9 changes: 8 additions & 1 deletion misc/shell-functions
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ build_srpm() {
local DIR
local COMPILER_FAMILY=${2}
local MPI_FAMILY=${3}
local MPI_DEPENDENT=${4}

if [ "${MPI_DEPENDENT}" -eq "0" ]; then
MPI_DEPENDENT=(--define 'ohpc_mpi_dependent 0')
else
MPI_DEPENDENT=()
fi

DIR=$(dirname "${1}")

SRPM=$(rpmbuild -bs --nodeps --define "_sourcedir ${DIR}/../SOURCES" --define "compiler_family ${COMPILER_FAMILY}" --define "mpi_family ${MPI_FAMILY}" "${SPEC}" 2>/dev/null)
SRPM=$(rpmbuild -bs --nodeps --define "_sourcedir ${DIR}/../SOURCES" --define "compiler_family ${COMPILER_FAMILY}" --define "mpi_family ${MPI_FAMILY}" "${MPI_DEPENDENT[@]}" "${SPEC}" 2>/dev/null)
RESULT=$?

echo "${SRPM}" | tail -1 | awk -F\ '{ print $2 }'
Expand Down
36 changes: 35 additions & 1 deletion tests/ci/run_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ def loop_command(command, max_attempts=5):
time.sleep(attempt_counter)


def build_srpm_and_rpm(command, mpi_family=None, compiler_family=None):
def build_srpm_and_rpm(
command,
mpi_family=None,
compiler_family=None,
not_mpi_dependent=False
):
# Build SRPM
command = [
'misc/build_srpm.sh',
Expand All @@ -132,6 +137,13 @@ def build_srpm_and_rpm(command, mpi_family=None, compiler_family=None):
command.append(compiler_family)
if compiler_family and mpi_family:
command.append(mpi_family)
if not_mpi_dependent:
if not mpi_family:
# This is a shortcoming of the build_srpm script.
# It only has positional parameters.
# It needs a dummy parameter here.
command.append('openmpi4')
command.append('0')
success, output = run_command(command)
if not success:
# First check if the architecture is not supported
Expand Down Expand Up @@ -202,6 +214,11 @@ def build_srpm_and_rpm(command, mpi_family=None, compiler_family=None):
" --define 'compiler_family %s'" % compiler_family
)

if not_mpi_dependent:
rebuild_command[-1] += (
" --define 'ohpc_mpi_dependent 0'"
)

# Disable parallel builds for below packages on aarch64 to avoid OOM
pkgs = ["boost-", "paraver-"]
if any([x in src_rpm for x in pkgs]) and os.uname().machine == "aarch64":
Expand Down Expand Up @@ -274,6 +291,23 @@ def build_srpm_and_rpm(command, mpi_family=None, compiler_family=None):
"%s (%s, %s)" %
(just_spec, args.compiler_family, family))

if '!?ohpc_mpi_dependent' in contents:
# This is a package that can be built with and without MPI support.
# It should have the following line:
# '%{!?ohpc_mpi_dependent:%define ohpc_mpi_dependent 1}'
# If that exists we need to rebuild it once more with
# ohpc_mpi_dependent set to 0.
if not build_srpm_and_rpm(
spec,
compiler_family=args.compiler_family,
not_mpi_dependent=True,
):
failed.append(just_spec)
else:
rebuild_success.append(
"%s (%s)" %
(just_spec, args.compiler_family))

elif 'ohpc_compiler_dependent' in contents:
if not build_srpm_and_rpm(
spec,
Expand Down

0 comments on commit 1843150

Please sign in to comment.