2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
6 # A library of functions shared by the various scripts in this directory.
8 # This is the timestamp about when we merged changed to include licenses
9 # with Arvados packages. We use it as a heuristic to add revisions for
11 LICENSE_PACKAGE_TS=20151208015500
13 if [[ -z "$ARVADOS_BUILDING_VERSION" ]]; then
14 RAILS_PACKAGE_ITERATION=1
16 RAILS_PACKAGE_ITERATION="$ARVADOS_BUILDING_ITERATION"
20 echo "$@" >"$STDOUT_IF_DEBUG"
23 find_python_program() {
27 if "$prog" --version >/dev/null 2>&1; then
35 Error: $prog (from Python setuptools module) not found
41 format_last_commit_here() {
42 local format="$1"; shift
43 local dir="${1:-.}"; shift
44 TZ=UTC git log -n1 --first-parent "--format=format:$format" "$dir"
48 # Output the version being built, or if we're building a
49 # dev/prerelease, output a version number based on the git log for
51 local subdir="$1"; shift
52 if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then
53 echo "$ARVADOS_BUILDING_VERSION"
58 declare $(format_last_commit_here "git_ts=%ct git_hash=%h" "$subdir")
59 ARVADOS_BUILDING_VERSION="$($WORKSPACE/build/version-at-commit.sh $git_hash)"
60 echo "$ARVADOS_BUILDING_VERSION"
63 nohash_version_from_git() {
64 local subdir="$1"; shift
65 if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then
66 echo "$ARVADOS_BUILDING_VERSION"
69 version_from_git $subdir | cut -d. -f1-4
72 timestamp_from_git() {
73 local subdir="$1"; shift
74 format_last_commit_here "%ct" "$subdir"
77 calculate_python_sdk_cwl_package_versions() {
78 python_sdk_version=$(cd sdk/python && python3 arvados_version.py)
79 cwl_runner_version=$(cd sdk/cwl && python3 arvados_version.py)
82 # Usage: get_native_arch
84 # Only amd64 and aarch64 are supported at the moment
94 echo "Error: architecture not supported"
102 local gem_name="$1"; shift
103 local gem_version="$(nohash_version_from_git)"
104 local gem_src_dir="$(pwd)"
106 if [[ -n "$ONLY_BUILD" ]] && [[ "$gem_name" != "$ONLY_BUILD" ]] ; then
110 if ! [[ -e "${gem_name}-${gem_version}.gem" ]]; then
111 find -maxdepth 1 -name "${gem_name}-*.gem" -delete
113 # -q appears to be broken in gem version 2.2.2
114 $GEM build "$gem_name.gemspec" $DASHQ_UNLESS_DEBUG >"$STDOUT_IF_DEBUG" 2>"$STDERR_IF_DEBUG"
118 calculate_go_package_version() {
119 # $__returnvar has the nameref attribute set, which means it is a reference
120 # to another variable that is passed in as the first argument to this function.
121 # see https://www.gnu.org/software/bash/manual/html_node/Shell-Parameters.html
122 local -n __returnvar="$1"; shift
128 # Update the version number and build a new package if the vendor
129 # bundle has changed, or the command imports anything from the
130 # Arvados SDK and the SDK has changed.
131 declare -a checkdirs=(go.mod go.sum)
132 while [ -n "$1" ]; do
136 # Even our rails packages (version calculation happens here!) depend on a go component (arvados-server)
137 # Everything depends on the build directory.
138 checkdirs+=(sdk/go lib build)
140 for dir in ${checkdirs[@]}; do
142 ts="$(timestamp_from_git "$dir")"
143 if [[ "$ts" -gt "$timestamp" ]]; then
144 version=$(version_from_git "$dir")
149 __returnvar="$version"
152 # Usage: package_go_binary services/foo arvados-foo [deb|rpm] [amd64|arm64] "Compute foo to arbitrary precision" [apache-2.0.txt]
153 package_go_binary() {
154 local src_path="$1"; shift
155 local prog="$1"; shift
156 local package_format="$1"; shift
157 local target_arch="$1"; shift
158 local description="$1"; shift
159 local license_file="${1:-agpl-3.0.txt}"; shift
161 if [[ -n "$ONLY_BUILD" ]] && [[ "$prog" != "$ONLY_BUILD" ]]; then
162 # arvados-workbench depends on arvados-server at build time, so even when
163 # only arvados-workbench is being built, we need to build arvados-server too
164 if [[ "$prog" != "arvados-server" ]] || [[ "$ONLY_BUILD" != "arvados-workbench" ]]; then
165 debug_echo -e "Skipping build of $prog package."
170 native_arch=$(get_native_arch)
172 if [[ "$native_arch" != "amd64" ]] && [[ -n "$target_arch" ]] && [[ "$native_arch" != "$target_arch" ]]; then
173 echo "Error: no cross compilation support for Go on $native_arch, can not build $prog for $target_arch"
177 case "$package_format-$TARGET" in
178 # Older Debian/Ubuntu do not support cross compilation because the
179 # libfuse package does not support multiarch. See
180 # <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477>.
181 # Red Hat-based distributions do not support native cross compilation at
182 # all (they use a qemu-based solution we haven't implemented yet).
183 deb-debian10|deb-ubuntu1804|deb-ubuntu2004|rpm-*)
185 if [[ "$native_arch" == "amd64" ]] && [[ -n "$target_arch" ]] && [[ "$native_arch" != "$target_arch" ]]; then
186 echo "Error: no cross compilation support for Go on $native_arch for $TARGET, can not build $prog for $target_arch"
195 if [[ -n "$target_arch" ]]; then
198 # No target architecture specified, default to native target. When on amd64
199 # also crosscompile arm64 (when supported).
201 if [[ $cross_compilation -ne 0 ]]; then
206 for ta in ${archs[@]}; do
207 package_go_binary_worker "$src_path" "$prog" "$package_format" "$description" "$native_arch" "$ta" "$license_file"
209 if [[ $retval -ne 0 ]]; then
215 # Usage: package_go_binary services/foo arvados-foo deb "Compute foo to arbitrary precision" [amd64/arm64] [amd64/arm64] [apache-2.0.txt]
216 package_go_binary_worker() {
217 local src_path="$1"; shift
218 local prog="$1"; shift
219 local package_format="$1"; shift
220 local description="$1"; shift
221 local native_arch="${1:-amd64}"; shift
222 local target_arch="${1:-amd64}"; shift
223 local license_file="${1:-agpl-3.0.txt}"; shift
225 debug_echo "package_go_binary $src_path as $prog (native arch: $native_arch, target arch: $target_arch)"
226 local basename="${src_path##*/}"
227 calculate_go_package_version go_package_version $src_path
229 cd $WORKSPACE/packages/$TARGET
230 test_package_presence "$prog" "$go_package_version" "go" "" "$target_arch"
231 if [[ $? -ne 0 ]]; then
235 echo "Building $package_format ($target_arch) package for $prog from $src_path"
236 if [[ "$native_arch" == "amd64" ]] && [[ "$target_arch" == "arm64" ]]; then
237 CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc GOARCH=${target_arch} go install -ldflags "-X git.arvados.org/arvados.git/lib/cmd.version=${go_package_version} -X main.version=${go_package_version}" "git.arvados.org/arvados.git/$src_path"
239 GOARCH=${arch} go install -ldflags "-X git.arvados.org/arvados.git/lib/cmd.version=${go_package_version} -X main.version=${go_package_version}" "git.arvados.org/arvados.git/$src_path"
244 binpath=$GOPATH/bin/${basename}
245 if [[ "${target_arch}" != "${native_arch}" ]]; then
246 switches+=("-a${target_arch}")
247 binpath="$GOPATH/bin/linux_${target_arch}/${basename}"
250 systemd_unit="$WORKSPACE/${src_path}/${prog}.service"
251 if [[ -e "${systemd_unit}" ]]; then
253 --after-install "${WORKSPACE}/build/go-python-package-scripts/postinst"
254 --before-remove "${WORKSPACE}/build/go-python-package-scripts/prerm"
255 "${systemd_unit}=/lib/systemd/system/${prog}.service")
257 switches+=("$WORKSPACE/${license_file}=/usr/share/doc/$prog/${license_file}")
259 fpm_build "${WORKSPACE}/${src_path}" "$binpath=/usr/bin/${prog}" "${prog}" dir "${go_package_version}" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=${description}" "${switches[@]}"
262 # Usage: package_go_so lib/foo arvados_foo.so arvados-foo deb amd64 "Arvados foo library"
264 local src_path="$1"; shift
265 local sofile="$1"; shift
266 local pkg="$1"; shift
267 local package_format="$1"; shift
268 local target_arch="$1"; shift # supported: amd64, arm64
269 local description="$1"; shift
271 if [[ -n "$ONLY_BUILD" ]] && [[ "$pkg" != "$ONLY_BUILD" ]]; then
272 debug_echo -e "Skipping build of $pkg package."
276 debug_echo "package_go_so $src_path as $pkg"
278 calculate_go_package_version go_package_version $src_path
279 cd $WORKSPACE/packages/$TARGET
280 test_package_presence $pkg $go_package_version go || return 1
281 cd $WORKSPACE/$src_path
282 go build -buildmode=c-shared -o ${GOPATH}/bin/${sofile}
283 cd $WORKSPACE/packages/$TARGET
285 "--url=https://arvados.org"
286 "--license=Apache License, Version 2.0"
287 "--description=${description}"
288 "$WORKSPACE/apache-2.0.txt=/usr/share/doc/$pkg/apache-2.0.txt"
290 if [[ -e "$WORKSPACE/$src_path/pam-configs-arvados" ]]; then
291 fpmargs+=("$WORKSPACE/$src_path/pam-configs-arvados=/usr/share/doc/$pkg/pam-configs-arvados-go")
293 if [[ -e "$WORKSPACE/$src_path/README" ]]; then
294 fpmargs+=("$WORKSPACE/$src_path/README=/usr/share/doc/$pkg/README")
296 fpm_build "${WORKSPACE}/${src_path}" "$GOPATH/bin/${sofile}=/usr/lib/${sofile}" "${pkg}" dir "${go_package_version}" "${fpmargs[@]}"
299 default_iteration() {
300 if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then
301 echo "$ARVADOS_BUILDING_ITERATION"
304 local package_name="$1"; shift
305 local package_version="$1"; shift
306 local package_type="$1"; shift
308 if [[ $package_version =~ ^0\.1\.([0-9]{14})(\.|$) ]] && \
309 [[ ${BASH_REMATCH[1]} -le $LICENSE_PACKAGE_TS ]]; then
315 _build_rails_package_scripts() {
316 local pkgname="$1"; shift
317 local destdir="$1"; shift
318 local srcdir="$RUN_BUILD_PACKAGES_PATH/rails-package-scripts"
319 for scriptname in postinst prerm postrm; do
320 cat "$srcdir/$pkgname.sh" "$srcdir/step2.sh" "$srcdir/$scriptname.sh" \
321 >"$destdir/$scriptname" || return $?
325 rails_package_version() {
326 local pkgname="$1"; shift
327 local srcdir="$1"; shift
328 if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then
329 echo "$ARVADOS_BUILDING_VERSION"
332 local version="$(version_from_git)"
333 if [ $pkgname = "arvados-api-server" -o $pkgname = "arvados-workbench" ] ; then
334 calculate_go_package_version version cmd/arvados-server "$srcdir"
339 test_rails_package_presence() {
340 local pkgname="$1"; shift
341 local srcdir="$1"; shift
343 if [[ -n "$ONLY_BUILD" ]] && [[ "$pkgname" != "$ONLY_BUILD" ]] ; then
351 local version="$(rails_package_version "$pkgname" "$srcdir")"
355 test_package_presence $pkgname $version rails "$RAILS_PACKAGE_ITERATION"
358 get_complete_package_name() {
359 # if the errexit flag is set, unset it until this function returns
360 # otherwise, the shift calls below will abort the program if optional arguments are not supplied
361 if [ -o errexit ]; then
365 # $__returnvar has the nameref attribute set, which means it is a reference
366 # to another variable that is passed in as the first argument to this function.
367 # see https://www.gnu.org/software/bash/manual/html_node/Shell-Parameters.html
368 local -n __returnvar="$1"; shift
369 local pkgname="$1"; shift
370 local version="$1"; shift
371 local pkgtype="$1"; shift
372 local iteration="$1"; shift
373 local arch="$1"; shift
374 if [[ "$iteration" == "" ]]; then
375 iteration="$(default_iteration "$pkgname" "$version" "$pkgtype")"
378 if [[ "$arch" == "" ]]; then
379 native_arch=$(get_native_arch)
380 rpm_native_arch="x86_64"
381 if [[ "$HOSTTYPE" == "aarch64" ]]; then
382 rpm_native_arch="arm64"
384 rpm_architecture="$rpm_native_arch"
385 deb_architecture="$native_arch"
387 if [[ "$pkgtype" =~ ^(src)$ ]]; then
388 rpm_architecture="noarch"
389 deb_architecture="all"
392 rpm_architecture=$arch
393 deb_architecture=$arch
396 local complete_pkgname="${pkgname}_$version${iteration:+-$iteration}_$deb_architecture.deb"
397 if [[ "$FORMAT" == "rpm" ]]; then
398 # rpm packages get iteration 1 if we don't supply one
399 iteration=${iteration:-1}
400 complete_pkgname="$pkgname-$version-${iteration}.$rpm_architecture.rpm"
402 __returnvar=${complete_pkgname}
405 # Test if the package already exists, if not return 0, if it does return 1
406 test_package_presence() {
407 local pkgname="$1"; shift
408 local version="$1"; shift
409 local pkgtype="$1"; shift
410 local iteration="$1"; shift
411 local arch="$1"; shift
412 if [[ -n "$ONLY_BUILD" ]] && [[ "$pkgname" != "$ONLY_BUILD" ]] ; then
413 # arvados-workbench depends on arvados-server at build time, so even when
414 # only arvados-workbench is being built, we need to build arvados-server too
415 if [[ "$pkgname" != "arvados-server" ]] || [[ "$ONLY_BUILD" != "arvados-workbench" ]]; then
421 get_complete_package_name full_pkgname "$pkgname" "$version" "$pkgtype" "$iteration" "$arch"
423 # See if we can skip building the package, only if it already exists in the
424 # processed/ directory. If so, move it back to the packages directory to make
425 # sure it gets picked up by the test and/or upload steps.
426 # Get the list of packages from the repos
428 if [[ "$FORCE_BUILD" == "1" ]]; then
429 echo "Package $full_pkgname build forced with --force-build, building"
430 elif [[ "$FORMAT" == "deb" ]]; then
433 dd[debian11]=bullseye
434 dd[ubuntu1804]=bionic
437 if [ ${pkgname:0:3} = "lib" ]; then
438 repo_subdir=${pkgname:0:4}
440 repo_subdir=${pkgname:0:1}
443 repo_pkg_list=$(curl -s -o - http://apt.arvados.org/${D}/pool/main/${repo_subdir}/${pkgname}/)
444 echo "${repo_pkg_list}" |grep -q ${full_pkgname}
445 if [ $? -eq 0 ] ; then
446 echo "Package $full_pkgname exists upstream, not rebuilding, downloading instead!"
447 curl -s -o "$WORKSPACE/packages/$TARGET/${full_pkgname}" http://apt.arvados.org/${D}/pool/main/${repo_subdir}/${pkgname}/${full_pkgname}
449 elif test -f "$WORKSPACE/packages/$TARGET/processed/${full_pkgname}" ; then
450 echo "Package $full_pkgname exists, not rebuilding!"
453 echo "Package $full_pkgname not found, building"
459 centos7) rpm_root="CentOS/7/dev" ;;
460 rocky8) rpm_root="CentOS/8/dev" ;;
462 echo "FIXME: Don't know RPM URL path for $TARGET, building"
466 local centos_repo="http://rpm.arvados.org/$rpm_root/$arch/"
468 repo_pkg_list=$(curl -s -o - ${centos_repo})
469 echo ${repo_pkg_list} |grep -q ${full_pkgname}
470 if [ $? -eq 0 ]; then
471 echo "Package $full_pkgname exists upstream, not rebuilding, downloading instead!"
472 curl -s -o "$WORKSPACE/packages/$TARGET/${full_pkgname}" ${centos_repo}${full_pkgname}
474 elif test -f "$WORKSPACE/packages/$TARGET/processed/${full_pkgname}" ; then
475 echo "Package $full_pkgname exists, not rebuilding!"
478 echo "Package $full_pkgname not found, building"
484 handle_rails_package() {
485 local pkgname="$1"; shift
487 if [[ -n "$ONLY_BUILD" ]] && [[ "$pkgname" != "$ONLY_BUILD" ]] ; then
490 local srcdir="$1"; shift
492 local license_path="$1"; shift
493 local version="$(rails_package_version "$pkgname" "$srcdir")"
494 echo "$version" >package-build.version
495 local scripts_dir="$(mktemp --tmpdir -d "$pkgname-XXXXXXXX.scripts")" && \
498 _build_rails_package_scripts "$pkgname" "$scripts_dir"
501 git rev-parse HEAD >git-commit.version
502 bundle config set cache_all true
505 if [[ 0 != "$?" ]] || ! cd "$WORKSPACE/packages/$TARGET"; then
506 echo "ERROR: $pkgname package prep failed" >&2
507 rm -rf "$scripts_dir"
511 local railsdir="/var/www/${pkgname%-server}/current"
512 local -a pos_args=("$srcdir/=$railsdir" "$pkgname" dir "$version")
513 local license_arg="$license_path=$railsdir/$(basename "$license_path")"
514 local -a switches=(--after-install "$scripts_dir/postinst"
515 --before-remove "$scripts_dir/prerm"
516 --after-remove "$scripts_dir/postrm")
517 if [[ -z "$ARVADOS_BUILDING_VERSION" ]]; then
518 switches+=(--iteration $RAILS_PACKAGE_ITERATION)
520 # For some reason fpm excludes need to not start with /.
521 local exclude_root="${railsdir#/}"
522 local -a exclude_list=(tmp log coverage Capfile\* \
523 config/deploy\* config/application.yml)
524 # for arvados-workbench, we need to have the (dummy) config/database.yml in the package
525 if [[ "$pkgname" != "arvados-workbench" ]]; then
526 exclude_list+=('config/database.yml')
528 for exclude in ${exclude_list[@]}; do
529 switches+=(-x "$exclude_root/$exclude")
531 fpm_build "${srcdir}" "${pos_args[@]}" "${switches[@]}" \
532 -x "$exclude_root/vendor/cache-*" \
533 -x "$exclude_root/vendor/bundle" "$@" "$license_arg"
534 rm -rf "$scripts_dir"
537 # Usage: handle_api_server [amd64|arm64]
538 handle_api_server () {
539 local target_arch="${1:-amd64}"; shift
541 if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "arvados-api-server" ]] ; then
542 debug_echo -e "Skipping build of arvados-api-server package."
546 native_arch=$(get_native_arch)
547 if [[ "$target_arch" != "$native_arch" ]]; then
548 echo "Error: no cross compilation support for Rails yet, can not build arvados-api-server for $ARCH"
553 # Build the API server package
554 test_rails_package_presence arvados-api-server "$WORKSPACE/services/api"
555 if [[ "$?" == "0" ]]; then
556 calculate_go_package_version arvados_server_version cmd/arvados-server
557 arvados_server_iteration=$(default_iteration "arvados-server" "$arvados_server_version" "go")
558 handle_rails_package arvados-api-server "$WORKSPACE/services/api" \
559 "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
560 --description="Arvados API server - Arvados is a free and open source platform for big data science." \
561 --license="GNU Affero General Public License, version 3.0" --depends "arvados-server = ${arvados_server_version}-${arvados_server_iteration}"
565 # Usage: handle_workbench [amd64|arm64]
566 handle_workbench () {
567 local target_arch="${1:-amd64}"; shift
568 if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "arvados-workbench" ]] ; then
569 debug_echo -e "Skipping build of arvados-workbench package."
573 native_arch=$(get_native_arch)
574 if [[ "$target_arch" != "$native_arch" ]]; then
575 echo "Error: no cross compilation support for Rails yet, can not build arvados-workbench for $native_arch"
580 if [[ "$native_arch" != "amd64" ]]; then
581 echo "Error: building the arvados-workbench package is not yet supported on this architecture ($native_arch)."
586 # Build the workbench server package
587 test_rails_package_presence arvados-workbench "$WORKSPACE/apps/workbench"
588 if [[ "$?" == "0" ]] ; then
589 calculate_go_package_version arvados_server_version cmd/arvados-server
590 arvados_server_iteration=$(default_iteration "arvados-server" "$arvados_server_version" "go")
595 # The workbench package has a build-time dependency on the arvados-server
596 # package for config manipulation, so install it first.
597 cd $WORKSPACE/cmd/arvados-server
598 get_complete_package_name arvados_server_pkgname arvados-server ${arvados_server_version} go
600 arvados_server_pkg_path="$WORKSPACE/packages/$TARGET/${arvados_server_pkgname}"
601 if [[ ! -e ${arvados_server_pkg_path} ]]; then
602 arvados_server_pkg_path="$WORKSPACE/packages/$TARGET/processed/${arvados_server_pkgname}"
604 if [[ "$FORMAT" == "deb" ]]; then
605 dpkg -i ${arvados_server_pkg_path}
607 rpm -i ${arvados_server_pkg_path}
610 cd "$WORKSPACE/apps/workbench"
612 # We need to bundle to be ready even when we build a package without vendor directory
613 # because asset compilation requires it.
614 bundle config set --local system 'true' >"$STDOUT_IF_DEBUG"
615 bundle install >"$STDOUT_IF_DEBUG"
617 # clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
618 # and we want that in the package, so it's easier to not exclude the tmp directory
619 # from the package - empty it instead.
623 # Set up an appropriate config.yml
624 arvados-server config-dump -config <(cat /etc/arvados/config.yml 2>/dev/null || echo "Clusters: {zzzzz: {}}") > /tmp/x
625 mkdir -p /etc/arvados/
626 mv /tmp/x /etc/arvados/config.yml
627 perl -p -i -e 'BEGIN{undef $/;} s/WebDAV(.*?):\n( *)ExternalURL: ""/WebDAV$1:\n$2ExternalURL: "example.com"/g' /etc/arvados/config.yml
629 ARVADOS_CONFIG=none RAILS_ENV=production RAILS_GROUPS=assets bin/rake npm:install >"$STDOUT_IF_DEBUG"
630 ARVADOS_CONFIG=none RAILS_ENV=production RAILS_GROUPS=assets bin/rake assets:precompile >"$STDOUT_IF_DEBUG"
632 # Remove generated configuration files so they don't go in the package.
636 if [[ "$?" != "0" ]]; then
637 echo "ERROR: Asset precompilation failed"
640 handle_rails_package arvados-workbench "$WORKSPACE/apps/workbench" \
641 "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
642 --description="Arvados Workbench - Arvados is a free and open source platform for big data science." \
643 --license="GNU Affero General Public License, version 3.0" --depends "arvados-server = ${arvados_server_version}-${arvados_server_iteration}"
648 # Usage: handle_cwltest [deb|rpm] [amd64|arm64]
650 local package_format="$1"; shift
651 local target_arch="${1:-amd64}"; shift
653 if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "python3-cwltest" ]] ; then
654 debug_echo -e "Skipping build of cwltest package."
658 if [[ -e "$WORKSPACE/cwltest" ]]; then
659 rm -rf "$WORKSPACE/cwltest"
661 git clone https://github.com/common-workflow-language/cwltest.git
662 # signal to our build script that we want a cwltest executable installed in /usr/bin/
663 mkdir cwltest/bin && touch cwltest/bin/cwltest
664 fpm_build_virtualenv "cwltest" "cwltest" "$package_format" "$target_arch"
665 # The python->python3 metapackage
666 build_metapackage "cwltest" "cwltest"
668 rm -rf "$WORKSPACE/cwltest"
671 # Usage: handle_arvados_src
672 handle_arvados_src () {
673 if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "arvados-src" ]] ; then
674 debug_echo -e "Skipping build of arvados-src package."
680 COMMIT_HASH=$(format_last_commit_here "%H")
681 arvados_src_version="$(version_from_git)"
683 cd $WORKSPACE/packages/$TARGET
684 test_package_presence arvados-src "$arvados_src_version" src ""
686 if [[ "$?" == "0" ]]; then
688 SRC_BUILD_DIR=$(mktemp -d)
689 # mktemp creates the directory with 0700 permissions by default
690 chmod 755 $SRC_BUILD_DIR
691 git clone $DASHQ_UNLESS_DEBUG "$WORKSPACE/.git" "$SRC_BUILD_DIR"
694 # go into detached-head state
695 git checkout $DASHQ_UNLESS_DEBUG "$COMMIT_HASH"
696 echo "$COMMIT_HASH" >git-commit.version
698 cd $WORKSPACE/packages/$TARGET
699 fpm_build "$WORKSPACE" $SRC_BUILD_DIR/=/usr/local/arvados/src arvados-src 'dir' "$arvados_src_version" "--exclude=usr/local/arvados/src/.git" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=The Arvados source code" "--architecture=all"
701 rm -rf "$SRC_BUILD_DIR"
706 # Build python packages with a virtualenv built-in
707 # Usage: fpm_build_virtualenv arvados-python-client sdk/python [deb|rpm] [amd64|arm64]
708 fpm_build_virtualenv () {
710 local pkg_dir=$1; shift
711 local package_format="$1"; shift
712 local target_arch="${1:-amd64}"; shift
714 native_arch=$(get_native_arch)
716 if [[ "$pkg" != "arvados-docker-cleaner" ]]; then
717 PYTHON_PKG=$PYTHON3_PKG_PREFIX-$pkg
719 # Exception to our package naming convention
723 if [[ -n "$ONLY_BUILD" ]] && [[ "$PYTHON_PKG" != "$ONLY_BUILD" ]]; then
724 # arvados-python-client sdist should always be built if we are building a
726 if [[ "$ONLY_BUILD" != "python3-arvados-cwl-runner" ]] &&
727 [[ "$ONLY_BUILD" != "python3-arvados-fuse" ]] &&
728 [[ "$ONLY_BUILD" != "python3-crunchstat-summary" ]] &&
729 [[ "$ONLY_BUILD" != "arvados-docker-cleaner" ]] &&
730 [[ "$ONLY_BUILD" != "python3-arvados-user-activity" ]]; then
731 debug_echo -e "Skipping build of $pkg package."
736 if [[ -n "$target_arch" ]] && [[ "$native_arch" == "$target_arch" ]]; then
737 fpm_build_virtualenv_worker "$pkg" "$pkg_dir" "$package_format" "$native_arch" "$target_arch"
738 elif [[ -z "$target_arch" ]]; then
739 fpm_build_virtualenv_worker "$pkg" "$pkg_dir" "$package_format" "$native_arch" "$native_arch"
741 echo "Error: no cross compilation support for Python yet, can not build $pkg for $target_arch"
746 # Build python packages with a virtualenv built-in
747 # Usage: fpm_build_virtualenv_worker arvados-python-client sdk/python python3 [deb|rpm] [amd64|arm64] [amd64|arm64]
748 fpm_build_virtualenv_worker () {
751 local package_format="$1"; shift
752 local native_arch="${1:-amd64}"; shift
753 local target_arch=${1:-amd64}; shift
756 STDOUT_IF_DEBUG=/dev/null
757 STDERR_IF_DEBUG=/dev/null
758 DASHQ_UNLESS_DEBUG=-q
759 if [[ "$DEBUG" != "0" ]]; then
760 STDOUT_IF_DEBUG=/dev/stdout
761 STDERR_IF_DEBUG=/dev/stderr
764 if [[ "$ARVADOS_BUILDING_ITERATION" == "" ]]; then
765 ARVADOS_BUILDING_ITERATION=1
768 local python=$PYTHON3_EXECUTABLE
770 PACKAGE_PREFIX=$PYTHON3_PKG_PREFIX
772 if [[ "$PKG" != "arvados-docker-cleaner" ]]; then
773 PYTHON_PKG=$PACKAGE_PREFIX-$PKG
775 # Exception to our package naming convention
779 cd $WORKSPACE/$PKG_DIR
783 # Get the latest setuptools
784 if ! $pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'; then
785 echo "Error, unable to upgrade setuptools with"
786 echo " $pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'"
789 # filter a useless warning (when building the cwltest package) from the stderr output
790 if ! $python setup.py $DASHQ_UNLESS_DEBUG sdist 2> >(grep -v 'warning: no previously-included files matching'); then
791 echo "Error, unable to run $python setup.py sdist for $PKG"
795 PACKAGE_PATH=`(cd dist; ls *tar.gz)`
797 if [[ "arvados-python-client" == "$PKG" ]]; then
798 PYSDK_PATH=`pwd`/dist/
801 if [[ -n "$ONLY_BUILD" ]] && [[ "$PYTHON_PKG" != "$ONLY_BUILD" ]] && [[ "$PKG" != "$ONLY_BUILD" ]]; then
805 # Determine the package version from the generated sdist archive
806 if [[ -n "$ARVADOS_BUILDING_VERSION" ]] ; then
807 UNFILTERED_PYTHON_VERSION=$ARVADOS_BUILDING_VERSION
808 PYTHON_VERSION=$(echo -n $ARVADOS_BUILDING_VERSION | sed s/~dev/.dev/g | sed s/~rc/rc/g)
810 PYTHON_VERSION=$(awk '($1 == "Version:"){print $2}' *.egg-info/PKG-INFO)
811 UNFILTERED_PYTHON_VERSION=$(echo -n $PYTHON_VERSION | sed s/\.dev/~dev/g |sed 's/\([0-9]\)rc/\1~rc/g')
814 # See if we actually need to build this package; does it exist already?
815 # We can't do this earlier than here, because we need PYTHON_VERSION...
816 # This isn't so bad; the sdist call above is pretty quick compared to
817 # the invocation of virtualenv and fpm, below.
818 if ! test_package_presence "$PYTHON_PKG" "$UNFILTERED_PYTHON_VERSION" "$python" "$ARVADOS_BUILDING_ITERATION" "$target_arch"; then
822 echo "Building $package_format ($target_arch) package for $PKG from $PKG_DIR"
824 # Package the sdist in a virtualenv
825 echo "Creating virtualenv..."
830 rm -f $PYTHON_PKG*deb
831 echo "virtualenv version: `virtualenv --version`"
832 virtualenv_command="virtualenv --python `which $python` $DASHQ_UNLESS_DEBUG build/usr/share/$python/dist/$PYTHON_PKG"
834 if ! $virtualenv_command; then
835 echo "Error, unable to run"
836 echo " $virtualenv_command"
840 if ! build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U pip; then
841 echo "Error, unable to upgrade pip with"
842 echo " build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U pip"
845 echo "pip version: `build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip --version`"
847 if ! build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'; then
848 echo "Error, unable to upgrade setuptools with"
849 echo " build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'"
852 echo "setuptools version: `build/usr/share/$python/dist/$PYTHON_PKG/bin/$python -c 'import setuptools; print(setuptools.__version__)'`"
854 if ! build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U wheel; then
855 echo "Error, unable to upgrade wheel with"
856 echo " build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U wheel"
859 echo "wheel version: `build/usr/share/$python/dist/$PYTHON_PKG/bin/wheel version`"
861 if [[ "$TARGET" != "centos7" ]] || [[ "$PYTHON_PKG" != "python-arvados-fuse" ]]; then
862 build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -f $PYSDK_PATH $PACKAGE_PATH
864 # centos7 needs these special tweaks to install python-arvados-fuse
865 build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG docutils
866 PYCURL_SSL_LIBRARY=nss build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -f $PYSDK_PATH $PACKAGE_PATH
869 if [[ "$?" != "0" ]]; then
870 echo "Error, unable to run"
871 echo " build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -f $PYSDK_PATH $PACKAGE_PATH"
875 cd build/usr/share/$python/dist/$PYTHON_PKG/
877 # Replace the shebang lines in all python scripts, and handle the activate
878 # scripts too. This is a functional replacement of the 237 line
879 # virtualenv_tools.py script that doesn't work in python3 without serious
880 # patching, minus the parts we don't need (modifying pyc files, etc).
881 for binfile in `ls bin/`; do
882 if ! file --mime bin/$binfile |grep -q binary; then
884 if [[ "$binfile" =~ ^activate(.csh|.fish|)$ ]]; then
885 # these 'activate' scripts need special treatment
886 sed -i "s/VIRTUAL_ENV=\".*\"/VIRTUAL_ENV=\"\/usr\/share\/$python\/dist\/$PYTHON_PKG\"/" bin/$binfile
887 sed -i "s/VIRTUAL_ENV \".*\"/VIRTUAL_ENV \"\/usr\/share\/$python\/dist\/$PYTHON_PKG\"/" bin/$binfile
889 if grep -q -E '^#!.*/bin/python\d?' bin/$binfile; then
890 # Replace shebang line
891 sed -i "1 s/^.*$/#!\/usr\/share\/$python\/dist\/$PYTHON_PKG\/bin\/python/" bin/$binfile
897 cd - >$STDOUT_IF_DEBUG
899 find build -iname '*.pyc' -exec rm {} \;
900 find build -iname '*.pyo' -exec rm {} \;
902 # Finally, generate the package
903 echo "Creating package..."
905 declare -a COMMAND_ARR=("fpm" "-s" "dir" "-t" "$package_format")
907 if [[ -n "$target_arch" ]] && [[ "$target_arch" != "amd64" ]]; then
908 COMMAND_ARR+=("-a$target_arch")
911 if [[ "$MAINTAINER" != "" ]]; then
912 COMMAND_ARR+=('--maintainer' "$MAINTAINER")
915 if [[ "$VENDOR" != "" ]]; then
916 COMMAND_ARR+=('--vendor' "$VENDOR")
919 COMMAND_ARR+=('--url' 'https://arvados.org')
922 DESCRIPTION=`grep '\sdescription' $WORKSPACE/$PKG_DIR/setup.py|cut -f2 -d=|sed -e "s/[',\\"]//g"`
923 COMMAND_ARR+=('--description' "$DESCRIPTION")
926 LICENSE_STRING=`grep license $WORKSPACE/$PKG_DIR/setup.py|cut -f2 -d=|sed -e "s/[',\\"]//g"`
927 COMMAND_ARR+=('--license' "$LICENSE_STRING")
929 if [[ "$DEBUG" != "0" ]]; then
930 COMMAND_ARR+=('--verbose' '--log' 'info')
933 COMMAND_ARR+=('-v' $(echo -n "$PYTHON_VERSION" | sed s/.dev/~dev/g | sed s/rc/~rc/g))
934 COMMAND_ARR+=('--iteration' "$ARVADOS_BUILDING_ITERATION")
935 COMMAND_ARR+=('-n' "$PYTHON_PKG")
936 COMMAND_ARR+=('-C' "build")
938 systemd_unit="$WORKSPACE/$PKG_DIR/$PKG.service"
939 if [[ -e "${systemd_unit}" ]]; then
940 COMMAND_ARR+=('--after-install' "${WORKSPACE}/build/go-python-package-scripts/postinst")
941 COMMAND_ARR+=('--before-remove' "${WORKSPACE}/build/go-python-package-scripts/prerm")
944 COMMAND_ARR+=('--depends' "$PYTHON3_PACKAGE")
945 case "$package_format" in
949 --deb-no-default-config-files
953 # Conflict with older packages we used to publish
954 --conflicts "rh-python36-python-$PKG"
955 # Do not generate /usr/lib/.build-id links on RH8+
956 # (otherwise our packages conflict with platform-python)
957 --rpm-rpmbuild-define "_build_id_links none"
961 # Append --depends X and other arguments specified by fpm-info.sh in
962 # the package source dir. These are added last so they can override
963 # the arguments added by this script.
964 declare -a fpm_args=()
965 declare -a fpm_depends=()
967 fpminfo="$WORKSPACE/$PKG_DIR/fpm-info.sh"
968 if [[ -e "$fpminfo" ]]; then
969 echo "Loading fpm overrides from $fpminfo"
970 if ! source "$fpminfo"; then
971 echo "Error, unable to source $WORKSPACE/$PKG_DIR/fpm-info.sh for $PKG"
976 for i in "${fpm_depends[@]}"; do
977 COMMAND_ARR+=('--depends' "$i")
980 for i in "${fpm_depends[@]}"; do
981 COMMAND_ARR+=('--replaces' "python-$PKG")
984 # make sure the systemd service file ends up in the right place
985 # used by arvados-docker-cleaner
986 if [[ -e "${systemd_unit}" ]]; then
987 COMMAND_ARR+=("usr/share/$python/dist/$PKG/share/doc/$PKG/$PKG.service=/lib/systemd/system/$PKG.service")
990 COMMAND_ARR+=("${fpm_args[@]}")
992 # Make sure to install all our package binaries in /usr/bin.
993 # We have to walk $WORKSPACE/$PKG_DIR/bin rather than
994 # $WORKSPACE/build/usr/share/$python/dist/$PYTHON_PKG/bin/ to get the list
995 # because the latter also includes all the python binaries for the virtualenv.
996 # We have to take the copies of our binaries from the latter directory, though,
997 # because those are the ones we rewrote the shebang line of, above.
998 if [[ -e "$WORKSPACE/$PKG_DIR/bin" ]]; then
999 for binary in `ls $WORKSPACE/$PKG_DIR/bin`; do
1000 COMMAND_ARR+=("usr/share/$python/dist/$PYTHON_PKG/bin/$binary=/usr/bin/")
1004 # the python3-arvados-cwl-runner package comes with cwltool, expose that version
1005 if [[ -e "$WORKSPACE/$PKG_DIR/dist/build/usr/share/$python/dist/$PYTHON_PKG/bin/cwltool" ]]; then
1006 COMMAND_ARR+=("usr/share/$python/dist/$PYTHON_PKG/bin/cwltool=/usr/bin/")
1011 debug_echo -e "\n${COMMAND_ARR[@]}\n"
1013 FPM_RESULTS=$("${COMMAND_ARR[@]}")
1016 # if something went wrong and debug is off, print out the fpm command that errored
1017 if ! fpm_verify $FPM_EXIT_CODE $FPM_RESULTS && [[ "$STDOUT_IF_DEBUG" == "/dev/null" ]]; then
1018 echo "fpm returned an error executing the command:"
1020 echo -e "\n${COMMAND_ARR[@]}\n"
1022 echo `ls *$package_format`
1023 mv $WORKSPACE/$PKG_DIR/dist/*$package_format $WORKSPACE/packages/$TARGET/
1028 # build_metapackage builds meta packages that help with the python to python 3 package migration
1029 build_metapackage() {
1030 # base package name (e.g. arvados-python-client)
1036 if [[ -n "$ONLY_BUILD" ]] && [[ "python-$BASE_NAME" != "$ONLY_BUILD" ]]; then
1040 if [[ "$ARVADOS_BUILDING_ITERATION" == "" ]]; then
1041 ARVADOS_BUILDING_ITERATION=1
1044 if [[ -z "$ARVADOS_BUILDING_VERSION" ]]; then
1045 cd $WORKSPACE/$PKG_DIR
1049 # Get the latest setuptools
1050 if ! pip3 install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'; then
1051 echo "Error, unable to upgrade setuptools with XY"
1052 echo " pip3 install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'"
1055 # filter a useless warning (when building the cwltest package) from the stderr output
1056 if ! python3 setup.py $DASHQ_UNLESS_DEBUG sdist 2> >(grep -v 'warning: no previously-included files matching'); then
1057 echo "Error, unable to run python3 setup.py sdist for $PKG"
1061 PYTHON_VERSION=$(awk '($1 == "Version:"){print $2}' *.egg-info/PKG-INFO)
1062 UNFILTERED_PYTHON_VERSION=$(echo -n $PYTHON_VERSION | sed s/\.dev/~dev/g |sed 's/\([0-9]\)rc/\1~rc/g')
1065 UNFILTERED_PYTHON_VERSION=$ARVADOS_BUILDING_VERSION
1066 PYTHON_VERSION=$(echo -n $ARVADOS_BUILDING_VERSION | sed s/~dev/.dev/g | sed s/~rc/rc/g)
1069 cd - >$STDOUT_IF_DEBUG
1070 if [[ -d "$BASE_NAME" ]]; then
1076 if [[ "$FORMAT" == "deb" ]]; then
1077 cat >ns-control <<EOF
1080 Standards-Version: 3.9.2
1082 Package: python-${BASE_NAME}
1083 Version: ${PYTHON_VERSION}-${ARVADOS_BUILDING_ITERATION}
1084 Maintainer: Arvados Package Maintainers <packaging@arvados.org>
1085 Depends: python3-${BASE_NAME}
1086 Description: metapackage to ease the upgrade to the Pyhon 3 version of ${BASE_NAME}
1087 This package is a metapackage that will automatically install the new version of
1088 ${BASE_NAME} which is Python 3 based and has a different name.
1091 /usr/bin/equivs-build ns-control
1092 if [[ $? -ne 0 ]]; then
1093 echo "Error running 'equivs-build ns-control', is the 'equivs' package installed?"
1096 elif [[ "$FORMAT" == "rpm" ]]; then
1097 cat >meta.spec <<EOF
1098 Summary: metapackage to ease the upgrade to the Python 3 version of ${BASE_NAME}
1099 Name: python-${BASE_NAME}
1100 Version: ${PYTHON_VERSION}
1101 Release: ${ARVADOS_BUILDING_ITERATION}
1102 License: distributable
1104 Requires: python3-${BASE_NAME}
1107 This package is a metapackage that will automatically install the new version of
1108 python-${BASE_NAME} which is Python 3 based and has a different name.
1124 * Mon Apr 12 2021 Arvados Package Maintainers <packaging@arvados.org>
1128 /usr/bin/rpmbuild -ba meta.spec
1129 if [[ $? -ne 0 ]]; then
1130 echo "Error running 'rpmbuild -ba meta.spec', is the 'rpm-build' package installed?"
1133 mv /root/rpmbuild/RPMS/x86_64/python-${BASE_NAME}*.${FORMAT} .
1134 if [[ $? -ne 0 ]]; then
1135 echo "Error finding rpm file output of 'rpmbuild -ba meta.spec'"
1140 echo "Unknown format"
1144 if [[ $EXITCODE -ne 0 ]]; then
1148 mv *$FORMAT $WORKSPACE/packages/$TARGET/
1152 cd - >$STDOUT_IF_DEBUG
1153 if [[ -d "$BASE_NAME" ]]; then
1158 # Build packages for everything
1160 # Source dir where fpm-info.sh (if any) will be found.
1163 # The package source. Depending on the source type, this can be a
1164 # path, or the name of the package in an upstream repository (e.g.,
1168 # The name of the package to build.
1171 # The type of source package. Passed to fpm -s. Default "dir".
1172 PACKAGE_TYPE=${1:-dir}
1174 # Optional: the package version number. Passed to fpm -v.
1178 if [[ -n "$ONLY_BUILD" ]] && [[ "$PACKAGE_NAME" != "$ONLY_BUILD" ]] && [[ "$PACKAGE" != "$ONLY_BUILD" ]] ; then
1179 # arvados-workbench depends on arvados-server at build time, so even when
1180 # only arvados-workbench is being built, we need to build arvados-server too
1181 if [[ "$PACKAGE_NAME" != "arvados-server" ]] || [[ "$ONLY_BUILD" != "arvados-workbench" ]]; then
1186 local default_iteration_value="$(default_iteration "$PACKAGE" "$VERSION" "$PACKAGE_TYPE")"
1188 declare -a COMMAND_ARR=("fpm" "-s" "$PACKAGE_TYPE" "-t" "$FORMAT")
1189 if [ python = "$PACKAGE_TYPE" ] && [ deb = "$FORMAT" ]; then
1190 # Dependencies are built from setup.py. Since setup.py will never
1191 # refer to Debian package iterations, it doesn't make sense to
1192 # enforce those in the .deb dependencies.
1193 COMMAND_ARR+=(--deb-ignore-iteration-in-dependencies)
1196 if [[ "$DEBUG" != "0" ]]; then
1197 COMMAND_ARR+=('--verbose' '--log' 'info')
1200 if [[ -n "$PACKAGE_NAME" ]]; then
1201 COMMAND_ARR+=('-n' "$PACKAGE_NAME")
1204 if [[ "$MAINTAINER" != "" ]]; then
1205 COMMAND_ARR+=('--maintainer' "$MAINTAINER")
1208 if [[ "$VENDOR" != "" ]]; then
1209 COMMAND_ARR+=('--vendor' "$VENDOR")
1212 if [[ "$VERSION" != "" ]]; then
1213 COMMAND_ARR+=('-v' "$VERSION")
1215 if [[ -n "$default_iteration_value" ]]; then
1216 # We can always add an --iteration here. If another one is specified in $@,
1217 # that will take precedence, as desired.
1218 COMMAND_ARR+=(--iteration "$default_iteration_value")
1221 # Append --depends X and other arguments specified by fpm-info.sh in
1222 # the package source dir. These are added last so they can override
1223 # the arguments added by this script.
1224 declare -a fpm_args=()
1225 declare -a build_depends=()
1226 declare -a fpm_depends=()
1227 declare -a fpm_conflicts=()
1228 declare -a fpm_exclude=()
1229 if [[ ! -d "$SRC_DIR" ]]; then
1230 echo >&2 "BUG: looking in wrong dir for fpm-info.sh: $pkgdir"
1233 fpminfo="${SRC_DIR}/fpm-info.sh"
1234 if [[ -e "$fpminfo" ]]; then
1235 debug_echo "Loading fpm overrides from $fpminfo"
1238 for pkg in "${build_depends[@]}"; do
1239 if [[ $TARGET =~ debian|ubuntu ]]; then
1240 pkg_deb=$(ls "$WORKSPACE/packages/$TARGET/$pkg_"*.deb | sort -rg | awk 'NR==1')
1241 if [[ -e $pkg_deb ]]; then
1242 echo "Installing build_dep $pkg from $pkg_deb"
1245 echo "Attemping to install build_dep $pkg using apt-get"
1246 apt-get install -y "$pkg"
1248 apt-get -y -f install
1250 pkg_rpm=$(ls "$WORKSPACE/packages/$TARGET/$pkg"-[0-9]*.rpm | sort -rg | awk 'NR==1')
1251 if [[ -e $pkg_rpm ]]; then
1252 echo "Installing build_dep $pkg from $pkg_rpm"
1255 echo "Attemping to install build_dep $pkg"
1260 for i in "${fpm_depends[@]}"; do
1261 COMMAND_ARR+=('--depends' "$i")
1263 for i in "${fpm_conflicts[@]}"; do
1264 COMMAND_ARR+=('--conflicts' "$i")
1266 for i in "${fpm_exclude[@]}"; do
1267 COMMAND_ARR+=('--exclude' "$i")
1270 COMMAND_ARR+=("${fpm_args[@]}")
1272 # Append remaining function arguments directly to fpm's command line.
1277 COMMAND_ARR+=("$PACKAGE")
1279 debug_echo -e "\n${COMMAND_ARR[@]}\n"
1281 FPM_RESULTS=$("${COMMAND_ARR[@]}")
1284 fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
1286 # if something went wrong and debug is off, print out the fpm command that errored
1287 if [[ 0 -ne $? ]] && [[ "$STDOUT_IF_DEBUG" == "/dev/null" ]]; then
1288 echo -e "\n${COMMAND_ARR[@]}\n"
1292 # verify build results
1299 if [[ $FPM_RESULTS =~ ([A-Za-z0-9_\.-]*\.)(deb|rpm) ]]; then
1300 FPM_PACKAGE_NAME=${BASH_REMATCH[1]}${BASH_REMATCH[2]}
1303 if [[ "$FPM_PACKAGE_NAME" == "" ]]; then
1306 echo "Error: $PACKAGE: Unable to figure out package name from fpm results:"
1311 elif [[ "$FPM_RESULTS" =~ "File already exists" ]]; then
1312 echo "Package $FPM_PACKAGE_NAME exists, not rebuilding"
1314 elif [[ 0 -ne "$FPM_EXIT_CODE" ]]; then
1316 echo "Error building package for $1:\n $FPM_RESULTS"
1323 if [[ "$FORMAT" == "deb" ]]; then
1324 $SUDO apt-get install $PACKAGES --yes
1325 elif [[ "$FORMAT" == "rpm" ]]; then
1326 $SUDO yum -q -y install $PACKAGES
1331 printf '%s %s\n' "=======" "$1"
1335 if [[ "$1" != "0" ]]; then
1336 title "$2 -- FAILED"
1337 failures+=("$2 (`timer`)")
1339 successes+=("$2 (`timer`)")
1348 if [[ -n "$t0" ]]; then
1349 echo -n "$(($SECONDS - $t0))s"
1354 for x in "${successes[@]}"
1359 if [[ ${#failures[@]} == 0 ]]
1361 if [[ ${#successes[@]} != 0 ]]; then
1362 echo "All test suites passed."
1365 echo "Failures (${#failures[@]}):"
1366 for x in "${failures[@]}"