Skip to content

Commit e40699e

Browse files
committed
install.sh : support build on amd64 and arm64
The build platform mostly depends on golang
1 parent 5256a2d commit e40699e

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

assets/build/install.sh

+20-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ RUBY_SRC_URL=https://cache.ruby-lang.org/pub/ruby/${RUBY_VERSION%.*}/ruby-${RUBY
1414

1515
GEM_CACHE_DIR="${GITLAB_BUILD_DIR}/cache"
1616

17+
# check system platform
18+
# TODO: cover as many variations as possible (depending on the platform supported by golang)
19+
case "$(uname -m)" in
20+
"x86_64")
21+
PLATFORM_NAME="amd64"
22+
;;
23+
"aarch64")
24+
PLATFORM_NAME="arm64"
25+
;;
26+
*)
27+
echo "The platform not supported ($(uname -a))"
28+
exit 1
29+
esac
30+
31+
GOLANG_ARCHIVE="go${GOLANG_VERSION}.linux-${PLATFORM_NAME}.tar.gz"
32+
1733
GOROOT=/tmp/go
1834
PATH=${GOROOT}/bin:$PATH
1935

@@ -97,9 +113,9 @@ BUNDLER_VERSION="$(grep "BUNDLED WITH" ${GITLAB_INSTALL_DIR}/Gemfile.lock -A 1 |
97113
gem install bundler:"${BUNDLER_VERSION}"
98114

99115
# download golang
100-
echo "Downloading Go ${GOLANG_VERSION}..."
101-
wget -cnv https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-amd64.tar.gz -P ${GITLAB_BUILD_DIR}/
102-
tar -xf ${GITLAB_BUILD_DIR}/go${GOLANG_VERSION}.linux-amd64.tar.gz -C /tmp/
116+
echo "Downloading Go ${GOLANG_VERSION} for ${PLATFORM_NAME} (${PLATFORM})..."
117+
wget -cnv https://storage.googleapis.com/golang/${GOLANG_ARCHIVE} -P ${GITLAB_BUILD_DIR}/
118+
tar -xf ${GITLAB_BUILD_DIR}/${GOLANG_ARCHIVE} -C /tmp/
103119

104120
# install gitlab-shell
105121
echo "Downloading gitlab-shell v.${GITLAB_SHELL_VERSION}..."
@@ -159,7 +175,7 @@ rm -rf ${GITLAB_GITALY_BUILD_DIR}
159175

160176
# remove go
161177
go clean --modcache
162-
rm -rf ${GITLAB_BUILD_DIR}/go${GOLANG_VERSION}.linux-amd64.tar.gz ${GOROOT}
178+
rm -rf ${GITLAB_BUILD_DIR:?}/${GOLANG_ARCHIVE} ${GOROOT}
163179

164180
# remove HSTS config from the default headers, we configure it in nginx
165181
exec_as_git sed -i "/headers\['Strict-Transport-Security'\]/d" ${GITLAB_INSTALL_DIR}/app/controllers/application_controller.rb

0 commit comments

Comments
 (0)