forked from pingcap/kvproto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.sh
More file actions
executable file
·36 lines (30 loc) · 826 Bytes
/
common.sh
File metadata and controls
executable file
·36 lines (30 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
set -ex
check_protoc_version() {
version=$(protoc --version)
major=$(echo ${version} | sed -n -e 's/.*\([0-9]\{1,\}\)\.[0-9]\{1,\}\.[0-9]\{1,\}.*/\1/p')
minor=$(echo ${version} | sed -n -e 's/.*[0-9]\{1,\}\.\([0-9]\{1,\}\)\.[0-9]\{1,\}.*/\1/p')
if [ "$major" -gt 3 ]; then
return 0
fi
if [ "$major" -eq 3 ] && [ "$minor" -eq 1 ]; then
return 0
fi
echo "protoc version not match, version 3.1.x is needed, current version: ${version}"
return 1
}
push () {
pushd $1 >/dev/null 2>&1
}
pop () {
popd $1 >/dev/null 2>&1
}
cmd_exists () {
which "$1" 1>/dev/null 2>&1
}
cargo_install() {
if ! cargo install --list|grep "$1 v$2"; then
echo "missing $1, trying to download/install it"
cargo install $1 --vers "$2" -f
fi
}