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"
178 if [[ "$TARGET" == "centos7" ]]; then
179 if [[ "$native_arch" == "amd64" ]] && [[ -n "$target_arch" ]] && [[ "$native_arch" != "$target_arch" ]]; then
180 echo "Error: no cross compilation support for Go on $native_arch for $TARGET, can not build $prog for $target_arch"
186 if [[ "$package_format" == "deb" ]] &&
187 [[ "$TARGET" == "debian10" ]] || [[ "$TARGET" == "ubuntu1804" ]] || [[ "$TARGET" == "ubuntu2004" ]]; then
188 # Due to bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477 the libfuse-dev package for arm64 does
189 # not install properly side by side with the amd64 version before Debian 11.
190 if [[ "$native_arch" == "amd64" ]] && [[ -n "$target_arch" ]] && [[ "$native_arch" != "$target_arch" ]]; then
191 echo "Error: no cross compilation support for Go on $native_arch for $TARGET, can not build $prog for $target_arch"
197 if [[ -n "$target_arch" ]]; then
200 # No target architecture specified, default to native target. When on amd64
201 # also crosscompile arm64 (when supported).
203 if [[ $cross_compilation -ne 0 ]]; then
208 for ta in ${archs[@]}; do
209 package_go_binary_worker "$src_path" "$prog" "$package_format" "$description" "$native_arch" "$ta" "$license_file"
211 if [[ $retval -ne 0 ]]; then
217 # Usage: package_go_binary services/foo arvados-foo deb "Compute foo to arbitrary precision" [amd64/arm64] [amd64/arm64] [apache-2.0.txt]
218 package_go_binary_worker() {
219 local src_path="$1"; shift
220 local prog="$1"; shift
221 local package_format="$1"; shift
222 local description="$1"; shift
223 local native_arch="${1:-amd64}"; shift
224 local target_arch="${1:-amd64}"; shift
225 local license_file="${1:-agpl-3.0.txt}"; shift
227 debug_echo "package_go_binary $src_path as $prog (native arch: $native_arch, target arch: $target_arch)"
228 local basename="${src_path##*/}"
229 calculate_go_package_version go_package_version $src_path
231 cd $WORKSPACE/packages/$TARGET
232 test_package_presence "$prog" "$go_package_version" "go" "" "$target_arch"
233 if [[ $? -ne 0 ]]; then
237 echo "Building $package_format ($target_arch) package for $prog from $src_path"
238 if [[ "$native_arch" == "amd64" ]] && [[ "$target_arch" == "arm64" ]]; then
239 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"
241 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"
246 binpath=$GOPATH/bin/${basename}
247 if [[ "${target_arch}" != "${native_arch}" ]]; then
248 switches+=("-a${target_arch}")
249 binpath="$GOPATH/bin/linux_${target_arch}/${basename}"
252 systemd_unit="$WORKSPACE/${src_path}/${prog}.service"
253 if [[ -e "${systemd_unit}" ]]; then
255 --after-install "${WORKSPACE}/build/go-python-package-scripts/postinst"
256 --before-remove "${WORKSPACE}/build/go-python-package-scripts/prerm"
257 "${systemd_unit}=/lib/systemd/system/${prog}.service")
259 switches+=("$WORKSPACE/${license_file}=/usr/share/doc/$prog/${license_file}")
261 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[@]}"
264 # Usage: package_go_so lib/foo arvados_foo.so arvados-foo deb amd64 "Arvados foo library"
266 local src_path="$1"; shift
267 local sofile="$1"; shift
268 local pkg="$1"; shift
269 local package_format="$1"; shift
270 local target_arch="$1"; shift # supported: amd64, arm64
271 local description="$1"; shift
273 if [[ -n "$ONLY_BUILD" ]] && [[ "$pkg" != "$ONLY_BUILD" ]]; then
274 debug_echo -e "Skipping build of $pkg package."
278 debug_echo "package_go_so $src_path as $pkg"
280 calculate_go_package_version go_package_version $src_path
281 cd $WORKSPACE/packages/$TARGET
282 test_package_presence $pkg $go_package_version go || return 1
283 cd $WORKSPACE/$src_path
284 go build -buildmode=c-shared -o ${GOPATH}/bin/${sofile}
285 cd $WORKSPACE/packages/$TARGET
287 "--url=https://arvados.org"
288 "--license=Apache License, Version 2.0"
289 "--description=${description}"
290 "$WORKSPACE/apache-2.0.txt=/usr/share/doc/$pkg/apache-2.0.txt"
292 if [[ -e "$WORKSPACE/$src_path/pam-configs-arvados" ]]; then
293 fpmargs+=("$WORKSPACE/$src_path/pam-configs-arvados=/usr/share/doc/$pkg/pam-configs-arvados-go")
295 if [[ -e "$WORKSPACE/$src_path/README" ]]; then
296 fpmargs+=("$WORKSPACE/$src_path/README=/usr/share/doc/$pkg/README")
298 fpm_build "${WORKSPACE}/${src_path}" "$GOPATH/bin/${sofile}=/usr/lib/${sofile}" "${pkg}" dir "${go_package_version}" "${fpmargs[@]}"
301 default_iteration() {
302 if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then
303 echo "$ARVADOS_BUILDING_ITERATION"
306 local package_name="$1"; shift
307 local package_version="$1"; shift
308 local package_type="$1"; shift
310 if [[ $package_version =~ ^0\.1\.([0-9]{14})(\.|$) ]] && \
311 [[ ${BASH_REMATCH[1]} -le $LICENSE_PACKAGE_TS ]]; then
317 _build_rails_package_scripts() {
318 local pkgname="$1"; shift
319 local destdir="$1"; shift
320 local srcdir="$RUN_BUILD_PACKAGES_PATH/rails-package-scripts"
321 for scriptname in postinst prerm postrm; do
322 cat "$srcdir/$pkgname.sh" "$srcdir/step2.sh" "$srcdir/$scriptname.sh" \
323 >"$destdir/$scriptname" || return $?
327 rails_package_version() {
328 local pkgname="$1"; shift
329 local srcdir="$1"; shift
330 if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then
331 echo "$ARVADOS_BUILDING_VERSION"
334 local version="$(version_from_git)"
335 if [ $pkgname = "arvados-api-server" -o $pkgname = "arvados-workbench" ] ; then
336 calculate_go_package_version version cmd/arvados-server "$srcdir"
341 test_rails_package_presence() {
342 local pkgname="$1"; shift
343 local srcdir="$1"; shift
345 if [[ -n "$ONLY_BUILD" ]] && [[ "$pkgname" != "$ONLY_BUILD" ]] ; then
353 local version="$(rails_package_version "$pkgname" "$srcdir")"
357 test_package_presence $pkgname $version rails "$RAILS_PACKAGE_ITERATION"
360 get_complete_package_name() {
361 # if the errexit flag is set, unset it until this function returns
362 # otherwise, the shift calls below will abort the program if optional arguments are not supplied
363 if [ -o errexit ]; then
367 # $__returnvar has the nameref attribute set, which means it is a reference
368 # to another variable that is passed in as the first argument to this function.
369 # see https://www.gnu.org/software/bash/manual/html_node/Shell-Parameters.html
370 local -n __returnvar="$1"; shift
371 local pkgname="$1"; shift
372 local version="$1"; shift
373 local pkgtype="$1"; shift
374 local iteration="$1"; shift
375 local arch="$1"; shift
376 if [[ "$iteration" == "" ]]; then
377 iteration="$(default_iteration "$pkgname" "$version" "$pkgtype")"
380 if [[ "$arch" == "" ]]; then
381 native_arch=$(get_native_arch)
382 rpm_native_arch="x86_64"
383 if [[ "$HOSTTYPE" == "aarch64" ]]; then
384 rpm_native_arch="arm64"
386 rpm_architecture="$rpm_native_arch"
387 deb_architecture="$native_arch"
389 if [[ "$pkgtype" =~ ^(src)$ ]]; then
390 rpm_architecture="noarch"
391 deb_architecture="all"
394 rpm_architecture=$arch
395 deb_architecture=$arch
398 local complete_pkgname="${pkgname}_$version${iteration:+-$iteration}_$deb_architecture.deb"
399 if [[ "$FORMAT" == "rpm" ]]; then
400 # rpm packages get iteration 1 if we don't supply one
401 iteration=${iteration:-1}
402 complete_pkgname="$pkgname-$version-${iteration}.$rpm_architecture.rpm"
404 __returnvar=${complete_pkgname}
407 # Test if the package already exists, if not return 0, if it does return 1
408 test_package_presence() {
409 local pkgname="$1"; shift
410 local version="$1"; shift
411 local pkgtype="$1"; shift
412 local iteration="$1"; shift
413 local arch="$1"; shift
414 if [[ -n "$ONLY_BUILD" ]] && [[ "$pkgname" != "$ONLY_BUILD" ]] ; then
415 # arvados-workbench depends on arvados-server at build time, so even when
416 # only arvados-workbench is being built, we need to build arvados-server too
417 if [[ "$pkgname" != "arvados-server" ]] || [[ "$ONLY_BUILD" != "arvados-workbench" ]]; then
423 get_complete_package_name full_pkgname "$pkgname" "$version" "$pkgtype" "$iteration" "$arch"
425 # See if we can skip building the package, only if it already exists in the
426 # processed/ directory. If so, move it back to the packages directory to make
427 # sure it gets picked up by the test and/or upload steps.
428 # Get the list of packages from the repos
430 if [[ "$FORCE_BUILD" == "1" ]]; then
431 echo "Package $full_pkgname build forced with --force-build, building"
432 elif [[ "$FORMAT" == "deb" ]]; then
435 dd[debian11]=bullseye
436 dd[ubuntu1804]=bionic
439 if [ ${pkgname:0:3} = "lib" ]; then
440 repo_subdir=${pkgname:0:4}
442 repo_subdir=${pkgname:0:1}
445 repo_pkg_list=$(curl -s -o - http://apt.arvados.org/${D}/pool/main/${repo_subdir}/${pkgname}/)
446 echo "${repo_pkg_list}" |grep -q ${full_pkgname}
447 if [ $? -eq 0 ] ; then
448 echo "Package $full_pkgname exists upstream, not rebuilding, downloading instead!"
449 curl -s -o "$WORKSPACE/packages/$TARGET/${full_pkgname}" http://apt.arvados.org/${D}/pool/main/${repo_subdir}/${pkgname}/${full_pkgname}
451 elif test -f "$WORKSPACE/packages/$TARGET/processed/${full_pkgname}" ; then
452 echo "Package $full_pkgname exists, not rebuilding!"
455 echo "Package $full_pkgname not found, building"
459 centos_repo="http://rpm.arvados.org/CentOS/7/dev/x86_64/"
461 repo_pkg_list=$(curl -s -o - ${centos_repo})
462 echo ${repo_pkg_list} |grep -q ${full_pkgname}
463 if [ $? -eq 0 ]; then
464 echo "Package $full_pkgname exists upstream, not rebuilding, downloading instead!"
465 curl -s -o "$WORKSPACE/packages/$TARGET/${full_pkgname}" ${centos_repo}${full_pkgname}
467 elif test -f "$WORKSPACE/packages/$TARGET/processed/${full_pkgname}" ; then
468 echo "Package $full_pkgname exists, not rebuilding!"
471 echo "Package $full_pkgname not found, building"
477 handle_rails_package() {
478 local pkgname="$1"; shift
480 if [[ -n "$ONLY_BUILD" ]] && [[ "$pkgname" != "$ONLY_BUILD" ]] ; then
483 local srcdir="$1"; shift
485 local license_path="$1"; shift
486 local version="$(rails_package_version "$pkgname" "$srcdir")"
487 echo "$version" >package-build.version
488 local scripts_dir="$(mktemp --tmpdir -d "$pkgname-XXXXXXXX.scripts")" && \
491 _build_rails_package_scripts "$pkgname" "$scripts_dir"
494 git rev-parse HEAD >git-commit.version
497 if [[ 0 != "$?" ]] || ! cd "$WORKSPACE/packages/$TARGET"; then
498 echo "ERROR: $pkgname package prep failed" >&2
499 rm -rf "$scripts_dir"
503 local railsdir="/var/www/${pkgname%-server}/current"
504 local -a pos_args=("$srcdir/=$railsdir" "$pkgname" dir "$version")
505 local license_arg="$license_path=$railsdir/$(basename "$license_path")"
506 local -a switches=(--after-install "$scripts_dir/postinst"
507 --before-remove "$scripts_dir/prerm"
508 --after-remove "$scripts_dir/postrm")
509 if [[ -z "$ARVADOS_BUILDING_VERSION" ]]; then
510 switches+=(--iteration $RAILS_PACKAGE_ITERATION)
512 # For some reason fpm excludes need to not start with /.
513 local exclude_root="${railsdir#/}"
514 local -a exclude_list=(tmp log coverage Capfile\* \
515 config/deploy\* config/application.yml)
516 # for arvados-workbench, we need to have the (dummy) config/database.yml in the package
517 if [[ "$pkgname" != "arvados-workbench" ]]; then
518 exclude_list+=('config/database.yml')
520 for exclude in ${exclude_list[@]}; do
521 switches+=(-x "$exclude_root/$exclude")
523 fpm_build "${srcdir}" "${pos_args[@]}" "${switches[@]}" \
524 -x "$exclude_root/vendor/cache-*" \
525 -x "$exclude_root/vendor/bundle" "$@" "$license_arg"
526 rm -rf "$scripts_dir"
529 # Usage: handle_api_server [amd64|arm64]
530 handle_api_server () {
531 local target_arch="${1:-amd64}"; shift
533 if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "arvados-api-server" ]] ; then
534 debug_echo -e "Skipping build of arvados-api-server package."
538 native_arch=$(get_native_arch)
539 if [[ "$target_arch" != "$native_arch" ]]; then
540 echo "Error: no cross compilation support for Rails yet, can not build arvados-api-server for $ARCH"
545 # Build the API server package
546 test_rails_package_presence arvados-api-server "$WORKSPACE/services/api"
547 if [[ "$?" == "0" ]]; then
548 calculate_go_package_version arvados_server_version cmd/arvados-server
549 arvados_server_iteration=$(default_iteration "arvados-server" "$arvados_server_version" "go")
550 handle_rails_package arvados-api-server "$WORKSPACE/services/api" \
551 "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
552 --description="Arvados API server - Arvados is a free and open source platform for big data science." \
553 --license="GNU Affero General Public License, version 3.0" --depends "arvados-server = ${arvados_server_version}-${arvados_server_iteration}"
557 # Usage: handle_workbench [amd64|arm64]
558 handle_workbench () {
559 local target_arch="${1:-amd64}"; shift
560 if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "arvados-workbench" ]] ; then
561 debug_echo -e "Skipping build of arvados-workbench package."
565 native_arch=$(get_native_arch)
566 if [[ "$target_arch" != "$native_arch" ]]; then
567 echo "Error: no cross compilation support for Rails yet, can not build arvados-workbench for $native_arch"
572 if [[ "$native_arch" != "amd64" ]]; then
573 echo "Error: building the arvados-workbench package is not yet supported on this architecture ($native_arch)."
578 # Build the workbench server package
579 test_rails_package_presence arvados-workbench "$WORKSPACE/apps/workbench"
580 if [[ "$?" == "0" ]] ; then
584 calculate_go_package_version arvados_server_version cmd/arvados-server
585 arvados_server_iteration=$(default_iteration "arvados-server" "$arvados_server_version" "go")
587 # The workbench package has a build-time dependency on the arvados-server
588 # package for config manipulation, so install it first.
589 cd $WORKSPACE/cmd/arvados-server
590 get_complete_package_name arvados_server_pkgname arvados-server ${arvados_server_version} go
592 arvados_server_pkg_path="$WORKSPACE/packages/$TARGET/${arvados_server_pkgname}"
593 if [[ ! -e ${arvados_server_pkg_path} ]]; then
594 arvados_server_pkg_path="$WORKSPACE/packages/$TARGET/processed/${arvados_server_pkgname}"
596 if [[ "$FORMAT" == "deb" ]]; then
597 dpkg -i ${arvados_server_pkg_path}
599 rpm -i ${arvados_server_pkg_path}
602 cd "$WORKSPACE/apps/workbench"
604 # We need to bundle to be ready even when we build a package without vendor directory
605 # because asset compilation requires it.
606 bundle install --system >"$STDOUT_IF_DEBUG"
608 # clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
609 # and we want that in the package, so it's easier to not exclude the tmp directory
610 # from the package - empty it instead.
614 # Set up an appropriate config.yml
615 arvados-server config-dump -config <(cat /etc/arvados/config.yml 2>/dev/null || echo "Clusters: {zzzzz: {}}") > /tmp/x
616 mkdir -p /etc/arvados/
617 mv /tmp/x /etc/arvados/config.yml
618 perl -p -i -e 'BEGIN{undef $/;} s/WebDAV(.*?):\n( *)ExternalURL: ""/WebDAV$1:\n$2ExternalURL: "example.com"/g' /etc/arvados/config.yml
620 ARVADOS_CONFIG=none RAILS_ENV=production RAILS_GROUPS=assets bin/rake npm:install >"$STDOUT_IF_DEBUG"
621 ARVADOS_CONFIG=none RAILS_ENV=production RAILS_GROUPS=assets bin/rake assets:precompile >"$STDOUT_IF_DEBUG"
623 # Remove generated configuration files so they don't go in the package.
627 if [[ "$?" != "0" ]]; then
628 echo "ERROR: Asset precompilation failed"
631 handle_rails_package arvados-workbench "$WORKSPACE/apps/workbench" \
632 "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
633 --description="Arvados Workbench - Arvados is a free and open source platform for big data science." \
634 --license="GNU Affero General Public License, version 3.0" --depends "arvados-server = ${arvados_server_version}-${arvados_server_iteration}"
639 # Usage: handle_cwltest [deb|rpm] [amd64|arm64]
641 local package_format="$1"; shift
642 local target_arch="${1:-amd64}"; shift
644 if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "python3-cwltest" ]] ; then
645 debug_echo -e "Skipping build of cwltest package."
649 if [[ -e "$WORKSPACE/cwltest" ]]; then
650 rm -rf "$WORKSPACE/cwltest"
652 git clone https://github.com/common-workflow-language/cwltest.git
653 # signal to our build script that we want a cwltest executable installed in /usr/bin/
654 mkdir cwltest/bin && touch cwltest/bin/cwltest
655 fpm_build_virtualenv "cwltest" "cwltest" "$package_format" "$target_arch"
656 # The python->python3 metapackage
657 build_metapackage "cwltest" "cwltest"
659 rm -rf "$WORKSPACE/cwltest"
662 # Usage: handle_arvados_src
663 handle_arvados_src () {
664 if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "arvados-src" ]] ; then
665 debug_echo -e "Skipping build of arvados-src package."
671 COMMIT_HASH=$(format_last_commit_here "%H")
672 arvados_src_version="$(version_from_git)"
674 cd $WORKSPACE/packages/$TARGET
675 test_package_presence arvados-src "$arvados_src_version" src ""
677 if [[ "$?" == "0" ]]; then
679 SRC_BUILD_DIR=$(mktemp -d)
680 # mktemp creates the directory with 0700 permissions by default
681 chmod 755 $SRC_BUILD_DIR
682 git clone $DASHQ_UNLESS_DEBUG "$WORKSPACE/.git" "$SRC_BUILD_DIR"
685 # go into detached-head state
686 git checkout $DASHQ_UNLESS_DEBUG "$COMMIT_HASH"
687 echo "$COMMIT_HASH" >git-commit.version
689 cd $WORKSPACE/packages/$TARGET
690 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"
692 rm -rf "$SRC_BUILD_DIR"
697 # Usage: handle_libarvados_perl
698 handle_libarvados_perl () {
699 if [[ -n "$ONLY_BUILD" ]] || [[ "$ONLY_BUILD" != "libarvados-perl" ]] ; then
700 debug_echo -e "Skipping build of libarvados-perl package."
703 cd "$WORKSPACE/sdk/perl"
704 libarvados_perl_version="$(version_from_git)"
706 cd $WORKSPACE/packages/$TARGET
707 test_package_presence libarvados-perl "$libarvados_perl_version"
709 if [[ "$?" == "0" ]]; then
710 cd "$WORKSPACE/sdk/perl"
712 if [[ -e Makefile ]]; then
713 make realclean >"$STDOUT_IF_DEBUG"
715 find -maxdepth 1 \( -name 'MANIFEST*' -or -name "libarvados-perl*.$FORMAT" \) \
719 perl Makefile.PL INSTALL_BASE=install >"$STDOUT_IF_DEBUG" && \
720 make install INSTALLDIRS=perl >"$STDOUT_IF_DEBUG" && \
721 fpm_build "$WORKSPACE/sdk/perl" install/lib/=/usr/share libarvados-perl \
722 dir "$(version_from_git)" install/man/=/usr/share/man \
723 "$WORKSPACE/apache-2.0.txt=/usr/share/doc/libarvados-perl/apache-2.0.txt" && \
724 mv --no-clobber libarvados-perl*.$FORMAT "$WORKSPACE/packages/$TARGET/"
728 # Build python packages with a virtualenv built-in
729 # Usage: fpm_build_virtualenv arvados-python-client sdk/python [deb|rpm] [amd64|arm64]
730 fpm_build_virtualenv () {
732 local pkg_dir=$1; shift
733 local package_format="$1"; shift
734 local target_arch="${1:-amd64}"; shift
736 native_arch=$(get_native_arch)
738 if [[ "$pkg" != "arvados-docker-cleaner" ]]; then
739 PYTHON_PKG=$PYTHON3_PKG_PREFIX-$pkg
741 # Exception to our package naming convention
745 if [[ -n "$ONLY_BUILD" ]] && [[ "$PYTHON_PKG" != "$ONLY_BUILD" ]]; then
746 # arvados-python-client sdist should always be built if we are building a
748 if [[ "$ONLY_BUILD" != "python3-arvados-cwl-runner" ]] &&
749 [[ "$ONLY_BUILD" != "python3-arvados-fuse" ]] &&
750 [[ "$ONLY_BUILD" != "python3-crunchstat-summary" ]] &&
751 [[ "$ONLY_BUILD" != "arvados-docker-cleaner" ]] &&
752 [[ "$ONLY_BUILD" != "python3-arvados-user-activity" ]]; then
753 debug_echo -e "Skipping build of $pkg package."
758 if [[ -n "$target_arch" ]] && [[ "$native_arch" == "$target_arch" ]]; then
759 fpm_build_virtualenv_worker "$pkg" "$pkg_dir" "$package_format" "$native_arch" "$target_arch"
760 elif [[ -z "$target_arch" ]]; then
761 fpm_build_virtualenv_worker "$pkg" "$pkg_dir" "$package_format" "$native_arch" "$native_arch"
763 echo "Error: no cross compilation support for Python yet, can not build $pkg for $target_arch"
768 # Build python packages with a virtualenv built-in
769 # Usage: fpm_build_virtualenv_worker arvados-python-client sdk/python python3 [deb|rpm] [amd64|arm64] [amd64|arm64]
770 fpm_build_virtualenv_worker () {
773 local package_format="$1"; shift
774 local native_arch="${1:-amd64}"; shift
775 local target_arch=${1:-amd64}; shift
778 STDOUT_IF_DEBUG=/dev/null
779 STDERR_IF_DEBUG=/dev/null
780 DASHQ_UNLESS_DEBUG=-q
781 if [[ "$DEBUG" != "0" ]]; then
782 STDOUT_IF_DEBUG=/dev/stdout
783 STDERR_IF_DEBUG=/dev/stderr
786 if [[ "$ARVADOS_BUILDING_ITERATION" == "" ]]; then
787 ARVADOS_BUILDING_ITERATION=1
792 PACKAGE_PREFIX=$PYTHON3_PKG_PREFIX
794 if [[ "$PKG" != "arvados-docker-cleaner" ]]; then
795 PYTHON_PKG=$PACKAGE_PREFIX-$PKG
797 # Exception to our package naming convention
801 cd $WORKSPACE/$PKG_DIR
805 # Get the latest setuptools
806 if ! $pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'; then
807 echo "Error, unable to upgrade setuptools with"
808 echo " $pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'"
811 # filter a useless warning (when building the cwltest package) from the stderr output
812 if ! $python setup.py $DASHQ_UNLESS_DEBUG sdist 2> >(grep -v 'warning: no previously-included files matching'); then
813 echo "Error, unable to run $python setup.py sdist for $PKG"
817 PACKAGE_PATH=`(cd dist; ls *tar.gz)`
819 if [[ "arvados-python-client" == "$PKG" ]]; then
820 PYSDK_PATH=`pwd`/dist/
823 if [[ -n "$ONLY_BUILD" ]] && [[ "$PYTHON_PKG" != "$ONLY_BUILD" ]] && [[ "$PKG" != "$ONLY_BUILD" ]]; then
827 # Determine the package version from the generated sdist archive
828 if [[ -n "$ARVADOS_BUILDING_VERSION" ]] ; then
829 UNFILTERED_PYTHON_VERSION=$ARVADOS_BUILDING_VERSION
830 PYTHON_VERSION=$(echo -n $ARVADOS_BUILDING_VERSION | sed s/~dev/.dev/g | sed s/~rc/rc/g)
832 PYTHON_VERSION=$(awk '($1 == "Version:"){print $2}' *.egg-info/PKG-INFO)
833 UNFILTERED_PYTHON_VERSION=$(echo -n $PYTHON_VERSION | sed s/\.dev/~dev/g |sed 's/\([0-9]\)rc/\1~rc/g')
836 # See if we actually need to build this package; does it exist already?
837 # We can't do this earlier than here, because we need PYTHON_VERSION...
838 # This isn't so bad; the sdist call above is pretty quick compared to
839 # the invocation of virtualenv and fpm, below.
840 if ! test_package_presence "$PYTHON_PKG" "$UNFILTERED_PYTHON_VERSION" "$python" "$ARVADOS_BUILDING_ITERATION" "$target_arch"; then
844 echo "Building $package_format ($target_arch) package for $PKG from $PKG_DIR"
846 # Package the sdist in a virtualenv
847 echo "Creating virtualenv..."
852 rm -f $PYTHON_PKG*deb
853 echo "virtualenv version: `virtualenv --version`"
854 virtualenv_command="virtualenv --python `which $python` $DASHQ_UNLESS_DEBUG build/usr/share/$python/dist/$PYTHON_PKG"
856 if ! $virtualenv_command; then
857 echo "Error, unable to run"
858 echo " $virtualenv_command"
862 if ! build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U pip; then
863 echo "Error, unable to upgrade pip with"
864 echo " build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U pip"
867 echo "pip version: `build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip --version`"
869 if ! build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'; then
870 echo "Error, unable to upgrade setuptools with"
871 echo " build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'"
874 echo "setuptools version: `build/usr/share/$python/dist/$PYTHON_PKG/bin/$python -c 'import setuptools; print(setuptools.__version__)'`"
876 if ! build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U wheel; then
877 echo "Error, unable to upgrade wheel with"
878 echo " build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U wheel"
881 echo "wheel version: `build/usr/share/$python/dist/$PYTHON_PKG/bin/wheel version`"
883 if [[ "$TARGET" != "centos7" ]] || [[ "$PYTHON_PKG" != "python-arvados-fuse" ]]; then
884 build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -f $PYSDK_PATH $PACKAGE_PATH
886 # centos7 needs these special tweaks to install python-arvados-fuse
887 build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG docutils
888 PYCURL_SSL_LIBRARY=nss build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -f $PYSDK_PATH $PACKAGE_PATH
891 if [[ "$?" != "0" ]]; then
892 echo "Error, unable to run"
893 echo " build/usr/share/$python/dist/$PYTHON_PKG/bin/$pip install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -f $PYSDK_PATH $PACKAGE_PATH"
897 cd build/usr/share/$python/dist/$PYTHON_PKG/
899 # Replace the shebang lines in all python scripts, and handle the activate
900 # scripts too. This is a functional replacement of the 237 line
901 # virtualenv_tools.py script that doesn't work in python3 without serious
902 # patching, minus the parts we don't need (modifying pyc files, etc).
903 for binfile in `ls bin/`; do
904 if ! file --mime bin/$binfile |grep -q binary; then
906 if [[ "$binfile" =~ ^activate(.csh|.fish|)$ ]]; then
907 # these 'activate' scripts need special treatment
908 sed -i "s/VIRTUAL_ENV=\".*\"/VIRTUAL_ENV=\"\/usr\/share\/$python\/dist\/$PYTHON_PKG\"/" bin/$binfile
909 sed -i "s/VIRTUAL_ENV \".*\"/VIRTUAL_ENV \"\/usr\/share\/$python\/dist\/$PYTHON_PKG\"/" bin/$binfile
911 if grep -q -E '^#!.*/bin/python\d?' bin/$binfile; then
912 # Replace shebang line
913 sed -i "1 s/^.*$/#!\/usr\/share\/$python\/dist\/$PYTHON_PKG\/bin\/python/" bin/$binfile
919 cd - >$STDOUT_IF_DEBUG
921 find build -iname '*.pyc' -exec rm {} \;
922 find build -iname '*.pyo' -exec rm {} \;
924 # Finally, generate the package
925 echo "Creating package..."
927 declare -a COMMAND_ARR=("fpm" "-s" "dir" "-t" "$package_format")
929 if [[ -n "$target_arch" ]] && [[ "$target_arch" != "amd64" ]]; then
930 COMMAND_ARR+=("-a$target_arch")
933 if [[ "$MAINTAINER" != "" ]]; then
934 COMMAND_ARR+=('--maintainer' "$MAINTAINER")
937 if [[ "$VENDOR" != "" ]]; then
938 COMMAND_ARR+=('--vendor' "$VENDOR")
941 COMMAND_ARR+=('--url' 'https://arvados.org')
944 DESCRIPTION=`grep '\sdescription' $WORKSPACE/$PKG_DIR/setup.py|cut -f2 -d=|sed -e "s/[',\\"]//g"`
945 COMMAND_ARR+=('--description' "$DESCRIPTION")
948 LICENSE_STRING=`grep license $WORKSPACE/$PKG_DIR/setup.py|cut -f2 -d=|sed -e "s/[',\\"]//g"`
949 COMMAND_ARR+=('--license' "$LICENSE_STRING")
951 if [[ "$package_format" == "rpm" ]]; then
952 # Make sure to conflict with the old rh-python36 packages we used to publish
953 COMMAND_ARR+=('--conflicts' "rh-python36-python-$PKG")
956 if [[ "$DEBUG" != "0" ]]; then
957 COMMAND_ARR+=('--verbose' '--log' 'info')
960 COMMAND_ARR+=('-v' $(echo -n "$PYTHON_VERSION" | sed s/.dev/~dev/g | sed s/rc/~rc/g))
961 COMMAND_ARR+=('--iteration' "$ARVADOS_BUILDING_ITERATION")
962 COMMAND_ARR+=('-n' "$PYTHON_PKG")
963 COMMAND_ARR+=('-C' "build")
965 systemd_unit="$WORKSPACE/$PKG_DIR/$PKG.service"
966 if [[ -e "${systemd_unit}" ]]; then
967 COMMAND_ARR+=('--after-install' "${WORKSPACE}/build/go-python-package-scripts/postinst")
968 COMMAND_ARR+=('--before-remove' "${WORKSPACE}/build/go-python-package-scripts/prerm")
971 COMMAND_ARR+=('--depends' "$PYTHON3_PACKAGE")
974 COMMAND_ARR+=('--deb-no-default-config-files')
976 # Append --depends X and other arguments specified by fpm-info.sh in
977 # the package source dir. These are added last so they can override
978 # the arguments added by this script.
979 declare -a fpm_args=()
980 declare -a fpm_depends=()
982 fpminfo="$WORKSPACE/$PKG_DIR/fpm-info.sh"
983 if [[ -e "$fpminfo" ]]; then
984 echo "Loading fpm overrides from $fpminfo"
985 if ! source "$fpminfo"; then
986 echo "Error, unable to source $WORKSPACE/$PKG_DIR/fpm-info.sh for $PKG"
991 for i in "${fpm_depends[@]}"; do
992 COMMAND_ARR+=('--depends' "$i")
995 for i in "${fpm_depends[@]}"; do
996 COMMAND_ARR+=('--replaces' "python-$PKG")
999 # make sure the systemd service file ends up in the right place
1000 # used by arvados-docker-cleaner
1001 if [[ -e "${systemd_unit}" ]]; then
1002 COMMAND_ARR+=("usr/share/$python/dist/$PKG/share/doc/$PKG/$PKG.service=/lib/systemd/system/$PKG.service")
1005 COMMAND_ARR+=("${fpm_args[@]}")
1007 # Make sure to install all our package binaries in /usr/bin.
1008 # We have to walk $WORKSPACE/$PKG_DIR/bin rather than
1009 # $WORKSPACE/build/usr/share/$python/dist/$PYTHON_PKG/bin/ to get the list
1010 # because the latter also includes all the python binaries for the virtualenv.
1011 # We have to take the copies of our binaries from the latter directory, though,
1012 # because those are the ones we rewrote the shebang line of, above.
1013 if [[ -e "$WORKSPACE/$PKG_DIR/bin" ]]; then
1014 for binary in `ls $WORKSPACE/$PKG_DIR/bin`; do
1015 COMMAND_ARR+=("usr/share/$python/dist/$PYTHON_PKG/bin/$binary=/usr/bin/")
1019 # the python3-arvados-cwl-runner package comes with cwltool, expose that version
1020 if [[ -e "$WORKSPACE/$PKG_DIR/dist/build/usr/share/$python/dist/$PYTHON_PKG/bin/cwltool" ]]; then
1021 COMMAND_ARR+=("usr/share/$python/dist/$PYTHON_PKG/bin/cwltool=/usr/bin/")
1026 debug_echo -e "\n${COMMAND_ARR[@]}\n"
1028 FPM_RESULTS=$("${COMMAND_ARR[@]}")
1031 # if something went wrong and debug is off, print out the fpm command that errored
1032 if ! fpm_verify $FPM_EXIT_CODE $FPM_RESULTS && [[ "$STDOUT_IF_DEBUG" == "/dev/null" ]]; then
1033 echo "fpm returned an error executing the command:"
1035 echo -e "\n${COMMAND_ARR[@]}\n"
1037 echo `ls *$package_format`
1038 mv $WORKSPACE/$PKG_DIR/dist/*$package_format $WORKSPACE/packages/$TARGET/
1043 # build_metapackage builds meta packages that help with the python to python 3 package migration
1044 build_metapackage() {
1045 # base package name (e.g. arvados-python-client)
1051 if [[ -n "$ONLY_BUILD" ]] && [[ "python-$BASE_NAME" != "$ONLY_BUILD" ]]; then
1055 if [[ "$ARVADOS_BUILDING_ITERATION" == "" ]]; then
1056 ARVADOS_BUILDING_ITERATION=1
1059 if [[ -z "$ARVADOS_BUILDING_VERSION" ]]; then
1060 cd $WORKSPACE/$PKG_DIR
1064 # Get the latest setuptools
1065 if ! pip3 install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'; then
1066 echo "Error, unable to upgrade setuptools with XY"
1067 echo " pip3 install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'"
1070 # filter a useless warning (when building the cwltest package) from the stderr output
1071 if ! python3 setup.py $DASHQ_UNLESS_DEBUG sdist 2> >(grep -v 'warning: no previously-included files matching'); then
1072 echo "Error, unable to run python3 setup.py sdist for $PKG"
1076 PYTHON_VERSION=$(awk '($1 == "Version:"){print $2}' *.egg-info/PKG-INFO)
1077 UNFILTERED_PYTHON_VERSION=$(echo -n $PYTHON_VERSION | sed s/\.dev/~dev/g |sed 's/\([0-9]\)rc/\1~rc/g')
1080 UNFILTERED_PYTHON_VERSION=$ARVADOS_BUILDING_VERSION
1081 PYTHON_VERSION=$(echo -n $ARVADOS_BUILDING_VERSION | sed s/~dev/.dev/g | sed s/~rc/rc/g)
1084 cd - >$STDOUT_IF_DEBUG
1085 if [[ -d "$BASE_NAME" ]]; then
1091 if [[ "$FORMAT" == "deb" ]]; then
1092 cat >ns-control <<EOF
1095 Standards-Version: 3.9.2
1097 Package: python-${BASE_NAME}
1098 Version: ${PYTHON_VERSION}-${ARVADOS_BUILDING_ITERATION}
1099 Maintainer: Arvados Package Maintainers <packaging@arvados.org>
1100 Depends: python3-${BASE_NAME}
1101 Description: metapackage to ease the upgrade to the Pyhon 3 version of ${BASE_NAME}
1102 This package is a metapackage that will automatically install the new version of
1103 ${BASE_NAME} which is Python 3 based and has a different name.
1106 /usr/bin/equivs-build ns-control
1107 if [[ $? -ne 0 ]]; then
1108 echo "Error running 'equivs-build ns-control', is the 'equivs' package installed?"
1111 elif [[ "$FORMAT" == "rpm" ]]; then
1112 cat >meta.spec <<EOF
1113 Summary: metapackage to ease the upgrade to the Python 3 version of ${BASE_NAME}
1114 Name: python-${BASE_NAME}
1115 Version: ${PYTHON_VERSION}
1116 Release: ${ARVADOS_BUILDING_ITERATION}
1117 License: distributable
1119 Requires: python3-${BASE_NAME}
1122 This package is a metapackage that will automatically install the new version of
1123 python-${BASE_NAME} which is Python 3 based and has a different name.
1139 * Mon Apr 12 2021 Arvados Package Maintainers <packaging@arvados.org>
1143 /usr/bin/rpmbuild -ba meta.spec
1144 if [[ $? -ne 0 ]]; then
1145 echo "Error running 'rpmbuild -ba meta.spec', is the 'rpm-build' package installed?"
1148 mv /root/rpmbuild/RPMS/x86_64/python-${BASE_NAME}*.${FORMAT} .
1149 if [[ $? -ne 0 ]]; then
1150 echo "Error finding rpm file output of 'rpmbuild -ba meta.spec'"
1155 echo "Unknown format"
1159 if [[ $EXITCODE -ne 0 ]]; then
1163 mv *$FORMAT $WORKSPACE/packages/$TARGET/
1167 cd - >$STDOUT_IF_DEBUG
1168 if [[ -d "$BASE_NAME" ]]; then
1173 # Build packages for everything
1175 # Source dir where fpm-info.sh (if any) will be found.
1178 # The package source. Depending on the source type, this can be a
1179 # path, or the name of the package in an upstream repository (e.g.,
1183 # The name of the package to build.
1186 # The type of source package. Passed to fpm -s. Default "dir".
1187 PACKAGE_TYPE=${1:-dir}
1189 # Optional: the package version number. Passed to fpm -v.
1193 if [[ -n "$ONLY_BUILD" ]] && [[ "$PACKAGE_NAME" != "$ONLY_BUILD" ]] && [[ "$PACKAGE" != "$ONLY_BUILD" ]] ; then
1194 # arvados-workbench depends on arvados-server at build time, so even when
1195 # only arvados-workbench is being built, we need to build arvados-server too
1196 if [[ "$PACKAGE_NAME" != "arvados-server" ]] || [[ "$ONLY_BUILD" != "arvados-workbench" ]]; then
1201 local default_iteration_value="$(default_iteration "$PACKAGE" "$VERSION" "$PACKAGE_TYPE")"
1203 declare -a COMMAND_ARR=("fpm" "-s" "$PACKAGE_TYPE" "-t" "$FORMAT")
1204 if [ python = "$PACKAGE_TYPE" ] && [ deb = "$FORMAT" ]; then
1205 # Dependencies are built from setup.py. Since setup.py will never
1206 # refer to Debian package iterations, it doesn't make sense to
1207 # enforce those in the .deb dependencies.
1208 COMMAND_ARR+=(--deb-ignore-iteration-in-dependencies)
1211 if [[ "$DEBUG" != "0" ]]; then
1212 COMMAND_ARR+=('--verbose' '--log' 'info')
1215 if [[ -n "$PACKAGE_NAME" ]]; then
1216 COMMAND_ARR+=('-n' "$PACKAGE_NAME")
1219 if [[ "$MAINTAINER" != "" ]]; then
1220 COMMAND_ARR+=('--maintainer' "$MAINTAINER")
1223 if [[ "$VENDOR" != "" ]]; then
1224 COMMAND_ARR+=('--vendor' "$VENDOR")
1227 if [[ "$VERSION" != "" ]]; then
1228 COMMAND_ARR+=('-v' "$VERSION")
1230 if [[ -n "$default_iteration_value" ]]; then
1231 # We can always add an --iteration here. If another one is specified in $@,
1232 # that will take precedence, as desired.
1233 COMMAND_ARR+=(--iteration "$default_iteration_value")
1236 # Append --depends X and other arguments specified by fpm-info.sh in
1237 # the package source dir. These are added last so they can override
1238 # the arguments added by this script.
1239 declare -a fpm_args=()
1240 declare -a build_depends=()
1241 declare -a fpm_depends=()
1242 declare -a fpm_conflicts=()
1243 declare -a fpm_exclude=()
1244 if [[ ! -d "$SRC_DIR" ]]; then
1245 echo >&2 "BUG: looking in wrong dir for fpm-info.sh: $pkgdir"
1248 fpminfo="${SRC_DIR}/fpm-info.sh"
1249 if [[ -e "$fpminfo" ]]; then
1250 debug_echo "Loading fpm overrides from $fpminfo"
1253 for pkg in "${build_depends[@]}"; do
1254 if [[ $TARGET =~ debian|ubuntu ]]; then
1255 pkg_deb=$(ls "$WORKSPACE/packages/$TARGET/$pkg_"*.deb | sort -rg | awk 'NR==1')
1256 if [[ -e $pkg_deb ]]; then
1257 echo "Installing build_dep $pkg from $pkg_deb"
1260 echo "Attemping to install build_dep $pkg using apt-get"
1261 apt-get install -y "$pkg"
1263 apt-get -y -f install
1265 pkg_rpm=$(ls "$WORKSPACE/packages/$TARGET/$pkg"-[0-9]*.rpm | sort -rg | awk 'NR==1')
1266 if [[ -e $pkg_rpm ]]; then
1267 echo "Installing build_dep $pkg from $pkg_rpm"
1270 echo "Attemping to install build_dep $pkg"
1275 for i in "${fpm_depends[@]}"; do
1276 COMMAND_ARR+=('--depends' "$i")
1278 for i in "${fpm_conflicts[@]}"; do
1279 COMMAND_ARR+=('--conflicts' "$i")
1281 for i in "${fpm_exclude[@]}"; do
1282 COMMAND_ARR+=('--exclude' "$i")
1285 COMMAND_ARR+=("${fpm_args[@]}")
1287 # Append remaining function arguments directly to fpm's command line.
1292 COMMAND_ARR+=("$PACKAGE")
1294 debug_echo -e "\n${COMMAND_ARR[@]}\n"
1296 FPM_RESULTS=$("${COMMAND_ARR[@]}")
1299 fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
1301 # if something went wrong and debug is off, print out the fpm command that errored
1302 if [[ 0 -ne $? ]] && [[ "$STDOUT_IF_DEBUG" == "/dev/null" ]]; then
1303 echo -e "\n${COMMAND_ARR[@]}\n"
1307 # verify build results
1314 if [[ $FPM_RESULTS =~ ([A-Za-z0-9_\.-]*\.)(deb|rpm) ]]; then
1315 FPM_PACKAGE_NAME=${BASH_REMATCH[1]}${BASH_REMATCH[2]}
1318 if [[ "$FPM_PACKAGE_NAME" == "" ]]; then
1321 echo "Error: $PACKAGE: Unable to figure out package name from fpm results:"
1326 elif [[ "$FPM_RESULTS" =~ "File already exists" ]]; then
1327 echo "Package $FPM_PACKAGE_NAME exists, not rebuilding"
1329 elif [[ 0 -ne "$FPM_EXIT_CODE" ]]; then
1331 echo "Error building package for $1:\n $FPM_RESULTS"
1338 if [[ "$FORMAT" == "deb" ]]; then
1339 $SUDO apt-get install $PACKAGES --yes
1340 elif [[ "$FORMAT" == "rpm" ]]; then
1341 $SUDO yum -q -y install $PACKAGES
1346 printf '%s %s\n' "=======" "$1"
1350 if [[ "$1" != "0" ]]; then
1351 title "$2 -- FAILED"
1352 failures+=("$2 (`timer`)")
1354 successes+=("$2 (`timer`)")
1363 if [[ -n "$t0" ]]; then
1364 echo -n "$(($SECONDS - $t0))s"
1369 for x in "${successes[@]}"
1374 if [[ ${#failures[@]} == 0 ]]
1376 if [[ ${#successes[@]} != 0 ]]; then
1377 echo "All test suites passed."
1380 echo "Failures (${#failures[@]}):"
1381 for x in "${failures[@]}"