From a6ad9e04ee2a3537a23aa9110a37079bad237b31 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Sat, 25 Feb 2023 12:35:57 -0800 Subject: [PATCH] Rewrite install-protobuf script Signed-off-by: Maksym Pavlenko --- script/setup/install-protobuf | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/script/setup/install-protobuf b/script/setup/install-protobuf index 5a397a184..169a62142 100755 --- a/script/setup/install-protobuf +++ b/script/setup/install-protobuf @@ -25,6 +25,7 @@ PROTOBUF_DIR=$(mktemp -d) # Use `go tool dist list` for the full list of targets TARGET="$(go env GOOS)-$(go env GOARCH)" +TARGET_ORIG=$TARGET # Fix up OS/ARCH to get proper download link for https://github.com/protocolbuffers/protobuf/releases @@ -41,20 +42,22 @@ 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 +if [[ $TARGET != $TARGET_ORIG ]] +then + 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 +else + # Build from source + 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 +fi rm -rf "$PROTOBUF_DIR"