From 77ac3347bea6eb72fc7ba887896e02276cea51ec Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Tue, 28 May 2024 12:09:54 +0530 Subject: [PATCH] Responded to Arvind's comment --- scripts/install_protoc.sh | 24 ++++++++++++------------ scripts/regenerate.sh | 7 +++---- scripts/vet-proto.sh | 13 +++++-------- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/scripts/install_protoc.sh b/scripts/install_protoc.sh index 127150496e21..e849dd400fe1 100755 --- a/scripts/install_protoc.sh +++ b/scripts/install_protoc.sh @@ -17,8 +17,7 @@ set -eu -o pipefail source "$(dirname $0)/vet-common.sh" -# Perform installation of protoc from source based on OS. - +# The version of protoc that will be installed. PROTOC_VERSION="25.2" # Function to download pre-built binaries for Linux with @@ -32,7 +31,7 @@ download_binary() { return else echo "Existing protoc version ($installed_version) differs. Kindly make sure you have $PROTOC_VERSION installed." -# exit 1 + exit 1 fi else echo "Unable to determine installed protoc version. Starting the installation." @@ -46,18 +45,19 @@ download_binary() { rm "protoc-${PROTOC_VERSION}-$2-$1.zip" } -# Determine architecture -if [[ $(uname -m) == "x86_64" ]]; then - ARCH="x86_64" -elif [[ $(uname -m) == "aarch64" ]] || [[ $(uname -m) == "arm64" ]] ; then - ARCH="aarch_64" -else - die "Unsupported architecture. Please consider manual installation." -fi +# Detect the architecture +case "$(uname -m)" in + "x86_64") ARCH="x86_64";; + "aarch64") ARCH="aarch_64";; + "arm64") ARCH="aarch_64";; +*) die "Unsupported architecture. Please consider manual installation from \ + https://github.com/protocolbuffers/protobuf/releases/ and add to PATH." +esac + # Detect the Operating System case "$(uname -s)" in "Darwin") download_binary $ARCH "osx" "$1";; "Linux") download_binary $ARCH "linux" "$1";; -*) echo "Please consider manual installation from \ +*) die "Unsupported OS. Please consider manual installation from \ https://github.com/protocolbuffers/protobuf/releases/ and add to PATH" ;; esac diff --git a/scripts/regenerate.sh b/scripts/regenerate.sh index 1c14d69a9a18..afece6530e41 100755 --- a/scripts/regenerate.sh +++ b/scripts/regenerate.sh @@ -20,13 +20,13 @@ WORKDIR=$(mktemp -d) function finish { rm -rf "$WORKDIR" # Revert back the PATH to client's original value - export PATH=$RESTORED_PATH - echo "Restored PATH to older value: $PATH" + export PATH=$ORIGINAL_PATH + echo "Restored PATH variable to original value." } trap finish EXIT GOBIN="${WORKDIR}"/bin -RESTORED_PATH=$PATH +ORIGINAL_PATH=$PATH export PATH="${GOBIN}:${PATH}" mkdir -p "${GOBIN}" @@ -52,7 +52,6 @@ mkdir -p "${WORKDIR}/googleapis/google/rpc" echo "curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto" curl --silent https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto > "${WORKDIR}/googleapis/google/rpc/code.proto" -#chmod +x ./scripts/install_protoc.sh source ./scripts/install_protoc.sh $WORKDIR mkdir -p "${WORKDIR}/out" diff --git a/scripts/vet-proto.sh b/scripts/vet-proto.sh index 89cd2e2757d9..f3ecbd4b84ec 100755 --- a/scripts/vet-proto.sh +++ b/scripts/vet-proto.sh @@ -20,14 +20,11 @@ trap cleanup EXIT # consistent with the place where all binaries installed by scripts in this repo # go.) if [[ "$1" = "-install" ]]; then - if [[ "${GITHUB_ACTIONS}" = "true" ]]; then - PROTOBUF_VERSION=25.2 # Shows up in pb.go files as v4.22.0 - PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip - source ./scripts/install_protoc.sh "/home/runner/go" - else - # TODO: replace with install protoc when https://github.com/grpc/grpc-go/pull/7064 is merged. - die "-install currently intended for use in CI only." - fi + if [[ "${GITHUB_ACTIONS}" = "true" ]]; then + source ./scripts/install_protoc.sh "/home/runner/go" + else + die "run protoc installer https://github.com/grpc/grpc-go/scripts/install_protoc.sh." + fi echo SUCCESS exit 0 elif [[ "$#" -ne 0 ]]; then