Files
rustfs/scripts/install-protoc.sh
Henry Guo 69dcf9e6cb fix(tooling): harden internode transport benchmark setup (#3037)
* refactor(config): centralize internode transport constants

* fix(bench): guard all ripgrep calls behind dry-run check

Move require_cmd rg and metrics collection inside the non-dry-run
path so that --dry-run works on hosts without rg installed.

* feat(tooling): cross-platform protoc setup for Linux and macOS

Make install-protoc.sh support Linux (x86_64, aarch64) alongside
macOS, and bump CI protoc from 29.3 to 33.1 to match the version
required by the gproto build script.

* fix(bench): record internode baseline error counts

* fix(skill): correct YAML frontmatter formatting for release-version-bump

* chore(ci): bump protoc version to 34.1

* fix(tooling): bump protoc 33.1 to 34.1 in install script, restore SKILL.md description

---------

Co-authored-by: Henry Guo <marshawcoco@users.noreply.github.com>
2026-05-21 05:47:32 +00:00

88 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install protoc 34.1 on macOS and Linux
set -e
PROTOC_VERSION="34.1"
ARCH=$(uname -m)
INSTALL_DIR="${HOME}/.local/bin"
PROTOC_BIN="${INSTALL_DIR}/protoc"
# Detect OS
OS="$(uname -s)"
# Select download URL based on OS and architecture
if [ "$OS" = "Darwin" ]; then
if [ "$ARCH" = "arm64" ]; then
# Apple Silicon (M1/M2/M3)
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-osx-aarch_64.zip"
elif [ "$ARCH" = "x86_64" ]; then
# Intel Mac
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-osx-x86_64.zip"
else
echo "Error: Unsupported macOS architecture $ARCH"
exit 1
fi
elif [ "$OS" = "Linux" ]; then
if [ "$ARCH" = "x86_64" ]; then
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip"
elif [ "$ARCH" = "aarch64" ]; then
PROTOC_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-aarch_64.zip"
else
echo "Error: Unsupported Linux architecture $ARCH"
exit 1
fi
else
echo "Error: Unsupported OS $OS"
echo "On Windows, install protoc via:"
echo " choco install protoc --version=${PROTOC_VERSION}"
echo " or download from https://github.com/protocolbuffers/protobuf/releases"
exit 1
fi
echo "Downloading protoc ${PROTOC_VERSION} for ${ARCH}..."
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
# Download and extract
curl -L -o protoc.zip "$PROTOC_URL"
unzip -q protoc.zip
# Create install directory
mkdir -p "$INSTALL_DIR"
# Backup existing version if present
if [ -f "$PROTOC_BIN" ]; then
echo "Backing up existing protoc to ${PROTOC_BIN}.backup"
mv "$PROTOC_BIN" "${PROTOC_BIN}.backup"
fi
# Install protoc
cp bin/protoc "$PROTOC_BIN"
chmod +x "$PROTOC_BIN"
# Clean up temporary files
cd -
rm -rf "$TEMP_DIR"
# Verify installation
echo ""
echo "Verifying installation..."
"$PROTOC_BIN" --version
# Check PATH
if [[ ":$PATH:" != *":${INSTALL_DIR}:"* ]]; then
echo ""
echo "⚠️ Warning: ${INSTALL_DIR} is not in PATH"
echo "Please add the following to ~/.zshrc or ~/.bash_profile:"
echo ""
echo " export PATH=\"\${HOME}/.local/bin:\$PATH\""
echo ""
echo "Then run: source ~/.zshrc"
else
echo ""
echo "✅ protoc ${PROTOC_VERSION} installed successfully!"
echo "Location: $PROTOC_BIN"
fi