From 211b62e9b29feb9c197f2924009565145d6350f6 Mon Sep 17 00:00:00 2001 From: "R.B. Boyer" <4903+rboyer@users.noreply.github.com> Date: Wed, 1 Jun 2022 15:24:45 -0500 Subject: [PATCH] build: ensure tools match go toolchain version (#13338) --- build-support/scripts/devtools.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) mode change 100644 => 100755 build-support/scripts/devtools.sh diff --git a/build-support/scripts/devtools.sh b/build-support/scripts/devtools.sh old mode 100644 new mode 100755 index 4ab5ba39d..32aea96bd --- a/build-support/scripts/devtools.sh +++ b/build-support/scripts/devtools.sh @@ -165,7 +165,10 @@ function install_versioned_tool { local installbase="$4" local should_install= + local install_reason= local got + local vgot + local vneed local expect="${module}@${version}" local install="${installbase}@${version}" @@ -189,13 +192,25 @@ function install_versioned_tool { awk '{print $2 "@" $3}')" if [[ "$expect" != "$got" ]]; then should_install=1 + install_reason="upgrade" + fi + + # check that they were compiled with the current version of go + set +o pipefail + vgot="$(go version -m $(which "${command}") | head -n 1 | grep -o 'go[0-9.]\+')" + vneed="$(go version | head -n 1 | awk '{print $3}')" + set -o pipefail + if [[ "$vgot" != "$vneed" ]]; then + should_install=1 + install_reason="go toolchain upgrade" fi else should_install=1 + install_reason="install" fi if [[ -n $should_install ]]; then - status_stage "installing tool: ${install}" + status_stage "installing tool (${install_reason}): ${install}" go install "${install}" else debug "skipping tool: ${install} (installed)"