-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathpost-build.sh
More file actions
executable file
·232 lines (200 loc) · 6.87 KB
/
post-build.sh
File metadata and controls
executable file
·232 lines (200 loc) · 6.87 KB
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
#!/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.
##############################################################
# Post-build script for packaging third-party filesystem JARs
# (JuiceFS, JindoFS) into Doris FE/BE output directories.
#
# This script is independent of the main build and can be
# executed standalone or called from build.sh.
#
# Usage:
# post-build.sh [--fe] [--be] [--output <dir>]
# [--juicefs] [--jindofs]
#
# Environment variables:
# DISABLE_BUILD_JUICEFS=OFF Enable JuiceFS packaging (default: ON, i.e. skip)
# DISABLE_BUILD_JINDOFS=OFF Enable JindoFS packaging (default: ON, i.e. skip)
##############################################################
set -eo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
DORIS_HOME="${DORIS_HOME:-${ROOT}}"
if [[ -z "${DORIS_THIRDPARTY}" ]]; then
DORIS_THIRDPARTY="${DORIS_HOME}/thirdparty"
fi
TARGET_SYSTEM="${TARGET_SYSTEM:-$(uname -s)}"
TARGET_ARCH="${TARGET_ARCH:-$(uname -m)}"
# --- Source helper scripts ---
. "${DORIS_HOME}/docker/thirdparties/juicefs-helpers.sh"
. "${DORIS_HOME}/docker/thirdparties/jindofs-helpers.sh"
# --- JuiceFS wrapper functions (migrated from build.sh) ---
find_juicefs_hadoop_jar() {
juicefs_find_hadoop_jar_by_globs \
"${DORIS_THIRDPARTY}/installed/juicefs_libs/juicefs-hadoop-[0-9]*.jar" \
"${DORIS_THIRDPARTY}/src/juicefs-hadoop-[0-9]*.jar" \
"${DORIS_HOME}/thirdparty/installed/juicefs_libs/juicefs-hadoop-[0-9]*.jar" \
"${DORIS_HOME}/thirdparty/src/juicefs-hadoop-[0-9]*.jar"
}
detect_juicefs_version() {
local juicefs_jar
juicefs_jar=$(find_juicefs_hadoop_jar || true)
juicefs_detect_hadoop_version "${juicefs_jar}" "${JUICEFS_DEFAULT_VERSION}"
}
download_juicefs_hadoop_jar() {
local juicefs_version="$1"
local cache_dir="${DORIS_HOME}/thirdparty/installed/juicefs_libs"
juicefs_download_hadoop_jar_to_cache "${juicefs_version}" "${cache_dir}"
}
copy_juicefs_hadoop_jar() {
local target_dir="$1"
local source_jar=""
source_jar=$(find_juicefs_hadoop_jar || true)
if [[ -z "${source_jar}" ]]; then
local juicefs_version
juicefs_version=$(detect_juicefs_version)
source_jar=$(download_juicefs_hadoop_jar "${juicefs_version}" || true)
fi
if [[ -z "${source_jar}" ]]; then
echo "WARN: skip copying juicefs-hadoop jar, not found in thirdparty and download failed"
return 0
fi
cp -r -p "${source_jar}" "${target_dir}/"
echo "Copy JuiceFS Hadoop jar to ${target_dir}: $(basename "${source_jar}")"
}
# --- Install functions ---
install_juicefs() {
local target_type="$1"
local output_dir="$2"
local target_dir
if [[ "${target_type}" == "fe" ]]; then
target_dir="${output_dir}/fe/lib/juicefs"
elif [[ "${target_type}" == "be" ]]; then
target_dir="${output_dir}/be/lib/java_extensions/juicefs"
else
echo "ERROR: unknown target type '${target_type}' for install_juicefs"
return 1
fi
install -d "${target_dir}"
copy_juicefs_hadoop_jar "${target_dir}"
}
install_jindofs() {
local target_type="$1"
local output_dir="$2"
local target_dir
if [[ "${target_type}" == "fe" ]]; then
target_dir="${output_dir}/fe/lib/jindofs"
elif [[ "${target_type}" == "be" ]]; then
target_dir="${output_dir}/be/lib/java_extensions/jindofs"
else
echo "ERROR: unknown target type '${target_type}' for install_jindofs"
return 1
fi
install -d "${target_dir}"
jindofs_copy_jars "${DORIS_THIRDPARTY}/installed/jindofs_libs" "${target_dir}" \
"${TARGET_SYSTEM}" "${TARGET_ARCH}"
}
# --- CLI ---
usage() {
echo "
Usage: $0 [--fe] [--be] [--output <dir>] [--juicefs] [--jindofs]
Package third-party filesystem JARs (JuiceFS, JindoFS) into Doris output directories.
By default, no third-party JARs are packaged. Use --juicefs/--jindofs or environment variables to opt in.
Options:
--fe Process FE output directory
--be Process BE output directory
--output <dir> Output directory (default: \${DORIS_HOME}/output)
--juicefs Enable JuiceFS packaging
--jindofs Enable JindoFS packaging
Environment variables:
DISABLE_BUILD_JUICEFS=OFF Enable JuiceFS packaging (--juicefs takes precedence)
DISABLE_BUILD_JINDOFS=OFF Enable JindoFS packaging (--jindofs takes precedence)
"
}
# Defaults: not installed
PROCESS_FE=0
PROCESS_BE=0
OUTPUT_DIR=""
BUILD_JUICEFS=""
BUILD_JINDOFS=""
while [[ $# -gt 0 ]]; do
case "$1" in
--fe)
PROCESS_FE=1
shift
;;
--be)
PROCESS_BE=1
shift
;;
--output)
OUTPUT_DIR="$2"
shift 2
;;
--juicefs)
BUILD_JUICEFS="ON"
shift
;;
--jindofs)
BUILD_JINDOFS="ON"
shift
;;
--help | -h)
usage
exit 0
;;
*)
echo "Unknown option: $1"
usage
exit 1
;;
esac
done
OUTPUT_DIR="${OUTPUT_DIR:-${DORIS_HOME}/output}"
# Resolve build flags: CLI > env DISABLE_BUILD_XXX > default (OFF)
if [[ -z "${BUILD_JUICEFS}" ]]; then
if [[ "$(echo "${DISABLE_BUILD_JUICEFS}" | tr '[:lower:]' '[:upper:]')" == "OFF" ]]; then
BUILD_JUICEFS="ON"
else
BUILD_JUICEFS="OFF"
fi
fi
if [[ -z "${BUILD_JINDOFS}" ]]; then
if [[ "$(echo "${DISABLE_BUILD_JINDOFS}" | tr '[:lower:]' '[:upper:]')" == "OFF" ]]; then
BUILD_JINDOFS="ON"
else
BUILD_JINDOFS="OFF"
fi
fi
if [[ "${PROCESS_FE}" -eq 0 && "${PROCESS_BE}" -eq 0 ]]; then
echo "Nothing to do. Specify --fe and/or --be."
exit 0
fi
# --- Main ---
for target_type in fe be; do
if [[ "${target_type}" == "fe" && "${PROCESS_FE}" -eq 0 ]]; then
continue
fi
if [[ "${target_type}" == "be" && "${PROCESS_BE}" -eq 0 ]]; then
continue
fi
if [[ "${BUILD_JINDOFS}" == "ON" ]]; then
install_jindofs "${target_type}" "${OUTPUT_DIR}"
fi
if [[ "${BUILD_JUICEFS}" == "ON" ]]; then
install_juicefs "${target_type}" "${OUTPUT_DIR}"
fi
done