From 98433e968bdc25ae1c5265e49374f957562197f8 Mon Sep 17 00:00:00 2001 From: David Galloway Date: Thu, 28 Apr 2022 10:16:26 -0400 Subject: [PATCH] build_utils: Function to install/change python3 symlink @guits needed all of the 2.jenkins.ceph.com builders to have `python3` point to `/usr/bin/python3.9` Signed-off-by: David Galloway --- scripts/build_utils.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/build_utils.sh b/scripts/build_utils.sh index 70802b0f..dfe56372 100644 --- a/scripts/build_utils.sh +++ b/scripts/build_utils.sh @@ -1652,3 +1652,15 @@ function retrycmd_if_failure() { echo "Executed '$*' $i times" set -o errexit } + +function set_centos_python3_version() { + # This function expects $1 to be a string like "python3.9" + local CURRENT_PYTHON3_VERSION=$(sudo alternatives --list | grep -e '^python3' | awk '{ print $3 }') + local EXPECTED_PYTHON3_VERSION=$1 + if ! [[ "$CURRENT_PYTHON3_VERSION" =~ .*"$EXPECTED_PYTHON3_VERSION" ]]; then + sudo dnf install -y $EXPECTED_PYTHON3_VERSION + sudo alternatives --set python3 /usr/bin/$EXPECTED_PYTHON3_VERSION + else + echo "python3 symlink already points to $CURRENT_PYTHON3_VERSION" + fi +} -- 2.39.5