mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-09 10:02:56 +01:00
48 lines
1.5 KiB
Bash
Executable file
48 lines
1.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -xeou pipefail
|
|
|
|
INSTALL_GOLANG_VERSION=${1}
|
|
GOLANG_DOWNLOAD_SHA256=${2}
|
|
|
|
GOLANG_DOWNLOAD_URL="https://golang.org/dl/go${INSTALL_GOLANG_VERSION}.linux-${BUILD_ARCH}.tar.gz"
|
|
|
|
function build_debian() {
|
|
curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz
|
|
echo "${GOLANG_DOWNLOAD_SHA256} golang.tar.gz" | sha256sum -c -
|
|
tar -C /usr/local -xzf golang.tar.gz
|
|
rm golang.tar.gz
|
|
}
|
|
|
|
function build_ubi() {
|
|
GO_MAJOR_VERSION=${INSTALL_GOLANG_VERSION%.*}
|
|
GOLANG_FIPS_BRANCH="go${GO_MAJOR_VERSION}-openssl-fips"
|
|
|
|
mkdir -p /tmp/golang
|
|
curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz
|
|
echo "${GOLANG_DOWNLOAD_SHA256} golang.tar.gz" | sha256sum -c -
|
|
tar -C /tmp/golang -xzf golang.tar.gz
|
|
|
|
# For UBI, we will be installing golang-fips
|
|
git clone https://github.com/golang-fips/go.git --branch ${GOLANG_FIPS_BRANCH} --single-branch --depth 1 /usr/local/go
|
|
|
|
cd /usr/local/go/src
|
|
|
|
PATH=$PATH:/tmp/golang/go/bin CGO_ENABLED=1 ./make.bash
|
|
|
|
rm -rf /usr/local/go/pkg/*/cmd /usr/local/go/pkg/bootstrap \
|
|
/usr/local/go/pkg/obj /usr/local/go/pkg/tool/*/api \
|
|
/usr/local/go/pkg/tool/*/go_bootstrap /usr/local/go/src/cmd/dist/dist \
|
|
/usr/local/go/.git* /tmp/golang
|
|
|
|
ln -sf /usr/local/go/bin/go /usr/local/go/bin/gofmt /usr/local/go/bin/godoc /usr/local/bin/
|
|
}
|
|
|
|
|
|
BUILD_OS=${BUILD_OS:-debian}
|
|
|
|
if [[ $BUILD_OS =~ debian ]]; then
|
|
build_debian "$@"
|
|
elif [[ $BUILD_OS =~ ubi ]]; then
|
|
build_ubi "$@"
|
|
fi
|