1
0
mirror of https://github.com/gluster/glusterd2.git synced 2026-02-05 12:45:38 +01:00
Files
glusterd2/scripts/check-protoc.sh
Michael Adam 98d9e5e665 scripts: fix shellcheck warnings in check-protoc.sh
SC1117: Backslash is literal in "\(". Prefer explicit escaping: "\\(".
SC1117: Backslash is literal in "\)". Prefer explicit escaping: "\\)".
SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]].

Signed-off-by: Michael Adam <obnox@redhat.com>
2018-04-24 10:34:31 +02:00

40 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Protobuf 3 version of `protoc` is required for GD2,
# for generating Go code from the proto definitions.
if [ "x$PROTOC" == "x" ]; then
PROTOC=protoc
fi
REQ_PROTOC_MAJOR_VERSION="3"
REQ_PROTOC_MINOR_VERSION="0"
REQ_PROTOC_VERSION="$REQ_PROTOC_MAJOR_VERSION.$REQ_PROTOC_MINOR_VERSION"
missing() {
echo "Protobuf compiler (protoc) $REQ_PROTOC_VERSION or later is missing on this system."
echo "Install protoc ${REQ_PROTOC_VERSION} using the preferred method for your system."
echo "Refer to https://developers.google.com/protocol-buffers/ if Protobuf $REQ_PROTOC_VERSION is not available in the system repositories."
exit 1
}
check_protoc_version() {
INST_PROTOC_VERSION=$(protoc --version | sed -e 's/.*libprotoc *//')
INST_PROTOC_MAJOR_VERSION=$(echo "$INST_PROTOC_VERSION" | cut -d. -f1)
INST_PROTOC_MINOR_VERSION=$(echo "$INST_PROTOC_VERSION" | cut -d. -f2)
if [ "$REQ_PROTOC_MAJOR_VERSION" -gt "$INST_PROTOC_MAJOR_VERSION" ]; then
missing
elif [ "$REQ_PROTOC_MAJOR_VERSION" -eq "$INST_PROTOC_MAJOR_VERSION" ] &&
[ "$REQ_PROTOC_MINOR_VERSION" -gt "$INST_PROTOC_MINOR_VERSION" ]; then
missing
fi
}
check_protoc_version
echo "protoc $REQ_PROTOC_VERSION or later is available on the system."