From 98b1c93720c474f45c5ae2a8346be80ae2391d07 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Mon, 8 Apr 2024 11:47:53 +0530 Subject: [PATCH 01/21] Resolved Merge Conflicts --- Makefile | 2 +- doc.go | 2 +- scripts/protoc_installer.sh | 40 ++++++++++++ regenerate.sh => scripts/regenerate.sh | 85 +++++++++++++++----------- scripts/vet.sh | 17 ++++++ 5 files changed, 108 insertions(+), 38 deletions(-) create mode 100644 scripts/protoc_installer.sh rename regenerate.sh => scripts/regenerate.sh (59%) diff --git a/Makefile b/Makefile index be38384ff6fe..44944f0ca9f6 100644 --- a/Makefile +++ b/Makefile @@ -46,4 +46,4 @@ vetdeps: testrace \ testdeps \ vet \ - vetdeps + vetdeps \ No newline at end of file diff --git a/doc.go b/doc.go index 0022859ad746..e7b532b6f806 100644 --- a/doc.go +++ b/doc.go @@ -16,7 +16,7 @@ * */ -//go:generate ./regenerate.sh +//go:generate ./scripts/regenerate.sh /* Package grpc implements an RPC system called gRPC. diff --git a/scripts/protoc_installer.sh b/scripts/protoc_installer.sh new file mode 100644 index 000000000000..38b5a3373e8b --- /dev/null +++ b/scripts/protoc_installer.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Install protoc +echo "Installing protoc" +PROTOC_VERSION="25.2" +echo "Protobuf version: ${PROTOC_VERSION}" + +# Function to download pre-built binaries for Linux +download_binary() { + echo "Attempting to download pre-built libprotoc ${PROTOC_VERSION} binary." + + # Download URL (adjust if a newer release is available) + DOWNLOAD_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-$2-$1.zip" + echo "Download URL: ${DOWNLOAD_URL}" + + # Download and unzip + curl -LO "$DOWNLOAD_URL" + echo "Downloaded" + INSTALL_DIR="${3:-/home/runner/go}" + unzip "protoc-${PROTOC_VERSION}-$2-$1.zip" -d $INSTALL_DIR + rm "protoc-${PROTOC_VERSION}-$2-$1.zip" +} + +download_protoc() { + # Determine architecture + if [[ $(uname -m) == "x86_64" ]]; then + ARCH="x86_64" + elif [[ $(uname -m) == "aarch64" ]] || [[ $(uname -m) == "arm64" ]] ; then + ARCH="aarch_64" + else + echo "Unsupported architecture. Please consider manual installation." + return + fi + # Detect the Operating System + OS=$(uname -s) + case "$OS" in + "Darwin") download_binary $ARCH "osx" "${WORKDIR:-.}";; + "Linux") download_binary $ARCH "linux" $1;; + *) echo "Unsupported operating system. Please consider manual installation." ;; + esac +} \ No newline at end of file diff --git a/regenerate.sh b/scripts/regenerate.sh similarity index 59% rename from regenerate.sh rename to scripts/regenerate.sh index 3edca296c224..8e69bdf205ac 100755 --- a/regenerate.sh +++ b/scripts/regenerate.sh @@ -15,16 +15,16 @@ set -eu -o pipefail -WORKDIR=$(mktemp -d) +export WORKDIR=$(mktemp -d) function finish { rm -rf "$WORKDIR" } trap finish EXIT -export GOBIN=${WORKDIR}/bin -export PATH=${GOBIN}:${PATH} -mkdir -p ${GOBIN} +export GOBIN="${WORKDIR}"/bin +export PATH="${GOBIN}:${PATH}" +mkdir -p "${GOBIN}" echo "remove existing generated files" # grpc_testing_not_regenerate/*.pb.go is not re-generated, @@ -38,39 +38,52 @@ echo "go install cmd/protoc-gen-go-grpc" (cd cmd/protoc-gen-go-grpc && go install .) echo "git clone https://github.com/grpc/grpc-proto" -git clone --quiet https://github.com/grpc/grpc-proto ${WORKDIR}/grpc-proto +git clone --quiet https://github.com/grpc/grpc-proto "${WORKDIR}"/grpc-proto echo "git clone https://github.com/protocolbuffers/protobuf" -git clone --quiet https://github.com/protocolbuffers/protobuf ${WORKDIR}/protobuf +git clone --quiet https://github.com/protocolbuffers/protobuf "${WORKDIR}"/protobuf # Pull in code.proto as a proto dependency -mkdir -p ${WORKDIR}/googleapis/google/rpc +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 +curl --silent https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto > "${WORKDIR}"/googleapis/google/rpc/code.proto -mkdir -p ${WORKDIR}/out +source ./scripts/protoc_installer.sh +download_protoc + +export PATH="$PATH:$GOBIN" + +PROTOC_PATH="/usr/local/bin" +if [[ ":$PATH:" != *":$PROTOC_PATH:"* ]]; then + export PATH="$PATH:$PROTOC_PATH" + echo "protoc added to your PATH. You might need to open a new terminal" +else + echo "protoc already appears to be on your PATH" +fi + +mkdir -p "${WORKDIR}/out" # Generates sources without the embed requirement LEGACY_SOURCES=( - ${WORKDIR}/grpc-proto/grpc/binlog/v1/binarylog.proto - ${WORKDIR}/grpc-proto/grpc/channelz/v1/channelz.proto - ${WORKDIR}/grpc-proto/grpc/health/v1/health.proto - ${WORKDIR}/grpc-proto/grpc/lb/v1/load_balancer.proto + "${WORKDIR}/grpc-proto/grpc/binlog/v1/binarylog.proto" + "${WORKDIR}/grpc-proto/grpc/channelz/v1/channelz.proto" + "${WORKDIR}/grpc-proto/grpc/health/v1/health.proto" + "${WORKDIR}/grpc-proto/grpc/lb/v1/load_balancer.proto" profiling/proto/service.proto - ${WORKDIR}/grpc-proto/grpc/reflection/v1alpha/reflection.proto - ${WORKDIR}/grpc-proto/grpc/reflection/v1/reflection.proto + "${WORKDIR}/grpc-proto/grpc/reflection/v1alpha/reflection.proto" + "${WORKDIR}/grpc-proto/grpc/reflection/v1/reflection.proto" ) # Generates only the new gRPC Service symbols SOURCES=( - $(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^profiling/proto/service.proto$') - ${WORKDIR}/grpc-proto/grpc/gcp/altscontext.proto - ${WORKDIR}/grpc-proto/grpc/gcp/handshaker.proto - ${WORKDIR}/grpc-proto/grpc/gcp/transport_security_common.proto - ${WORKDIR}/grpc-proto/grpc/lookup/v1/rls.proto - ${WORKDIR}/grpc-proto/grpc/lookup/v1/rls_config.proto - ${WORKDIR}/grpc-proto/grpc/testing/*.proto - ${WORKDIR}/grpc-proto/grpc/core/*.proto + $(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^\(profiling/proto/service.proto\|reflection/grpc_reflection_v1alpha/reflection.proto\)$') + "${WORKDIR}/grpc-proto/grpc/gcp/altscontext.proto" + "${WORKDIR}/grpc-proto/grpc/gcp/handshaker.proto" + "${WORKDIR}/grpc-proto/grpc/gcp/transport_security_common.proto" + "${WORKDIR}/grpc-proto/grpc/lookup/v1/rls.proto" + "${WORKDIR}/grpc-proto/grpc/lookup/v1/rls_config.proto" + "${WORKDIR}/grpc-proto/grpc/testing/*.proto" + "${WORKDIR}/grpc-proto/grpc/core/*.proto" ) # These options of the form 'Mfoo.proto=bar' instruct the codegen to use an @@ -95,29 +108,29 @@ for src in ${SOURCES[@]}; do echo "protoc ${src}" protoc --go_out=${OPTS}:${WORKDIR}/out --go-grpc_out=${OPTS},use_generic_streams_experimental=true:${WORKDIR}/out \ -I"." \ - -I${WORKDIR}/grpc-proto \ - -I${WORKDIR}/googleapis \ - -I${WORKDIR}/protobuf/src \ - ${src} + -I"${WORKDIR}/grpc-proto" \ + -I"${WORKDIR}/googleapis" \ + -I"${WORKDIR}/protobuf/src" \ + "${src}" done for src in ${LEGACY_SOURCES[@]}; do echo "protoc ${src}" - protoc --go_out=${OPTS}:${WORKDIR}/out --go-grpc_out=${OPTS},require_unimplemented_servers=false:${WORKDIR}/out \ + protoc --go_out="${OPTS}:${WORKDIR}"/out --go-grpc_out="${OPTS}",require_unimplemented_servers=false:"${WORKDIR}/out" \ -I"." \ - -I${WORKDIR}/grpc-proto \ - -I${WORKDIR}/googleapis \ - -I${WORKDIR}/protobuf/src \ - ${src} + -I"${WORKDIR}/grpc-proto" \ + -I"${WORKDIR}/googleapis" \ + -I"${WORKDIR}/protobuf/src" \ + "${src}" done # The go_package option in grpc/lookup/v1/rls.proto doesn't match the # current location. Move it into the right place. -mkdir -p ${WORKDIR}/out/google.golang.org/grpc/internal/proto/grpc_lookup_v1 -mv ${WORKDIR}/out/google.golang.org/grpc/lookup/grpc_lookup_v1/* ${WORKDIR}/out/google.golang.org/grpc/internal/proto/grpc_lookup_v1 +mkdir -p "${WORKDIR}/out/google.golang.org/grpc/internal/proto/grpc_lookup_v1" +mv "${WORKDIR}"/out/google.golang.org/grpc/lookup/grpc_lookup_v1/* "${WORKDIR}"/out/google.golang.org/grpc/internal/proto/grpc_lookup_v1 # grpc_testing_not_regenerate/*.pb.go are not re-generated, # see grpc_testing_not_regenerate/README.md for details. -rm ${WORKDIR}/out/google.golang.org/grpc/reflection/test/grpc_testing_not_regenerate/*.pb.go +rm "${WORKDIR}"/out/google.golang.org/grpc/reflection/test/grpc_testing_not_regenerate/*.pb.go -cp -R ${WORKDIR}/out/google.golang.org/grpc/* . +cp -R "${WORKDIR}"/out/google.golang.org/grpc/* . diff --git a/scripts/vet.sh b/scripts/vet.sh index f5806f1cd0ce..07c32faa74a8 100755 --- a/scripts/vet.sh +++ b/scripts/vet.sh @@ -32,6 +32,23 @@ if [[ "$1" = "-install" ]]; then honnef.co/go/tools/cmd/staticcheck \ github.com/client9/misspell/cmd/misspell popd + if [[ -z "${VET_SKIP_PROTO}" ]]; then +<<<<<<< HEAD + source ./scripts/protoc_installer.sh + download_protoc + protoc --version +======= + if [[ "${GITHUB_ACTIONS}" = "true" ]]; then + source ./scripts/protoc_installer.sh + pushd /home/runner/go + download_protoc + bin/protoc --version + popd + elif not which protoc > /dev/null; then + die "Please install protoc into your path" + fi +>>>>>>> beb91247 (Migrate all the shell scripts to scripts directory) + fi exit 0 elif [[ "$#" -ne 0 ]]; then die "Unknown argument(s): $*" From c9cbdcf3c1b834581fb03cdcbc1eaf8f36402a32 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Tue, 2 Apr 2024 11:18:51 +0530 Subject: [PATCH 02/21] Fix comments --- scripts/regenerate.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/regenerate.sh b/scripts/regenerate.sh index 8e69bdf205ac..e4ebd2c22741 100755 --- a/scripts/regenerate.sh +++ b/scripts/regenerate.sh @@ -38,13 +38,13 @@ echo "go install cmd/protoc-gen-go-grpc" (cd cmd/protoc-gen-go-grpc && go install .) echo "git clone https://github.com/grpc/grpc-proto" -git clone --quiet https://github.com/grpc/grpc-proto "${WORKDIR}"/grpc-proto +git clone --quiet https://github.com/grpc/grpc-proto "${WORKDIR}/grpc-proto" echo "git clone https://github.com/protocolbuffers/protobuf" -git clone --quiet https://github.com/protocolbuffers/protobuf "${WORKDIR}"/protobuf +git clone --quiet https://github.com/protocolbuffers/protobuf "${WORKDIR}/protobuf" # Pull in code.proto as a proto dependency -mkdir -p "${WORKDIR}"/googleapis/google/rpc +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 @@ -116,7 +116,7 @@ done for src in ${LEGACY_SOURCES[@]}; do echo "protoc ${src}" - protoc --go_out="${OPTS}:${WORKDIR}"/out --go-grpc_out="${OPTS}",require_unimplemented_servers=false:"${WORKDIR}/out" \ + protoc --go_out="${OPTS}:${WORKDIR}/out" --go-grpc_out="${OPTS}",require_unimplemented_servers=false:"${WORKDIR}/out" \ -I"." \ -I"${WORKDIR}/grpc-proto" \ -I"${WORKDIR}/googleapis" \ @@ -127,7 +127,7 @@ done # The go_package option in grpc/lookup/v1/rls.proto doesn't match the # current location. Move it into the right place. mkdir -p "${WORKDIR}/out/google.golang.org/grpc/internal/proto/grpc_lookup_v1" -mv "${WORKDIR}"/out/google.golang.org/grpc/lookup/grpc_lookup_v1/* "${WORKDIR}"/out/google.golang.org/grpc/internal/proto/grpc_lookup_v1 +mv "${WORKDIR}"/out/google.golang.org/grpc/lookup/grpc_lookup_v1/* "${WORKDIR}/out/google.golang.org/grpc/internal/proto/grpc_lookup_v1" # grpc_testing_not_regenerate/*.pb.go are not re-generated, # see grpc_testing_not_regenerate/README.md for details. From 0185eb1602ef43dd004ef22f6f39b0af782785e2 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan <159750762+aranjans@users.noreply.github.com> Date: Tue, 2 Apr 2024 11:35:00 +0530 Subject: [PATCH 03/21] Update scripts/protoc_installer.sh Co-authored-by: Arvind Bright --- scripts/protoc_installer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/protoc_installer.sh b/scripts/protoc_installer.sh index 38b5a3373e8b..d4e4d93050e4 100644 --- a/scripts/protoc_installer.sh +++ b/scripts/protoc_installer.sh @@ -37,4 +37,4 @@ download_protoc() { "Linux") download_binary $ARCH "linux" $1;; *) echo "Unsupported operating system. Please consider manual installation." ;; esac -} \ No newline at end of file +} From a309f73148e5307ab8f77d565b5d43ca276d2112 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan <159750762+aranjans@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:01:19 +0530 Subject: [PATCH 04/21] Update scripts/regenerate.sh Co-authored-by: Arvind Bright --- scripts/regenerate.sh | 2 +- scripts/vet.sh | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/scripts/regenerate.sh b/scripts/regenerate.sh index e4ebd2c22741..936b5d556a63 100755 --- a/scripts/regenerate.sh +++ b/scripts/regenerate.sh @@ -46,7 +46,7 @@ git clone --quiet https://github.com/protocolbuffers/protobuf "${WORKDIR}/protob # Pull in code.proto as a proto dependency 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 +curl --silent https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto > "${WORKDIR}/googleapis/google/rpc/code.proto" source ./scripts/protoc_installer.sh download_protoc diff --git a/scripts/vet.sh b/scripts/vet.sh index 07c32faa74a8..dc4d29e7b19b 100755 --- a/scripts/vet.sh +++ b/scripts/vet.sh @@ -33,21 +33,9 @@ if [[ "$1" = "-install" ]]; then github.com/client9/misspell/cmd/misspell popd if [[ -z "${VET_SKIP_PROTO}" ]]; then -<<<<<<< HEAD source ./scripts/protoc_installer.sh download_protoc protoc --version -======= - if [[ "${GITHUB_ACTIONS}" = "true" ]]; then - source ./scripts/protoc_installer.sh - pushd /home/runner/go - download_protoc - bin/protoc --version - popd - elif not which protoc > /dev/null; then - die "Please install protoc into your path" - fi ->>>>>>> beb91247 (Migrate all the shell scripts to scripts directory) fi exit 0 elif [[ "$#" -ne 0 ]]; then From 61bb0b27d7ed0e69fb8ebf00eaafd447cbfcdb52 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Thu, 4 Apr 2024 15:15:52 +0530 Subject: [PATCH 05/21] Remove export WORKDIR --- scripts/regenerate.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/regenerate.sh b/scripts/regenerate.sh index 936b5d556a63..3d86411fca82 100755 --- a/scripts/regenerate.sh +++ b/scripts/regenerate.sh @@ -15,7 +15,7 @@ set -eu -o pipefail -export WORKDIR=$(mktemp -d) +WORKDIR=$(mktemp -d) function finish { rm -rf "$WORKDIR" @@ -49,7 +49,7 @@ echo "curl https://raw.githubusercontent.com/googleapis/googleapis/master/google curl --silent https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto > "${WORKDIR}/googleapis/google/rpc/code.proto" source ./scripts/protoc_installer.sh -download_protoc +download_protoc $WORKDIR export PATH="$PATH:$GOBIN" @@ -93,6 +93,7 @@ SOURCES=( # Note that the protos listed here are all for testing purposes. All protos to # be used externally should have a go_package option (and they don't need to be # listed here). +# listed here). OPTS=Mgrpc/core/stats.proto=google.golang.org/grpc/interop/grpc_testing/core,\ Mgrpc/testing/benchmark_service.proto=google.golang.org/grpc/interop/grpc_testing,\ Mgrpc/testing/stats.proto=google.golang.org/grpc/interop/grpc_testing,\ From 33534c320d1fa4be430c99288b55dc4057b2697a Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Wed, 10 Apr 2024 11:33:50 +0530 Subject: [PATCH 06/21] Resolved comments --- scripts/protoc_installer.sh | 28 ++++++++++------------------ scripts/regenerate.sh | 12 +----------- scripts/vet-proto.sh | 6 +++++- scripts/vet.sh | 5 ----- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/scripts/protoc_installer.sh b/scripts/protoc_installer.sh index d4e4d93050e4..8772b1b07b72 100644 --- a/scripts/protoc_installer.sh +++ b/scripts/protoc_installer.sh @@ -1,40 +1,32 @@ #!/bin/bash # Install protoc -echo "Installing protoc" PROTOC_VERSION="25.2" -echo "Protobuf version: ${PROTOC_VERSION}" # Function to download pre-built binaries for Linux download_binary() { - echo "Attempting to download pre-built libprotoc ${PROTOC_VERSION} binary." - # Download URL (adjust if a newer release is available) DOWNLOAD_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-$2-$1.zip" - echo "Download URL: ${DOWNLOAD_URL}" - # Download and unzip curl -LO "$DOWNLOAD_URL" - echo "Downloaded" - INSTALL_DIR="${3:-/home/runner/go}" + INSTALL_DIR="${3:-${GOBIN:-${GOPATH:-$HOME/go}/bin}}" unzip "protoc-${PROTOC_VERSION}-$2-$1.zip" -d $INSTALL_DIR rm "protoc-${PROTOC_VERSION}-$2-$1.zip" } download_protoc() { # Determine architecture - if [[ $(uname -m) == "x86_64" ]]; then - ARCH="x86_64" - elif [[ $(uname -m) == "aarch64" ]] || [[ $(uname -m) == "arm64" ]] ; then - ARCH="aarch_64" - else - echo "Unsupported architecture. Please consider manual installation." - return - fi + 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 Operating System OS=$(uname -s) case "$OS" in - "Darwin") download_binary $ARCH "osx" "${WORKDIR:-.}";; + "Darwin") download_binary $ARCH "osx" "$1";; "Linux") download_binary $ARCH "linux" $1;; - *) echo "Unsupported operating system. Please consider manual installation." ;; + *) echo "Unsupported operating system. Please consider manual installation." ;; esac } diff --git a/scripts/regenerate.sh b/scripts/regenerate.sh index 3d86411fca82..98bc9d38e723 100755 --- a/scripts/regenerate.sh +++ b/scripts/regenerate.sh @@ -51,16 +51,6 @@ curl --silent https://raw.githubusercontent.com/googleapis/googleapis/master/goo source ./scripts/protoc_installer.sh download_protoc $WORKDIR -export PATH="$PATH:$GOBIN" - -PROTOC_PATH="/usr/local/bin" -if [[ ":$PATH:" != *":$PROTOC_PATH:"* ]]; then - export PATH="$PATH:$PROTOC_PATH" - echo "protoc added to your PATH. You might need to open a new terminal" -else - echo "protoc already appears to be on your PATH" -fi - mkdir -p "${WORKDIR}/out" # Generates sources without the embed requirement @@ -76,7 +66,7 @@ LEGACY_SOURCES=( # Generates only the new gRPC Service symbols SOURCES=( - $(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^\(profiling/proto/service.proto\|reflection/grpc_reflection_v1alpha/reflection.proto\)$') + $(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^profiling/proto/service.proto$') "${WORKDIR}/grpc-proto/grpc/gcp/altscontext.proto" "${WORKDIR}/grpc-proto/grpc/gcp/handshaker.proto" "${WORKDIR}/grpc-proto/grpc/gcp/transport_security_common.proto" diff --git a/scripts/vet-proto.sh b/scripts/vet-proto.sh index 26c1ac65885a..76c35a1c0f45 100755 --- a/scripts/vet-proto.sh +++ b/scripts/vet-proto.sh @@ -28,7 +28,11 @@ if [[ "$1" = "-install" ]]; then unzip ${PROTOC_FILENAME} protoc --version # Check that the binary works. popd - else + elif [[ -z "${VET_SKIP_PROTO}" ]]; then + source ./scripts/protoc_installer.sh + download_protoc + protoc --version + 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 diff --git a/scripts/vet.sh b/scripts/vet.sh index dc4d29e7b19b..f5806f1cd0ce 100755 --- a/scripts/vet.sh +++ b/scripts/vet.sh @@ -32,11 +32,6 @@ if [[ "$1" = "-install" ]]; then honnef.co/go/tools/cmd/staticcheck \ github.com/client9/misspell/cmd/misspell popd - if [[ -z "${VET_SKIP_PROTO}" ]]; then - source ./scripts/protoc_installer.sh - download_protoc - protoc --version - fi exit 0 elif [[ "$#" -ne 0 ]]; then die "Unknown argument(s): $*" From 1ff5e4640217bea4b47de0f68a9f27ecb5eb145e Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan <159750762+aranjans@users.noreply.github.com> Date: Wed, 10 Apr 2024 11:49:26 +0530 Subject: [PATCH 07/21] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 44944f0ca9f6..be38384ff6fe 100644 --- a/Makefile +++ b/Makefile @@ -46,4 +46,4 @@ vetdeps: testrace \ testdeps \ vet \ - vetdeps \ No newline at end of file + vetdeps From 18505dea538ff3f722f1b8745b53599e36d5ba42 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Thu, 11 Apr 2024 22:03:59 +0530 Subject: [PATCH 08/21] Fix --- scripts/protoc_installer.sh | 6 ++++-- scripts/regenerate.sh | 5 ++--- scripts/vet-proto.sh | 4 ---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/scripts/protoc_installer.sh b/scripts/protoc_installer.sh index 8772b1b07b72..1ec2ca46e625 100644 --- a/scripts/protoc_installer.sh +++ b/scripts/protoc_installer.sh @@ -2,7 +2,8 @@ # Install protoc PROTOC_VERSION="25.2" -# Function to download pre-built binaries for Linux +# Function to download pre-built binaries for Linux with +# ARCH as $1, OS as $2, and WORKDIR as $3 arguments. download_binary() { # Download URL (adjust if a newer release is available) DOWNLOAD_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-$2-$1.zip" @@ -13,7 +14,8 @@ download_binary() { rm "protoc-${PROTOC_VERSION}-$2-$1.zip" } -download_protoc() { +# Function to install protoc with WORKDIR as argument +install_protoc() { # Determine architecture if [[ $(uname -m) == "x86_64" ]]; then ARCH="x86_64" diff --git a/scripts/regenerate.sh b/scripts/regenerate.sh index 98bc9d38e723..2b2a0dc586c9 100755 --- a/scripts/regenerate.sh +++ b/scripts/regenerate.sh @@ -22,7 +22,7 @@ function finish { } trap finish EXIT -export GOBIN="${WORKDIR}"/bin +GOBIN="${WORKDIR}"/bin export PATH="${GOBIN}:${PATH}" mkdir -p "${GOBIN}" @@ -49,7 +49,7 @@ echo "curl https://raw.githubusercontent.com/googleapis/googleapis/master/google curl --silent https://raw.githubusercontent.com/googleapis/googleapis/master/google/rpc/code.proto > "${WORKDIR}/googleapis/google/rpc/code.proto" source ./scripts/protoc_installer.sh -download_protoc $WORKDIR +install_protoc $WORKDIR mkdir -p "${WORKDIR}/out" @@ -83,7 +83,6 @@ SOURCES=( # Note that the protos listed here are all for testing purposes. All protos to # be used externally should have a go_package option (and they don't need to be # listed here). -# listed here). OPTS=Mgrpc/core/stats.proto=google.golang.org/grpc/interop/grpc_testing/core,\ Mgrpc/testing/benchmark_service.proto=google.golang.org/grpc/interop/grpc_testing,\ Mgrpc/testing/stats.proto=google.golang.org/grpc/interop/grpc_testing,\ diff --git a/scripts/vet-proto.sh b/scripts/vet-proto.sh index 76c35a1c0f45..dd52fe482e07 100755 --- a/scripts/vet-proto.sh +++ b/scripts/vet-proto.sh @@ -28,10 +28,6 @@ if [[ "$1" = "-install" ]]; then unzip ${PROTOC_FILENAME} protoc --version # Check that the binary works. popd - elif [[ -z "${VET_SKIP_PROTO}" ]]; then - source ./scripts/protoc_installer.sh - download_protoc - protoc --version 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." From 187a537e17a0ae6e260cc4532ba7f9ce0f83b238 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Fri, 12 Apr 2024 11:30:47 +0530 Subject: [PATCH 09/21] Refactor --- scripts/protoc_installer.sh | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/scripts/protoc_installer.sh b/scripts/protoc_installer.sh index 1ec2ca46e625..4026423bc9c0 100644 --- a/scripts/protoc_installer.sh +++ b/scripts/protoc_installer.sh @@ -1,5 +1,24 @@ #!/bin/bash -# Install protoc +# Copyright 2024 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu -o pipefail + +source "$(dirname $0)/vet-common.sh" + +# Perform installation of protoc from source based on OS. + PROTOC_VERSION="25.2" # Function to download pre-built binaries for Linux with @@ -25,10 +44,10 @@ install_protoc() { die "Unsupported architecture. Please consider manual installation." fi # Detect the Operating System - OS=$(uname -s) - case "$OS" in + case "$(uname -s)" in "Darwin") download_binary $ARCH "osx" "$1";; "Linux") download_binary $ARCH "linux" $1;; - *) echo "Unsupported operating system. Please consider manual installation." ;; + *) echo "Please consider manual installation from \ + https://github.com/protocolbuffers/protobuf/releases/ and add to PATH" ;; esac } From b4ba6859e56401b8ed8082395ab43bcec8e77b43 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Wed, 17 Apr 2024 21:40:15 +0530 Subject: [PATCH 10/21] fix --- scripts/protoc_installer.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/protoc_installer.sh b/scripts/protoc_installer.sh index 4026423bc9c0..570649e196df 100644 --- a/scripts/protoc_installer.sh +++ b/scripts/protoc_installer.sh @@ -24,6 +24,19 @@ PROTOC_VERSION="25.2" # Function to download pre-built binaries for Linux with # ARCH as $1, OS as $2, and WORKDIR as $3 arguments. download_binary() { + # Check if protoc is already available + if command -v protoc &> /dev/null; then + if installed_version=$(protoc --version | cut -d' ' -f2 2>/dev/null); then + if [ "$installed_version" = "$PROTOC_VERSION" ]; then + echo "protoc version $PROTOC_VERSION is already installed." + return + else + echo "Existing protoc version ($installed_version) differs. Installing version $PROTOC_VERSION..." + fi + else + echo "Unable to determine installed protoc version. Starting the installation." + fi + fi # Download URL (adjust if a newer release is available) DOWNLOAD_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-$2-$1.zip" # Download and unzip @@ -46,7 +59,7 @@ install_protoc() { # Detect the Operating System case "$(uname -s)" in "Darwin") download_binary $ARCH "osx" "$1";; - "Linux") download_binary $ARCH "linux" $1;; + "Linux") download_binary $ARCH "linux" "$1";; *) echo "Please consider manual installation from \ https://github.com/protocolbuffers/protobuf/releases/ and add to PATH" ;; esac From 0da67234640570fecaba29cc3bdc0009060fba1d Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Wed, 17 Apr 2024 22:46:48 +0530 Subject: [PATCH 11/21] Refactor --- scripts/protoc_installer.sh | 33 +++++++++++++++------------------ scripts/regenerate.sh | 3 +-- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/scripts/protoc_installer.sh b/scripts/protoc_installer.sh index 570649e196df..05254a8a03bc 100644 --- a/scripts/protoc_installer.sh +++ b/scripts/protoc_installer.sh @@ -46,21 +46,18 @@ download_binary() { rm "protoc-${PROTOC_VERSION}-$2-$1.zip" } -# Function to install protoc with WORKDIR as argument -install_protoc() { - # 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 Operating System - case "$(uname -s)" in - "Darwin") download_binary $ARCH "osx" "$1";; - "Linux") download_binary $ARCH "linux" "$1";; - *) echo "Please consider manual installation from \ - https://github.com/protocolbuffers/protobuf/releases/ and add to PATH" ;; - esac -} +# 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 Operating System +case "$(uname -s)" in + "Darwin") download_binary $ARCH "osx" "$1";; + "Linux") download_binary $ARCH "linux" "$1";; +*) echo "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 2b2a0dc586c9..4f95195db460 100755 --- a/scripts/regenerate.sh +++ b/scripts/regenerate.sh @@ -48,8 +48,7 @@ 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" -source ./scripts/protoc_installer.sh -install_protoc $WORKDIR +source ./scripts/protoc_installer.sh $WORKDIR mkdir -p "${WORKDIR}/out" From c462adcce6a154243208f7271e09bb5fc52a2572 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Wed, 24 Apr 2024 12:16:59 +0530 Subject: [PATCH 12/21] final fix --- scripts/{protoc_installer.sh => install_protoc.sh} | 4 ++-- scripts/regenerate.sh | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) rename scripts/{protoc_installer.sh => install_protoc.sh} (95%) mode change 100644 => 100755 diff --git a/scripts/protoc_installer.sh b/scripts/install_protoc.sh old mode 100644 new mode 100755 similarity index 95% rename from scripts/protoc_installer.sh rename to scripts/install_protoc.sh index 05254a8a03bc..127150496e21 --- a/scripts/protoc_installer.sh +++ b/scripts/install_protoc.sh @@ -31,13 +31,13 @@ download_binary() { echo "protoc version $PROTOC_VERSION is already installed." return else - echo "Existing protoc version ($installed_version) differs. Installing version $PROTOC_VERSION..." + echo "Existing protoc version ($installed_version) differs. Kindly make sure you have $PROTOC_VERSION installed." +# exit 1 fi else echo "Unable to determine installed protoc version. Starting the installation." fi fi - # Download URL (adjust if a newer release is available) DOWNLOAD_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-$2-$1.zip" # Download and unzip curl -LO "$DOWNLOAD_URL" diff --git a/scripts/regenerate.sh b/scripts/regenerate.sh index 4f95195db460..45c86888edb3 100755 --- a/scripts/regenerate.sh +++ b/scripts/regenerate.sh @@ -19,10 +19,13 @@ WORKDIR=$(mktemp -d) function finish { rm -rf "$WORKDIR" + # Revert back the PATH to client's original value + export PATH=RESTORED_PATH } trap finish EXIT GOBIN="${WORKDIR}"/bin +RESTORED_PATH=PATH export PATH="${GOBIN}:${PATH}" mkdir -p "${GOBIN}" @@ -48,7 +51,8 @@ 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" -source ./scripts/protoc_installer.sh $WORKDIR +#chmod +x ./scripts/install_protoc.sh +source ./scripts/install_protoc.sh $WORKDIR mkdir -p "${WORKDIR}/out" From f6365fb6666a738825d118eca8d0767c6f8c24c5 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Wed, 24 Apr 2024 12:21:27 +0530 Subject: [PATCH 13/21] tmp --- scripts/vet-proto.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/vet-proto.sh b/scripts/vet-proto.sh index dd52fe482e07..787f804a9a10 100755 --- a/scripts/vet-proto.sh +++ b/scripts/vet-proto.sh @@ -23,11 +23,8 @@ 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 - pushd /home/runner/go - wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME} - unzip ${PROTOC_FILENAME} - protoc --version # Check that the binary works. - popd + chmod +x ./scripts/install_protoc.sh + 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." From eb40292ec056826b76b78dfcea3a6e16e05402c5 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan <159750762+aranjans@users.noreply.github.com> Date: Fri, 3 May 2024 11:59:10 +0530 Subject: [PATCH 14/21] Update scripts/regenerate.sh Co-authored-by: Arvind Bright --- scripts/regenerate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/regenerate.sh b/scripts/regenerate.sh index 45c86888edb3..405bc814d366 100755 --- a/scripts/regenerate.sh +++ b/scripts/regenerate.sh @@ -20,7 +20,7 @@ WORKDIR=$(mktemp -d) function finish { rm -rf "$WORKDIR" # Revert back the PATH to client's original value - export PATH=RESTORED_PATH + export PATH=$RESTORED_PATH } trap finish EXIT From 5878795ea1469339e9a602cf7aef4cf9cbb791da Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Fri, 3 May 2024 12:07:16 +0530 Subject: [PATCH 15/21] fix: restore PATH variable at end of execution --- scripts/regenerate.sh | 3 ++- scripts/vet-proto.sh | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/regenerate.sh b/scripts/regenerate.sh index 405bc814d366..1c14d69a9a18 100755 --- a/scripts/regenerate.sh +++ b/scripts/regenerate.sh @@ -21,11 +21,12 @@ 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" } trap finish EXIT GOBIN="${WORKDIR}"/bin -RESTORED_PATH=PATH +RESTORED_PATH=$PATH export PATH="${GOBIN}:${PATH}" mkdir -p "${GOBIN}" diff --git a/scripts/vet-proto.sh b/scripts/vet-proto.sh index 787f804a9a10..89cd2e2757d9 100755 --- a/scripts/vet-proto.sh +++ b/scripts/vet-proto.sh @@ -23,7 +23,6 @@ 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 - chmod +x ./scripts/install_protoc.sh 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. From 77ac3347bea6eb72fc7ba887896e02276cea51ec Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Tue, 28 May 2024 12:09:54 +0530 Subject: [PATCH 16/21] 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 From 193e22c40004eb8ffd1daa7857398fd1a07a66da Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Mon, 3 Jun 2024 22:37:34 +0530 Subject: [PATCH 17/21] final fix --- scripts/install_protoc.sh | 11 +++++------ scripts/vet-proto.sh | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/install_protoc.sh b/scripts/install_protoc.sh index e849dd400fe1..922b4527be8c 100755 --- a/scripts/install_protoc.sh +++ b/scripts/install_protoc.sh @@ -21,17 +21,16 @@ source "$(dirname $0)/vet-common.sh" PROTOC_VERSION="25.2" # Function to download pre-built binaries for Linux with -# ARCH as $1, OS as $2, and WORKDIR as $3 arguments. +# ARCH as $1, OS as $2, and INSTALL_PATH as $3 arguments. download_binary() { - # Check if protoc is already available + # Check if protoc is already available. if command -v protoc &> /dev/null; then - if installed_version=$(protoc --version | cut -d' ' -f2 2>/dev/null); then - if [ "$installed_version" = "$PROTOC_VERSION" ]; then + if INSTALL_VERSION=$(protoc --version | cut -d' ' -f2 2>/dev/null); then + if [ "$INSTALL_VERSION" = "$PROTOC_VERSION" ]; then echo "protoc version $PROTOC_VERSION is already installed." return else - echo "Existing protoc version ($installed_version) differs. Kindly make sure you have $PROTOC_VERSION installed." - exit 1 + die "Existing protoc version ($INSTALL_VERSION) differs. Kindly make sure you have $PROTOC_VERSION installed." fi else echo "Unable to determine installed protoc version. Starting the installation." diff --git a/scripts/vet-proto.sh b/scripts/vet-proto.sh index f3ecbd4b84ec..56b423593cb9 100755 --- a/scripts/vet-proto.sh +++ b/scripts/vet-proto.sh @@ -23,7 +23,7 @@ if [[ "$1" = "-install" ]]; then 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." + die "run protoc installer https://github.com/grpc/grpc-go/blob/master/scripts/install_protoc.sh" fi echo SUCCESS exit 0 From 81429418ef0e659ae4480054e2a994b7f09957ac Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Tue, 4 Jun 2024 12:58:31 +0530 Subject: [PATCH 18/21] fix --- scripts/install_protoc.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/install_protoc.sh b/scripts/install_protoc.sh index 922b4527be8c..08d810fd1906 100755 --- a/scripts/install_protoc.sh +++ b/scripts/install_protoc.sh @@ -54,9 +54,10 @@ case "$(uname -m)" in esac # Detect the Operating System +INSTALL_PATH=${1:+"$1"} case "$(uname -s)" in - "Darwin") download_binary $ARCH "osx" "$1";; - "Linux") download_binary $ARCH "linux" "$1";; + "Darwin") download_binary $ARCH "osx" "$INSTALL_PATH";; + "Linux") download_binary $ARCH "linux" "$INSTALL_PATH";; *) die "Unsupported OS. Please consider manual installation from \ https://github.com/protocolbuffers/protobuf/releases/ and add to PATH" ;; esac From ab458c5eff47a46b09f0503a13a98609a2195cc4 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Tue, 4 Jun 2024 13:48:22 +0530 Subject: [PATCH 19/21] fix --- scripts/install_protoc.sh | 5 +++++ scripts/regenerate.sh | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/install_protoc.sh b/scripts/install_protoc.sh index 08d810fd1906..08761fd49713 100755 --- a/scripts/install_protoc.sh +++ b/scripts/install_protoc.sh @@ -12,6 +12,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +# +# This script ensures the installation of protobuf on client machine. +# In case of manual run of this script, make sure you pass the args +# expected at +# https://github.com/grpc/grpc-go/blob/master/scripts/install_protoc.sh#L60 set -eu -o pipefail diff --git a/scripts/regenerate.sh b/scripts/regenerate.sh index afece6530e41..c5d7b1a645f0 100755 --- a/scripts/regenerate.sh +++ b/scripts/regenerate.sh @@ -21,7 +21,6 @@ function finish { rm -rf "$WORKDIR" # Revert back the PATH to client's original value export PATH=$ORIGINAL_PATH - echo "Restored PATH variable to original value." } trap finish EXIT From 222edaa9c48eb969ba6796cc76c68d09555423dd Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Sat, 8 Jun 2024 15:04:09 +0530 Subject: [PATCH 20/21] Remove readme.txt from zip --- scripts/install_protoc.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/install_protoc.sh b/scripts/install_protoc.sh index 08761fd49713..29b8635b077f 100755 --- a/scripts/install_protoc.sh +++ b/scripts/install_protoc.sh @@ -44,9 +44,12 @@ download_binary() { DOWNLOAD_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-$2-$1.zip" # Download and unzip curl -LO "$DOWNLOAD_URL" - INSTALL_DIR="${3:-${GOBIN:-${GOPATH:-$HOME/go}/bin}}" + INSTALL_DIR="${3:-${GOBIN:-${GOPATH:-$HOME/go}}}" + echo "INSTALL DIR: ${INSTALL_DIR}" unzip "protoc-${PROTOC_VERSION}-$2-$1.zip" -d $INSTALL_DIR rm "protoc-${PROTOC_VERSION}-$2-$1.zip" + rm "${INSTALL_DIR}/readme.txt" + ls "${INSTALL_DIR}" } # Detect the architecture From cee987598160e275f37308dd85f3fd51c0ae5065 Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan Date: Sat, 8 Jun 2024 15:06:16 +0530 Subject: [PATCH 21/21] fix --- scripts/install_protoc.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install_protoc.sh b/scripts/install_protoc.sh index 29b8635b077f..f0b8aef56178 100755 --- a/scripts/install_protoc.sh +++ b/scripts/install_protoc.sh @@ -45,11 +45,9 @@ download_binary() { # Download and unzip curl -LO "$DOWNLOAD_URL" INSTALL_DIR="${3:-${GOBIN:-${GOPATH:-$HOME/go}}}" - echo "INSTALL DIR: ${INSTALL_DIR}" unzip "protoc-${PROTOC_VERSION}-$2-$1.zip" -d $INSTALL_DIR rm "protoc-${PROTOC_VERSION}-$2-$1.zip" rm "${INSTALL_DIR}/readme.txt" - ls "${INSTALL_DIR}" } # Detect the architecture