generated from devcontainers-community/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
50 lines (41 loc) · 1.22 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -euo pipefail
source lib.sh
check_packages curl ca-certificates
apt_cleanup
echo "Installing Bazel"
LOCAL_BIN="/usr/local/bin"
github_download() {
repo=$1
version=$2
artifact=$3
output=$4
if [ "${version}" = "latest" ]; then
URL="https://github.com/${repo}/releases/latest/download/${artifact}"
else
URL="https://github.com/${repo}/releases/download/${version}/${artifact}"
fi
curl -fSsL "${URL}" -o "${output}"
}
arch="$(uname -m)"
case "${arch}" in
x86_64) ARCHITECTURE=amd64 ;;
aarch64 | arm64 | armv8*) ARCHITECTURE=arm64 ;;
*)
echo -e "Unsupported '$arch' architecture"
exit 1
esac
platf="$(uname -s)"
case "${platf}" in
Linux) PLATFORM=linux ;;
Darwin) PLATFORM=darwin ;;
*)
echo -e "Unsupported '$platf' platform"
exit 1
esac
github_download "bazelbuild/bazelisk" "${BAZELISK_VERSION}" "bazelisk-${PLATFORM}-${ARCHITECTURE}" "${LOCAL_BIN}/bazelisk"
chmod +x "${LOCAL_BIN}/bazelisk"
ln -s "${LOCAL_BIN}/bazelisk" "${LOCAL_BIN}/bazel"
github_download "bazelbuild/buildtools" "${BUILDIFIER_VERSION}" "buildifier-${PLATFORM}-${ARCHITECTURE}" "${LOCAL_BIN}/buildifier"
chmod +x "${LOCAL_BIN}/buildifier"
echo "Done"