-
Notifications
You must be signed in to change notification settings - Fork 348
Expand file tree
/
Copy pathdaos_build.sh
More file actions
executable file
·195 lines (172 loc) · 5.49 KB
/
Copy pathdaos_build.sh
File metadata and controls
executable file
·195 lines (172 loc) · 5.49 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
#!/bin/bash
#
# Copyright 2026 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
# This is a script to be run by the src/tests/ftest/dfuse/daos_build.py to run a test on a CI node.
set -euo pipefail
timestamp_output() {
while IFS= read -r line; do
# Use bash printf time formatting to avoid spawning `date` per line
printf '%(%Y-%m-%d %H:%M:%S)T %s\n' -1 "$line"
done
}
# Timestamp all script output (stdout + stderr)
exec > >(timestamp_output) 2>&1
show_help() {
echo "Usage: $0 [options]"
echo "Options:"
echo " -p, --python-cmd <val> Python command to use (default: python3)"
echo " -v, --venv-dir <val> Path to Python virtual environment (default: /tmp/daos_build/venv)"
echo " -b, --build-dir <val> Directory to clone and build DAOS (default: /tmp/daos_build/daos)"
echo " -m, --mount-dir <val> Optional mount directory to use for filesystem tests (default: none)"
echo " -g, --git-checkout <val> Git branch or commit to checkout (default: origin/master)"
echo " -d, --distro <val> Linux distribution for installing dependencies (default: el9)"
echo " -j, --build-jobs <val> Number of parallel jobs for building DAOS (default: 30)"
echo " -r, --rebuild Whether to skip setup of build and venv directories (default: false)"
echo " --debug Whether to run additional debug checks (default: false)"
echo " -h, --help Show this help message and exit"
}
# Argument defaults
python_cmd="python3"
venv_dir="/tmp/daos_build/venv"
build_dir="/tmp/daos_build/daos"
mount_dir=""
git_checkout="origin/master"
distro="el9"
build_jobs="30"
rebuild="false"
debug="false"
# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-p|--python-cmd)
python_cmd="$2"
shift 2
;;
-v|--venv-dir)
venv_dir="$2"
shift 2
;;
-b|--build-dir)
build_dir="$2"
shift 2
;;
-m|--mount-dir)
mount_dir="$2"
shift 2
;;
-g|--git-checkout)
git_checkout="$2"
shift 2
;;
-d|--distro)
distro="$2"
shift 2
;;
-j|--build-jobs)
build_jobs="$2"
shift 2
;;
-r|--rebuild)
rebuild="true"
shift 1
;;
--debug)
debug="true"
shift 1
;;
--help|-h)
show_help
exit 0
;;
--)
shift
break
;;
*)
echo "Unknown option: $1" >&2
show_help
exit 1
;;
esac
done
run_cmd() {
local start_time end_time elapsed_seconds rc
local cmd="$*"
echo ">---------------------------------------------------------"
echo "Running command: ${cmd}"
start_time=$(date +%s)
${cmd}
rc=$?
end_time=$(date +%s)
elapsed_seconds=$((end_time - start_time))
echo "Command finished in ${elapsed_seconds}s with rc=${rc}: ${cmd}"
if [ "${rc}" -ne 0 ]; then
echo "ERROR: command failed with rc=${rc}: ${cmd}" # >&2
return "${rc}"
fi
return 0
}
full_start=$(date +%s)
# Create a Python virtual environment and install python build dependencies
if [ "${rebuild}" = "false" ]; then
run_cmd "rm -rf ${venv_dir}" || exit
run_cmd "${python_cmd} -m venv ${venv_dir}" || exit
cat <<EOF > "${venv_dir}"/pip.conf
[global]
progress_bar = off
no_color = true
quiet = 0
EOF
fi
# Run in the python virtual environment for the rest of the script
run_cmd "source ${venv_dir}/bin/activate" || exit
venv_python="${venv_dir}/bin/python"
# Clone the DAOS repository and install RPM dependencies for the build
if [ "${rebuild}" = "false" ]; then
run_cmd "rm -rf ${build_dir}" || exit
run_cmd "git clone https://github.com/daos-stack/daos.git ${build_dir}" || exit
run_cmd "git -C ${build_dir} checkout ${git_checkout}" || exit
run_cmd "git -C ${build_dir} submodule update --init --recursive" || exit
run_cmd "cp ${build_dir}/utils/scripts/install-${distro}.sh /tmp/install.sh" || exit
run_cmd "sudo -E NO_OPENMPI_DEVEL=1 /tmp/install.sh -y" || exit
run_cmd "${venv_python} -m pip install pip --upgrade" || exit
run_cmd "${venv_python} -m pip install -r ${build_dir}/requirements-build.txt" || exit
fi
# Debug
if [ "${debug}" = "true" ]; then
# Check that all required Python packages are installed and available in PATH
awk '!/^\s*($|#)/ {print $1}' "${build_dir}/requirements-build.txt" | while read -r pkg; do
if [ "${pkg}" = "pyelftools" ]; then
continue
fi
run_cmd "which ${pkg}" || exit
done
run_cmd "which python" || true
run_cmd "which python3" || true
run_cmd "cat /etc/uv/uv.toml" || true
run_cmd "which uv" || true
run_cmd "echo $PATH" || true
run_cmd "echo $VIRTUAL_ENV" || true
fi
# Build DAOS dependencies
scons="${venv_python} -m SCons"
run_cmd "${scons} -C ${build_dir} --jobs ${build_jobs} --build-deps=only" || exit
if [[ -n ${mount_dir-} ]]; then
# Run filesystem tests to verify the build.
run_cmd "daos filesystem query ${mount_dir}" || exit
run_cmd "daos filesystem evict ${build_dir}" || exit
run_cmd "daos filesystem query ${mount_dir}" || exit
fi
# Build and install DAOS
run_cmd "${scons} -C ${build_dir} --jobs ${build_jobs}" || exit
run_cmd "${scons} -C ${build_dir} --jobs ${build_jobs} install --implicit-deps-unchanged" || exit
if [[ -n ${mount_dir-} ]]; then
run_cmd "daos filesystem query ${mount_dir}" || exit
fi
full_end=$(date +%s)
full_time=$((full_end - full_start))
echo "DAOS build and installation completed successfully in ${full_time}s"
exit 0