]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
build_utils: Function to install/change python3 symlink
authorDavid Galloway <dgallowa@redhat.com>
Thu, 28 Apr 2022 14:16:26 +0000 (10:16 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Thu, 28 Apr 2022 14:16:26 +0000 (10:16 -0400)
@guits needed all of the 2.jenkins.ceph.com builders to have `python3` point to `/usr/bin/python3.9`

Signed-off-by: David Galloway <dgallowa@redhat.com>
scripts/build_utils.sh

index 70802b0f18c786bd79d423ead7a6aa207761cc72..dfe56372509651b916e46c5a6890c0b3c759f319 100644 (file)
@@ -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
+}