github.com/thanos-io/thanos@v0.32.5/scripts/installprotoc.sh (about) 1 #!/usr/bin/env bash 2 # 3 # Install the standard protocol buffer implementation - protoc. 4 set -e 5 set -u 6 7 PROTOC_VERSION=${PROTOC_VERSION:-3.20.1} 8 TMP_GOPATH=${TMP_GOPATH:-/tmp/thanos-go} 9 PROTOC_DOWNLOAD_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}" 10 11 OS=$(go env GOOS) 12 ARCH=$(go env GOARCH) 13 PLATFORM="${OS}/${ARCH}" 14 15 is_supported_platform() { 16 platform=$1 17 found=1 18 case "$platform" in 19 darwin/arm64) found=0 ;; 20 darwin/amd64) found=0 ;; 21 darwin/i386) found=0 ;; 22 linux/amd64) found=0 ;; 23 linux/i386) found=0 ;; 24 linux/arm64) found=0 ;; 25 linux/ppc64le) found=0 ;; 26 esac 27 return $found 28 } 29 30 adjust_os() { 31 case ${OS} in 32 darwin) OS=osx ;; 33 esac 34 true 35 } 36 37 adjust_arch() { 38 case ${ARCH} in 39 amd64) ARCH=x86_64 ;; 40 i386) ARCH=x86_32 ;; 41 arm64) ARCH=aarch_64 ;; 42 ppc64le) ARCH=ppcle_64 ;; 43 esac 44 true 45 } 46 47 mkdir -p ${TMP_GOPATH} 48 49 is_supported_platform "$PLATFORM" 50 if [[ $? -eq 1 ]]; then 51 echo "platform $PLATFORM is not supported. See https://github.com/protocolbuffers/protobuf/releases for details" 52 exit 1 53 fi 54 55 adjust_os 56 57 adjust_arch 58 59 PACKAGE="protoc-${PROTOC_VERSION}-${OS}-${ARCH}.zip" 60 PACKAGE_DOWNLOAD_URL="${PROTOC_DOWNLOAD_URL}/${PACKAGE}" 61 curl -LSs ${PACKAGE_DOWNLOAD_URL} -o ${TMP_GOPATH}/${PACKAGE} 62 unzip -qqj ${TMP_GOPATH}/${PACKAGE} "bin/protoc" -d "${TMP_GOPATH}/bin/"