From 3769b4840b99dc59f4a2f097149b9f88dcaf511d Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Sat, 25 Feb 2023 11:47:48 -0800 Subject: [PATCH] Rewrite install-protobuf script Signed-off-by: Maksym Pavlenko --- script/setup/install-protobuf | 63 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/script/setup/install-protobuf b/script/setup/install-protobuf index de1d31f43..5a397a184 100755 --- a/script/setup/install-protobuf +++ b/script/setup/install-protobuf @@ -21,44 +21,41 @@ set -eu -o pipefail PROTOBUF_VERSION=3.20.1 -GOARCH=$(go env GOARCH) -GOOS=$(go env GOOS) PROTOBUF_DIR=$(mktemp -d) -case $GOARCH in +# Use `go tool dist list` for the full list of targets +TARGET="$(go env GOOS)-$(go env GOARCH)" -arm64) - wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-aarch_64.zip" - unzip "$PROTOBUF_DIR/protobuf" -d /usr/local - ;; +# Fix up OS/ARCH to get proper download link for https://github.com/protocolbuffers/protobuf/releases -amd64|386) - if [ "$GOOS" = windows ]; then - wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-win32.zip" - elif [ "$GOOS" = linux ]; then - wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-x86_64.zip" - elif [ "$GOOS" == darwin ]; then - wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-osx-x86_64.zip" - fi - unzip "$PROTOBUF_DIR/protobuf" -d /usr/local - ;; +# Darwin +TARGET=${TARGET/darwin-amd64/osx-x86_64} +TARGET=${TARGET/darwin-arm64/osx-aarch_64} + +# Windows +TARGET=${TARGET/windows-amd64/win64} +TARGET=${TARGET/windows-386/win32} + +# Linux +TARGET=${TARGET/linux-386/linux-x86_32} +TARGET=${TARGET/linux-amd64/linux-x86_64} +TARGET=${TARGET/linux-ppc64le/linux-ppcle_64} + +wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-$TARGET.zip" +unzip "$PROTOBUF_DIR/protobuf" -d /usr/local + +wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-cpp-$PROTOBUF_VERSION.zip" +unzip "$PROTOBUF_DIR/protobuf" -d /usr/src/protobuf + +cd "/usr/src/protobuf/protobuf-$PROTOBUF_VERSION" +./autogen.sh +./configure --disable-shared + +make +make check +make install +ldconfig -ppc64le) - wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-linux-ppcle_64.zip" - unzip "$PROTOBUF_DIR/protobuf" -d /usr/local - ;; -*) - wget -O "$PROTOBUF_DIR/protobuf" "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protobuf-cpp-$PROTOBUF_VERSION.zip" - unzip "$PROTOBUF_DIR/protobuf" -d /usr/src/protobuf - cd "/usr/src/protobuf/protobuf-$PROTOBUF_VERSION" - ./autogen.sh - ./configure --disable-shared - make - make check - make install - ldconfig - ;; -esac rm -rf "$PROTOBUF_DIR" # Download status.proto. grpc repos' one seems copied from