forked from apache/celeborn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-distribution.sh
executable file
·438 lines (379 loc) · 13.8 KB
/
make-distribution.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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 -o pipefail
set -e
set -x
PROJECT_DIR="$(cd "`dirname "$0"`/.."; pwd)"
DIST_DIR="$PROJECT_DIR/dist"
NAME="bin"
RELEASE="false"
MVN="$PROJECT_DIR/build/mvn"
SBT="$PROJECT_DIR/build/sbt"
SBT_ENABLED="false"
function exit_with_usage {
echo "make-distribution.sh - tool for making binary distributions of Celeborn"
echo ""
echo "usage:"
cl_options="[--name <custom_name>] [--release] [--sbt-enabled] [--mvn <mvn-command>]"
echo "make-distribution.sh $cl_options <maven build options>"
echo ""
exit 1
}
# Parse arguments
while (( "$#" )); do
case $1 in
--name)
NAME="bin-$2"
shift
;;
--mvn)
MVN="$2"
shift
;;
--release)
RELEASE="true"
;;
--sbt-enabled)
SBT_ENABLED="true"
;;
--help)
exit_with_usage
;;
--*)
echo "Error: $1 is not supported"
exit_with_usage
;;
-*)
break
;;
*)
echo "Error: $1 is not supported"
exit_with_usage
;;
esac
shift
done
if [ -z "$JAVA_HOME" ]; then
# Fall back on JAVA_HOME from rpm, if found
if [ $(command -v rpm) ]; then
RPM_JAVA_HOME="$(rpm -E %java_home 2>/dev/null)"
if [ "$RPM_JAVA_HOME" != "%java_home" ]; then
JAVA_HOME="$RPM_JAVA_HOME"
echo "No JAVA_HOME set, proceeding with '$JAVA_HOME' learned from rpm"
fi
fi
if [ -z "$JAVA_HOME" ]; then
if [ `command -v java` ]; then
# If java is in /usr/bin/java, we want /usr
JAVA_HOME="$(dirname $(dirname $(which java)))"
fi
fi
fi
if [ -z "$JAVA_HOME" ]; then
echo "Error: JAVA_HOME is not set, cannot proceed."
exit -1
fi
export MAVEN_OPTS="${MAVEN_OPTS:--Xmx2g -XX:ReservedCodeCacheSize=1g}"
if [ ! "$(command -v "$MVN")" ] ; then
echo -e "Could not locate Maven command: '$MVN'."
exit -1;
fi
if [ $(command -v git) ]; then
GITREV=$(git rev-parse --short HEAD 2>/dev/null || :)
if [ ! -z "$GITREV" ]; then
GITREVSTRING=" (git revision $GITREV)"
fi
unset GITREV
fi
cd "$PROJECT_DIR"
# Make directories
rm -rf "$DIST_DIR"
mkdir -p "$DIST_DIR"
MVN_DIST_OPT="-DskipTests -Dmaven.javadoc.skip=true -Dmaven.source.skip"
function build_service {
VERSION=$("$MVN" help:evaluate -Dexpression=project.version $@ 2>/dev/null \
| grep -v "INFO" \
| grep -v "WARNING" \
| tail -n 1)
SCALA_VERSION=$("$MVN" help:evaluate -Dexpression=scala.binary.version $@ 2>/dev/null \
| grep -v "INFO" \
| grep -v "WARNING" \
| tail -n 1)
echo "Celeborn version is $VERSION"
echo "Making apache-celeborn-$VERSION-$NAME.tgz"
echo "Celeborn $VERSION$GITREVSTRING" > "$DIST_DIR/RELEASE"
echo "Build flags: $@" >> "$DIST_DIR/RELEASE"
# Store the command as an array because $MVN variable might have spaces in it.
# Normal quoting tricks don't work.
# See: http://mywiki.wooledge.org/BashFAQ/050
BUILD_COMMAND=("$MVN" clean package $MVN_DIST_OPT -pl master,worker,cli -am $@)
# Actually build the jar
echo -e "\nBuilding with..."
echo -e "\$ ${BUILD_COMMAND[@]}\n"
"${BUILD_COMMAND[@]}"
mkdir -p "$DIST_DIR/jars"
mkdir -p "$DIST_DIR/master-jars"
mkdir -p "$DIST_DIR/worker-jars"
mkdir -p "$DIST_DIR/cli-jars"
## Copy master jars
cp "$PROJECT_DIR"/master/target/celeborn-master_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/master-jars/"
cp "$PROJECT_DIR"/master/target/scala-$SCALA_VERSION/jars/*.jar "$DIST_DIR/jars/"
for jar in $(ls "$PROJECT_DIR/master/target/scala-$SCALA_VERSION/jars"); do
(cd $DIST_DIR/master-jars; ln -snf "../jars/$jar" .)
done
## Copy worker jars
cp "$PROJECT_DIR"/worker/target/celeborn-worker_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/worker-jars/"
cp "$PROJECT_DIR"/worker/target/scala-$SCALA_VERSION/jars/*.jar "$DIST_DIR/jars/"
for jar in $(ls "$PROJECT_DIR/worker/target/scala-$SCALA_VERSION/jars"); do
(cd $DIST_DIR/worker-jars; ln -snf "../jars/$jar" .)
done
## Copy cli jars
cp "$PROJECT_DIR"/cli/target/celeborn-cli_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/cli-jars/"
cp "$PROJECT_DIR"/cli/target/scala-$SCALA_VERSION/jars/*.jar "$DIST_DIR/jars/"
for jar in $(ls "$PROJECT_DIR/cli/target/scala-$SCALA_VERSION/jars"); do
(cd $DIST_DIR/cli-jars; ln -snf "../jars/$jar" .)
done
}
function build_spark_client {
VERSION=$("$MVN" help:evaluate -Dexpression=project.version $@ 2>/dev/null \
| grep -v "INFO" \
| grep -v "WARNING" \
| tail -n 1)
SCALA_VERSION=$("$MVN" help:evaluate -Dexpression=scala.binary.version $@ 2>/dev/null \
| grep -v "INFO" \
| grep -v "WARNING" \
| tail -n 1)
SPARK_VERSION=$("$MVN" help:evaluate -Dexpression=spark.version $@ 2>/dev/null \
| grep -v "INFO" \
| grep -v "WARNING" \
| tail -n 1)
SPARK_MAJOR_VERSION=${SPARK_VERSION%%.*}
# Store the command as an array because $MVN variable might have spaces in it.
# Normal quoting tricks don't work.
# See: http://mywiki.wooledge.org/BashFAQ/050
BUILD_COMMAND=("$MVN" clean package $MVN_DIST_OPT -pl :celeborn-client-spark-${SPARK_MAJOR_VERSION}-shaded_$SCALA_VERSION -am $@)
# Actually build the jar
echo -e "\nBuilding with..."
echo -e "\$ ${BUILD_COMMAND[@]}\n"
"${BUILD_COMMAND[@]}"
mkdir -p "$DIST_DIR/spark"
## Copy spark client jars
cp "$PROJECT_DIR"/client-spark/spark-$SPARK_MAJOR_VERSION-shaded/target/celeborn-client-spark-${SPARK_MAJOR_VERSION}-shaded_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/spark/"
}
function build_flink_client {
FLINK_VERSION=$("$MVN" help:evaluate -Dexpression=flink.version $@ 2>/dev/null \
| grep -v "INFO" \
| grep -v "WARNING" \
| tail -n 1)
SCALA_VERSION=$("$MVN" help:evaluate -Dexpression=scala.binary.version $@ 2>/dev/null \
| grep -v "INFO" \
| grep -v "WARNING" \
| tail -n 1)
FLINK_BINARY_VERSION=${FLINK_VERSION%.*}
# Store the command as an array because $MVN variable might have spaces in it.
# Normal quoting tricks don't work.
# See: http://mywiki.wooledge.org/BashFAQ/050
BUILD_COMMAND=("$MVN" clean package $MVN_DIST_OPT -pl :celeborn-client-flink-${FLINK_BINARY_VERSION}-shaded_$SCALA_VERSION -am $@)
# Actually build the jar
echo -e "\nBuilding with..."
echo -e "\$ ${BUILD_COMMAND[@]}\n"
"${BUILD_COMMAND[@]}"
## flink spark client jars
mkdir -p "$DIST_DIR/flink"
cp "$PROJECT_DIR"/client-flink/flink-$FLINK_BINARY_VERSION-shaded/target/celeborn-client-flink-${FLINK_BINARY_VERSION}-shaded_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/flink/"
}
function build_mr_client {
VERSION=$("$MVN" help:evaluate -Dexpression=project.version $@ 2>/dev/null \
| grep -v "INFO" \
| grep -v "WARNING" \
| tail -n 1)
BUILD_COMMAND=("$MVN" clean package $MVN_DIST_OPT -pl :celeborn-client-mr-shaded_${SCALA_VERSION} -am $@)
# Actually build the jar
echo -e "\nBuilding with..."
echo -e "\$ ${BUILD_COMMAND[@]}\n"
"${BUILD_COMMAND[@]}"
## flink spark client jars
mkdir -p "$DIST_DIR/mr"
cp "$PROJECT_DIR"/client-mr/mr-shaded/target/celeborn-client-mr-shaded_${SCALA_VERSION}-$VERSION.jar "$DIST_DIR/mr/"
}
#########################
# sbt functions #
#########################
function sbt_build_service {
VERSION=$("$SBT" -no-colors "Show / version" | awk '/\[info\]/{ver=$2} END{print ver}')
SCALA_VERSION=$("$SBT" -no-colors "Show / scalaBinaryVersion" | awk '/\[info\]/{ver=$2} END{print ver}')
echo "Celeborn version is $VERSION"
echo "Making apache-celeborn-$VERSION-$NAME.tgz"
echo "Celeborn $VERSION$GITREVSTRING" > "$DIST_DIR/RELEASE"
echo "Build flags: $@" >> "$DIST_DIR/RELEASE"
if [[ $@ == *"aws"* ]]; then
export SBT_MAVEN_PROFILES="aws"
fi
BUILD_COMMAND=("$SBT" clean package)
# Actually build the jar
echo -e "\nBuilding with..."
echo -e "\$ ${BUILD_COMMAND[@]}\n"
"${BUILD_COMMAND[@]}"
$SBT "celeborn-master/copyJars;celeborn-worker/copyJars;celeborn-cli/copyJars"
mkdir -p "$DIST_DIR/jars"
mkdir -p "$DIST_DIR/master-jars"
mkdir -p "$DIST_DIR/worker-jars"
mkdir -p "$DIST_DIR/cli-jars"
## Copy master jars
cp "$PROJECT_DIR"/master/target/scala-$SCALA_VERSION/celeborn-master_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/master-jars/"
cp "$PROJECT_DIR"/master/target/scala-$SCALA_VERSION/jars/*.jar "$DIST_DIR/jars/"
for jar in $(ls "$PROJECT_DIR/master/target/scala-$SCALA_VERSION/jars"); do
(cd $DIST_DIR/master-jars; ln -snf "../jars/$jar" .)
done
## Copy worker jars
cp "$PROJECT_DIR"/worker/target/scala-$SCALA_VERSION/celeborn-worker_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/worker-jars/"
cp "$PROJECT_DIR"/worker/target/scala-$SCALA_VERSION/jars/*.jar "$DIST_DIR/jars/"
for jar in $(ls "$PROJECT_DIR/worker/target/scala-$SCALA_VERSION/jars"); do
(cd $DIST_DIR/worker-jars; ln -snf "../jars/$jar" .)
done
## Copy cli jars
cp "$PROJECT_DIR"/cli/target/scala-$SCALA_VERSION/celeborn-cli_$SCALA_VERSION-$VERSION.jar "$DIST_DIR/cli-jars/"
cp "$PROJECT_DIR"/cli/target/scala-$SCALA_VERSION/jars/*.jar "$DIST_DIR/jars/"
for jar in $(ls "$PROJECT_DIR/cli/target/scala-$SCALA_VERSION/jars"); do
(cd $DIST_DIR/cli-jars; ln -snf "../jars/$jar" .)
done
}
function sbt_build_client {
PROFILE="$1"
# get the client shaded project
CLIENT_PROJECT=$("$SBT" -no-colors "$PROFILE" projects | grep shaded | awk '{print$2}')
# get the shaded jar file path
ASSEMBLY_OUTPUT_PATH=$("$SBT" -no-colors "$PROFILE" "show $CLIENT_PROJECT/assembly/assemblyOutputPath" | awk '/\[info\]/{ver=$2} END{print ver}')
# build the shaded jar
$SBT $PROFILE "clean;$CLIENT_PROJECT/assembly"
PROFILE_PREFIX=$(echo "$PROFILE" | cut -d'-' -f2)
CLIENT_SUB_DIR="${PROFILE_PREFIX:1}"
mkdir -p "$DIST_DIR/$CLIENT_SUB_DIR"
cp "$ASSEMBLY_OUTPUT_PATH" "$DIST_DIR/$CLIENT_SUB_DIR/"
}
if [ "$SBT_ENABLED" == "true" ]; then
sbt_build_service "$@"
if [ "$RELEASE" == "true" ]; then
sbt_build_client -Pspark-2.4
sbt_build_client -Pspark-3.4
sbt_build_client -Pspark-3.5
sbt_build_client -Pflink-1.14
sbt_build_client -Pflink-1.15
sbt_build_client -Pflink-1.16
sbt_build_client -Pflink-1.17
sbt_build_client -Pflink-1.18
sbt_build_client -Pflink-1.19
sbt_build_client -Pflink-1.20
sbt_build_client -Pmr
else
echo "build client with $@"
ENGINE_COUNT=0
ENGINES=("spark" "flink" "mr")
for single_engine in ${ENGINES[@]}
do
echo $single_engine
if [[ $@ == *"${single_engine}"* ]];then
ENGINE_COUNT=`expr ${ENGINE_COUNT} + 1`
fi
done
if [[ ${ENGINE_COUNT} -eq 0 ]]; then
echo "Skip building client."
elif [[ ${ENGINE_COUNT} -ge 2 ]]; then
echo "Error: unsupported build options: $@"
echo " currently we do not support compiling different engine clients at the same time."
exit -1
else
sbt_build_client $@
fi
fi
else
if [ "$RELEASE" == "true" ]; then
build_service
build_spark_client -Pspark-2.4
build_spark_client -Pspark-3.4
build_spark_client -Pspark-3.5
build_flink_client -Pflink-1.14
build_flink_client -Pflink-1.15
build_flink_client -Pflink-1.16
build_flink_client -Pflink-1.17
build_flink_client -Pflink-1.18
build_flink_client -Pflink-1.19
build_flink_client -Pflink-1.20
build_mr_client -Pmr
else
## build release package on demand
build_service $@
echo "build client with $@"
ENGINE_COUNT=0
ENGINES=("spark" "flink" "mr")
for single_engine in ${ENGINES[@]}
do
echo $single_engine
if [[ $@ == *"${single_engine}"* ]];then
ENGINE_COUNT=`expr ${ENGINE_COUNT} + 1`
fi
done
if [[ ${ENGINE_COUNT} -eq 0 ]]; then
echo "Skip building client."
elif [[ ${ENGINE_COUNT} -ge 2 ]]; then
echo "Error: unsupported build options: $@"
echo " currently we do not support compiling different engine clients at the same time."
exit -1
elif [[ $@ == *"spark"* ]]; then
echo "build spark clients"
build_spark_client $@
elif [[ $@ == *"flink"* ]]; then
echo "build flink clients"
build_flink_client $@
elif [[ $@ == *"mr"* ]]; then
echo "build mr clients"
build_mr_client $@
fi
fi
fi
# Copy configuration templates
mkdir "$DIST_DIR/conf"
cp "$PROJECT_DIR"/conf/*.template "$DIST_DIR/conf"
# Copy shell scripts
cp -r "$PROJECT_DIR/bin" "$DIST_DIR"
cp -r "$PROJECT_DIR/sbin" "$DIST_DIR"
# Copy db scripts
mkdir "$DIST_DIR/db-scripts"
cp -r "$PROJECT_DIR/service/src/main/resources/sql/" "$DIST_DIR/db-scripts"
# Copy container related resources
mkdir "$DIST_DIR/docker"
cp "$PROJECT_DIR/docker/Dockerfile" "$DIST_DIR/docker"
# Copy Helm Charts
cp -r "$PROJECT_DIR/charts" "$DIST_DIR"
# Copy license files
if [[ -f $"$PROJECT_DIR/LICENSE-binary" ]]; then
cp "$PROJECT_DIR/LICENSE-binary" "$DIST_DIR/LICENSE"
cp -r "$PROJECT_DIR/licenses-binary" "$DIST_DIR/licenses"
cp "$PROJECT_DIR/NOTICE-binary" "$DIST_DIR/NOTICE"
fi
# Create tarball
TARDIR_NAME="apache-celeborn-$VERSION-$NAME"
TARDIR="$PROJECT_DIR/$TARDIR_NAME"
rm -rf "$TARDIR"
cp -R "$DIST_DIR" "$TARDIR"
TAR="tar"
if [ "$(uname -s)" = "Darwin" ]; then
TAR="tar --no-mac-metadata --no-xattrs --no-fflags"
fi
$TAR -czf "apache-celeborn-$VERSION-$NAME.tgz" -C "$PROJECT_DIR" "$TARDIR_NAME"
rm -rf "$TARDIR"