2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
6 . "$(dirname "$(readlink -f "$0")")"/run-library.sh || exit 1
8 read -rd "\000" helpmessage <<EOF
9 $(basename "$0"): Build Arvados packages
12 WORKSPACE=/path/to/arvados $(basename "$0") [options]
16 --build-bundle-packages (default: false)
17 Build api server and workbench packages with vendor/bundle included
19 Output debug information (default: false)
21 Distribution to build packages for (default: debian10)
22 --only-build <package>
23 Build only a specific package (or ONLY_BUILD from environment)
25 Build a specific architecture (or ARCH from environment, defaults to native architecture)
27 Build even if the package exists upstream or if it has already been
30 Build command to execute (defaults to the run command defined in the
33 WORKSPACE=path Path to the Arvados source tree to build packages from
37 # Begin of user configuration
39 # set to --no-cache-dir to disable pip caching
42 MAINTAINER="Arvados Package Maintainers <packaging@arvados.org>"
43 VENDOR="The Arvados Project"
45 # End of user configuration
47 DEBUG=${ARVADOS_DEBUG:-0}
48 FORCE_BUILD=${FORCE_BUILD:-0}
53 PARSEDOPTS=$(getopt --name "$0" --longoptions \
54 help,build-bundle-packages,debug,target:,only-build:,arch:,force-build \
60 eval set -- "$PARSEDOPTS"
61 while [ $# -gt 0 ]; do
64 echo >&2 "$helpmessage"
72 ONLY_BUILD="$2"; shift
88 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
96 if [[ "$COMMAND" != "" ]]; then
97 COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET"
100 STDOUT_IF_DEBUG=/dev/null
101 STDERR_IF_DEBUG=/dev/null
102 DASHQ_UNLESS_DEBUG=-q
103 if [[ "$DEBUG" != 0 ]]; then
104 STDOUT_IF_DEBUG=/dev/stdout
105 STDERR_IF_DEBUG=/dev/stderr
109 declare -a PYTHON3_BACKPORTS
111 PYTHON3_EXECUTABLE=python3
112 PYTHON3_VERSION=$($PYTHON3_EXECUTABLE -c 'import sys; print("{v.major}.{v.minor}".format(v=sys.version_info))')
114 ## These defaults are suitable for any Debian-based distribution.
115 # You can customize them as needed in distro sections below.
116 PYTHON3_PACKAGE=python$PYTHON3_VERSION
117 PYTHON3_PKG_PREFIX=python3
119 PYTHON3_INSTALL_LIB=lib/python$PYTHON3_VERSION/dist-packages
120 ## End Debian Python defaults.
128 PYTHON3_EXECUTABLE=python3.8
129 PYTHON3_VERSION=$($PYTHON3_EXECUTABLE -c 'import sys; print("{v.major}.{v.minor}".format(v=sys.version_info))')
130 PYTHON3_PACKAGE=python$PYTHON3_VERSION
131 PYTHON3_INSTALL_LIB=lib/python$PYTHON3_VERSION/dist-packages
138 PYTHON3_PACKAGE=$(rpm -qf "$(which python"$PYTHON3_VERSION")" --queryformat '%{NAME}\n')
139 PYTHON3_PKG_PREFIX=$PYTHON3_PACKAGE
141 PYTHON3_INSTALL_LIB=lib/python$PYTHON3_VERSION/site-packages
142 export PYCURL_SSL_LIBRARY=nss
145 echo -e "$0: Unknown target '$TARGET'.\n" >&2
151 if [[ -z "$WORKSPACE" ]]; then
152 echo >&2 "$helpmessage"
154 echo >&2 "Error: WORKSPACE environment variable not set"
160 fpm --version >/dev/null 2>&1
162 if [[ $? -ne 0 ]]; then
163 echo >&2 "$helpmessage"
165 echo >&2 "Error: fpm not found"
170 RUN_BUILD_PACKAGES_PATH="$(dirname "$0")"
171 RUN_BUILD_PACKAGES_PATH="$(cd "$RUN_BUILD_PACKAGES_PATH" && pwd)" # absolutized and normalized
172 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
173 # error; for some reason, the path is not accessible
174 # to the script (e.g. permissions re-evaled after suid)
178 debug_echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
179 debug_echo "Workspace is $WORKSPACE"
181 if [[ -f /etc/profile.d/rvm.sh ]]; then
182 source /etc/profile.d/rvm.sh
183 GEM="rvm-exec default gem"
188 # Make all files world-readable -- jenkins runs with umask 027, and has checked
189 # out our git tree here
190 chmod o+r "$WORKSPACE" -R
192 # More cleanup - make sure all executables that we'll package are 755
193 cd "$WORKSPACE" || exit 1
194 find . -type d -name 'bin' -print0 |xargs -0 -I {} find {} -type f -print0 |xargs -0 -I {} chmod 755 {}
196 # Now fix our umask to something better suited to building and publishing
200 debug_echo "umask is" "$(umask)"
202 if [[ ! -d "$WORKSPACE/packages/$TARGET" ]]; then
203 mkdir -p "$WORKSPACE/packages/$TARGET"
204 chown --reference="$WORKSPACE" "$WORKSPACE/packages/$TARGET"
207 # Required due to CVE-2022-24765
208 git config --global --add safe.directory /arvados
211 debug_echo -e "\nRuby gems\n"
213 FPM_GEM_PREFIX=$($GEM environment gemdir)
215 cd "$WORKSPACE/sdk/ruby" || exit 1
216 handle_ruby_gem arvados
218 cd "$WORKSPACE/sdk/cli" || exit 1
219 handle_ruby_gem arvados-cli
221 cd "$WORKSPACE/services/login-sync" || exit 1
222 handle_ruby_gem arvados-login-sync
228 debug_echo -e "\nGo packages\n"
232 package_go_binary cmd/arvados-client arvados-client "$FORMAT" "$ARCH" \
233 "Arvados command line tool (beta)"
234 package_go_binary cmd/arvados-server arvados-server "$FORMAT" "$ARCH" \
235 "Arvados server daemons"
236 package_go_binary cmd/arvados-server arvados-controller "$FORMAT" "$ARCH" \
237 "Arvados cluster controller daemon"
238 package_go_binary cmd/arvados-server arvados-dispatch-cloud "$FORMAT" "$ARCH" \
239 "Arvados cluster cloud dispatch"
240 package_go_binary cmd/arvados-server arvados-dispatch-lsf "$FORMAT" "$ARCH" \
241 "Dispatch Arvados containers to an LSF cluster"
242 package_go_binary cmd/arvados-server arvados-git-httpd "$FORMAT" "$ARCH" \
243 "Provide authenticated http access to Arvados-hosted git repositories"
244 package_go_binary services/crunch-dispatch-local crunch-dispatch-local "$FORMAT" "$ARCH" \
245 "Dispatch Crunch containers on the local system"
246 package_go_binary cmd/arvados-server crunch-dispatch-slurm "$FORMAT" "$ARCH" \
247 "Dispatch Crunch containers to a SLURM cluster"
248 package_go_binary cmd/arvados-server crunch-run "$FORMAT" "$ARCH" \
249 "Supervise a single Crunch container"
250 package_go_binary services/crunchstat crunchstat "$FORMAT" "$ARCH" \
251 "Gather cpu/memory/network statistics of running Crunch jobs"
252 package_go_binary cmd/arvados-server arvados-health "$FORMAT" "$ARCH" \
253 "Check health of all Arvados cluster services"
254 package_go_binary cmd/arvados-server keep-balance "$FORMAT" "$ARCH" \
255 "Rebalance and garbage-collect data blocks stored in Arvados Keep"
256 package_go_binary cmd/arvados-server keepproxy "$FORMAT" "$ARCH" \
257 "Make a Keep cluster accessible to clients that are not on the LAN"
258 package_go_binary cmd/arvados-server keepstore "$FORMAT" "$ARCH" \
259 "Keep storage daemon, accessible to clients on the LAN"
260 package_go_binary cmd/arvados-server keep-web "$FORMAT" "$ARCH" \
261 "Static web hosting service for user data stored in Arvados Keep"
262 package_go_binary cmd/arvados-server arvados-ws "$FORMAT" "$ARCH" \
263 "Arvados Websocket server"
264 package_go_binary tools/sync-groups arvados-sync-groups "$FORMAT" "$ARCH" \
265 "Synchronize remote groups into Arvados from an external source"
266 package_go_binary tools/sync-users arvados-sync-users "$FORMAT" "$ARCH" \
267 "Synchronize remote users into Arvados from an external source"
268 package_go_binary tools/keep-block-check keep-block-check "$FORMAT" "$ARCH" \
269 "Verify that all data from one set of Keep servers to another was copied"
270 package_go_binary tools/keep-rsync keep-rsync "$FORMAT" "$ARCH" \
271 "Copy all data from one set of Keep servers to another"
272 package_go_binary tools/keep-exercise keep-exercise "$FORMAT" "$ARCH" \
273 "Performance testing tool for Arvados Keep"
274 package_go_so lib/pam pam_arvados.so libpam-arvados-go "$FORMAT" "$ARCH" \
275 "Arvados PAM authentication module"
278 debug_echo -e "\nPython packages\n"
280 # The Python SDK - Python3 package
281 fpm_build_virtualenv "arvados-python-client" "sdk/python" "$FORMAT" "$ARCH"
283 # Arvados cwl runner - Python3 package
284 fpm_build_virtualenv "arvados-cwl-runner" "sdk/cwl" "$FORMAT" "$ARCH"
286 # The FUSE driver - Python3 package
287 fpm_build_virtualenv "arvados-fuse" "services/fuse" "$FORMAT" "$ARCH"
289 # The Arvados crunchstat-summary tool
290 fpm_build_virtualenv "crunchstat-summary" "tools/crunchstat-summary" "$FORMAT" "$ARCH"
292 # The Docker image cleaner
293 fpm_build_virtualenv "arvados-docker-cleaner" "services/dockercleaner" "$FORMAT" "$ARCH"
295 # The Arvados user activity tool
296 fpm_build_virtualenv "arvados-user-activity" "tools/user-activity" "$FORMAT" "$ARCH"
298 # The python->python3 metapackages
299 build_metapackage "arvados-fuse" "services/fuse"
300 build_metapackage "arvados-python-client" "services/fuse"
301 build_metapackage "arvados-cwl-runner" "sdk/cwl"
302 build_metapackage "crunchstat-summary" "tools/crunchstat-summary"
303 build_metapackage "arvados-docker-cleaner" "services/dockercleaner"
304 build_metapackage "arvados-user-activity" "tools/user-activity"
306 # The cwltest package, which lives out of tree
307 handle_cwltest "$FORMAT" "$ARCH"
310 debug_echo -e "\nRails packages\n"
312 # The rails api server package
313 handle_api_server "$ARCH"
314 # The rails workbench package
315 handle_workbench "$ARCH"
317 # clean up temporary GOPATH