From: David Galloway Date: Mon, 2 May 2022 18:31:12 +0000 (-0400) Subject: build_utils.sh: Remove python3 versions we don't want X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7de24933bb5d42f493781cbc8a1b51fd7833cf7e;p=ceph-build.git build_utils.sh: Remove python3 versions we don't want @guits and I think there's either a bug in `alternatives` or we just can't figure out how it's supposed to work. Even with setting `alternatives --set python3 /usr/bin/python3.9`, python3.6 was still the "best" version according to `alternatives --display`. So we'll just remove the other version entirely. Signed-off-by: David Galloway --- diff --git a/scripts/build_utils.sh b/scripts/build_utils.sh index dfe56372..c2c8e250 100644 --- a/scripts/build_utils.sh +++ b/scripts/build_utils.sh @@ -1655,11 +1655,13 @@ function retrycmd_if_failure() { 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 CURRENT_PYTHON3_VERSION=$(sudo alternatives --display python3 | grep -e 'Current.*best.* version is' | awk '{ print $5 }' | sed 's/\.$//') 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 + PYTHON3_TO_REMOVE=$(rpm -qf $CURRENT_PYTHON3_VERSION | cut -d '-' -f1) + sudo dnf remove -y ${PYTHON3_TO_REMOVE}\* + sudo dnf install -y $EXPECTED_PYTHON3_VERSION || sudo dnf reinstall -y $EXPECTED_PYTHON3_VERSION + sudo alternatives --display python3 else echo "python3 symlink already points to $CURRENT_PYTHON3_VERSION" fi