-
Notifications
You must be signed in to change notification settings - Fork 37
/
build.sh
executable file
·79 lines (63 loc) · 1.79 KB
/
build.sh
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
set -eo pipefail
mode=''
# The argument must be either 'zookeeper' or 'clickhouse'
if [ "$#" -lt 0 ] && [ "$1" != "zookeeper" ] && [ "$1" != "clickhouse" ]; then
echo "Usage: $0 [zookeeper|clickhouse]"
exit 1
fi
if [ "$1" != "clickhouse" ]; then
mode='zookeeper'
else
mode='clickhouse'
fi
ROOT=$(dirname "$0")
ROOT=$(cd "$ROOT"; pwd)
mkdir -p $ROOT/build
function version()
{
grep VERSION_STRING $ROOT/version.txt | awk '{print $2}' | awk -F')' '{print $1}'
}
# build binary
function build()
{
echo "Building in $1 compatible mode."
cd $ROOT/build && find $ROOT/build -type f ! -name '*.tar.gz' -exec rm -f {} +
COMPATIBLE_MODE_ZOOKEEPER="ON"
if [ -n "$1" ] && [ "$1" == "clickhouse" ]; then
COMPATIBLE_MODE_ZOOKEEPER="OFF"
fi
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCOMPATIBLE_MODE_ZOOKEEPER=$COMPATIBLE_MODE_ZOOKEEPER
PARALLEL="$(($(nproc) / 4 + 1))"
make -j $PARALLEL
echo "Build complete!"
echo ""
}
# make tarball
function package()
{
echo "Packaging in $1 compatible mode."
cd "$ROOT"
mkdir -p build/RaftKeeper
mkdir -p build/RaftKeeper/bin
mkdir -p build/RaftKeeper/lib
mkdir -p build/RaftKeeper/conf
mkdir -p build/RaftKeeper/log
mkdir -p build/RaftKeeper/data
cp programs/server/bin/start.sh build/RaftKeeper/bin/.
cp programs/server/bin/stop.sh build/RaftKeeper/bin/.
cp build/programs/raftkeeper build/RaftKeeper/lib/.
cp programs/server/config.xml build/RaftKeeper/conf/.
cd $ROOT/build
if [ -n "$1" ] && [ "$1" == "clickhouse" ]; then
file_name=RaftKeeper-`version`-linux-x86_64-clickhouse.tar.gz
else
file_name=RaftKeeper-`version`-linux-x86_64.tar.gz
fi
tar -czvf $file_name RaftKeeper
rm -rf RaftKeeper
echo "RaftKeeper is built into build/${file_name}."
}
build "$mode"
package "$mode"
echo "Done!"