forked from thanos-io/thanos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed make proto Signed-off-by: jojohappy <[email protected]> * Address review comments Signed-off-by: jojohappy <[email protected]> * Change the download destination of protoc package Signed-off-by: jojohappy <[email protected]> * Rollback && simplify the code Signed-off-by: jojohappy <[email protected]> * Fixed temporary dir doesn't exist Signed-off-by: jojohappy <[email protected]> * To install protoc command only suuportting linux or macosx Signed-off-by: jojohappy <[email protected]> * Update docs Signed-off-by: jojohappy <[email protected]>
- Loading branch information
Showing
4 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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/" |