Files

Ignorování revizí v .git-blame-ignorerevs. Klikněte zde pro obejití a zobrazení normálního pohledu blame.

176 řádky
4.5 KiB
Bash
Surový Trvalý odkaz Normální zobrazení Historie

#!/bin/bash -e
if [ ! -f CMakeLists.txt ]; then
2022-04-21 21:36:07 -05:00
if [ ! -f ../CMakeLists.txt ]; then
echo "Error! Execute script from source directory"
exit 1
else
cd ..
fi
fi
set -e
tolower()
{
2023-03-07 06:04:19 -06:00
echo "$@" | awk -F '\\|~\\|' '{print tolower($1)}';
}
toupper()
{
2023-03-07 06:04:19 -06:00
echo "$@" | awk -F '\\|~\\|' '{print toupper($1)}';
}
usage()
{
print_option() { printf " --%-20s %-24s %s\n" "${1}" "${2}" "${3}"; }
echo "Options:"
print_option "help -h" "" "This message"
echo ""
print_default_option() { printf " --%-20s %-24s %s (default: %s)\n" "${1}" "${2}" "${3}" "$(tolower ${4})"; }
2023-03-07 06:04:19 -06:00
print_default_option distro "[ubuntu|opensuse|rhel]" "OS distribution" "${DISTRO}"
print_default_option versions "[VERSION] [VERSION...]" "Ubuntu or OpenSUSE release" "${VERSIONS}"
print_default_option rocm-versions "[VERSION] [VERSION...]" "ROCm versions" "${ROCM_VERSIONS}"
print_default_option python-versions "[VERSION] [VERSION...]" "Python 3 minor releases" "${PYTHON_VERSIONS}"
2022-11-17 08:43:45 -06:00
print_default_option "user -u" "[USERNAME]" "DockerHub username" "${USER}"
print_default_option "retry -r" "[N]" "Number of attempts to build (to account for network errors)" "${RETRY}"
echo ""
echo "Usage: ${BASH_SOURCE[0]} <OPTIONS> -- <build-release.sh OPTIONS>"
echo " e.g:"
echo " ${BASH_SOURCE[0]} --distro ubuntu --versions 22.04 --rocm-versions 6.4 6.3 -- --core +nopython --rocm-mpi +nopython"
echo " ${BASH_SOURCE[0]} --distro ubuntu --versions 22.04 --python-version 6 7 8 9 10 -- --rocm +python --rocm-mpi +nopython"
}
2022-04-21 21:36:07 -05:00
send-error()
{
usage
2022-04-21 21:36:07 -05:00
echo -e "\nError: ${@}"
exit 1
}
verbose-run()
{
2022-11-17 08:43:45 -06:00
echo -e "\n### Executing \"${@}\" a maximum of ${RETRY} times... ###\n"
for i in $(seq 1 1 ${RETRY})
do
set +e
eval "${@}"
local RETC=$?
set -e
if [ "${RETC}" -eq 0 ]; then
break
else
echo -en "\n### Command failed with error code ${RETC}... "
if [ "${i}" -ne "${RETRY}" ]; then
echo -e "Retrying... ###\n"
sleep 3
else
echo -e "Exiting... ###\n"
exit ${RETC}
fi
fi
done
2022-04-21 21:36:07 -05:00
}
build-release()
{
CONTAINER=$1
2022-04-04 15:27:38 -05:00
OS=$2
ROCM_VERSION=$3
CODE_VERSION=$4
2022-04-21 21:36:07 -05:00
shift
shift
shift
shift
local DOCKER_ARGS=""
tty -s && DOCKER_ARGS="-it" || DOCKER_ARGS=""
2024-10-21 14:58:30 -04:00
verbose-run docker run ${DOCKER_ARGS} --rm -v ${PWD}:/home/rocprofiler-systems --stop-signal "SIGINT" --env DISTRO=${OS} --env ROCM_VERSION=${ROCM_VERSION} --env VERSION=${CODE_VERSION} --env PYTHON_VERSIONS=\"${PYTHON_VERSIONS}\" --env IS_DOCKER=1 ${CONTAINER} /home/rocprofiler-systems/scripts/build-release.sh ${@}
}
reset-last()
{
last() { send-error "Unsupported argument :: ${1}"; }
}
reset-last
: ${USER:=$(whoami)}
2022-01-26 15:02:53 -06:00
: ${DISTRO:=ubuntu}
: ${VERSIONS:=22.04}
: ${ROCM_VERSIONS:=6.4 6.3}
2022-02-25 18:30:37 -06:00
: ${MPI:=0}
2025-05-02 19:29:15 -04:00
: ${PYTHON_VERSIONS:="6 7 8 9 10 11 12 13"}
2022-11-17 08:43:45 -06:00
: ${RETRY:=3}
2022-04-04 15:27:38 -05:00
n=0
while [[ $# -gt 0 ]]
do
case "${1}" in
-h|--help)
usage
exit 0
;;
2022-04-04 15:27:38 -05:00
"--distro")
shift
DISTRO=${1}
last() { DISTRO="${DISTRO} ${1}"; }
2022-04-04 15:27:38 -05:00
;;
"--versions")
shift
VERSIONS=${1}
last() { VERSIONS="${VERSIONS} ${1}"; }
2022-04-04 15:27:38 -05:00
;;
"--rocm-versions")
shift
ROCM_VERSIONS=${1}
last() { ROCM_VERSIONS="${ROCM_VERSIONS} ${1}"; }
2022-04-04 15:27:38 -05:00
;;
2022-04-21 21:36:07 -05:00
"--python-versions")
shift
PYTHON_VERSIONS=${1}
last() { PYTHON_VERSIONS="${PYTHON_VERSIONS} ${1}"; }
;;
--user|-u)
shift
USER=${1}
reset-last
2022-04-21 21:36:07 -05:00
;;
2022-11-17 08:43:45 -06:00
--retry|-r)
shift
RETRY=${1}
reset-last
;;
2022-04-21 21:36:07 -05:00
"--")
shift
SCRIPT_ARGS=${@}
break
;;
2022-04-04 15:27:38 -05:00
*)
last ${1}
2022-04-04 15:27:38 -05:00
;;
esac
n=$((${n} + 1))
shift
done
CODE_VERSION=$(cat VERSION)
if [ "${RETRY}" -lt 1 ]; then
RETRY=1
fi
2023-03-07 06:04:19 -06:00
if [ "${DISTRO}" = "rhel" ]; then
SCRIPT_ARGS="${SCRIPT_ARGS} --static-libstdcxx off"
fi
2022-01-26 15:02:53 -06:00
for VERSION in ${VERSIONS}
do
TAG=${DISTRO}-${VERSION}
2022-02-25 18:30:37 -06:00
for ROCM_VERSION in ${ROCM_VERSIONS}
do
2024-10-21 14:58:30 -04:00
build-release ${USER}/rocprofiler-systems:release-base-${TAG}-rocm-${ROCM_VERSION} ${DISTRO}-${VERSION} ${ROCM_VERSION} ${CODE_VERSION} ${SCRIPT_ARGS}
2022-02-25 18:30:37 -06:00
done
2022-01-26 15:02:53 -06:00
done