From 540bbcb0e226279905633aa50d4bdfb29166f202 Mon Sep 17 00:00:00 2001 From: Steph Roberts Date: Mon, 1 Jul 2024 23:27:07 +0000 Subject: [PATCH] Add AL23 ref doc and install specific go version --- buildspecs/pr-build-amzn.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/buildspecs/pr-build-amzn.yml b/buildspecs/pr-build-amzn.yml index 40047354cc..797d004aac 100644 --- a/buildspecs/pr-build-amzn.yml +++ b/buildspecs/pr-build-amzn.yml @@ -8,7 +8,7 @@ env: phases: install: commands: - # Same buildspec used for different Amazon Linuc versions - detect verison to use in Go installation + # Same buildspec used for different Amazon Linux versions - detect verison to use in Go installation - | if [ -f /etc/os-release ]; then . /etc/os-release @@ -41,25 +41,30 @@ phases: esac # Identify the correct AL2023 version to use in the Go installation + # Ref: https://docs.aws.amazon.com/linux/al2023/ug/managing-repos-os-updates.html + # xmllint is required to find the latest distribution release from releasemd.xml in us-west-2 - AL23_VERSION="$(curl -s https://al2023-repos-us-west-2-de612dc2.s3.dualstack.us-west-2.amazonaws.com/core/releasemd.xml | xmllint --xpath "string(//root/releases/release[last()]/@version)" -)" - AGENT_VERSION=$(cat VERSION) # Need to install GOLANG explicitly as required versions do not come preinstalled - # Remove existing go installation (goenv utility) and install downloaded binaries + # Remove existing go installation (goenv utility) - sudo rm -rf /root/.goenv - sudo rm -rf /usr/local/go/bin/go - # Install dependencies and define variables based on the build image used + # Define the Go version to install + - GOVERSION="$(cat GO_VERSION)" + + # Install Go and define variables based on Amazon Linux version (2 or 2023) # Amazon Linux 2023 uses package manager DNF, while older versions use YUM # Set the appropriate AL23 version echo string to include in build log - | if [[ "$amzn_version" = "amzn2023" ]]; then sudo dnf --releasever="$AL23_VERSION" update -y - sudo yum install -y golang + sudo yum install -y golang-$GOVERSION amzn_version="amzn2023" al23_version_echo="Amazon Linux 2023 Version: $AL23_VERSION" elif [[ "$amzn_version" = "amzn2" ]]; then - sudo yum install -y golang + sudo yum install -y golang-$GOVERSION amzn_version="amzn2" al23_version_echo="" else