forked from thanos-io/thanos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallprotoc.sh
executable file
·59 lines (49 loc) · 1.24 KB
/
installprotoc.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
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
#
# Install the standard protocol buffer implementation - protoc.
set -e
set -u
PROTOC_VERSION=${PROTOC_VERSION:-3.4.0}
TMP_GOPATH=${TMP_GOPATH:-/tmp/thanos-go}
PROTOC_DOWNLOAD_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}"
OS=$(go env GOOS)
ARCH=$(go env GOARCH)
PLATFORM="${OS}/${ARCH}"
is_supported_platform() {
platform=$1
found=1
case "$platform" in
darwin/amd64) found=0 ;;
darwin/i386) found=0 ;;
linux/amd64) found=0 ;;
linux/i386) found=0 ;;
linux/arm64) found=0 ;;
esac
return $found
}
adjust_os() {
case ${OS} in
darwin) OS=osx ;;
esac
true
}
adjust_arch() {
case ${ARCH} in
amd64) ARCH=x86_64 ;;
i386) ARCH=x86_32 ;;
arm64) ARCH=aarch_64 ;;
esac
true
}
mkdir -p ${TMP_GOPATH}
is_supported_platform "$PLATFORM"
if [[ $? -eq 1 ]]; then
echo "platform $PLATFORM is not supported. See https://github.com/protocolbuffers/protobuf/releases for details"
exit 1
fi
adjust_os
adjust_arch
PACKAGE="protoc-${PROTOC_VERSION}-${OS}-${ARCH}.zip"
PACKAGE_DOWNLOAD_URL="${PROTOC_DOWNLOAD_URL}/${PACKAGE}"
curl -LSs ${PACKAGE_DOWNLOAD_URL} -o ${TMP_GOPATH}/${PACKAGE}
unzip -qqj ${TMP_GOPATH}/${PACKAGE} "bin/protoc" -d "${TMP_GOPATH}/bin/"