17417: Merge branch 'main' into 17417-add-arm64
authorWard Vandewege <ward@curii.com>
Fri, 7 Jan 2022 19:52:31 +0000 (14:52 -0500)
committerWard Vandewege <ward@curii.com>
Fri, 7 Jan 2022 19:52:31 +0000 (14:52 -0500)
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

15 files changed:
.gitignore
build/libcloud-pin.sh [deleted file]
build/package-build-dockerfiles/Makefile
build/package-build-dockerfiles/build-all-build-containers.sh
build/package-build-dockerfiles/centos7/Dockerfile
build/package-build-dockerfiles/debian10/Dockerfile
build/package-build-dockerfiles/debian11/Dockerfile
build/package-build-dockerfiles/ubuntu1804/Dockerfile
build/package-build-dockerfiles/ubuntu2004/Dockerfile
build/package-build-dockerfiles/ubuntu2004/ports.list [new file with mode: 0644]
build/run-build-packages-one-target.sh
build/run-build-packages.sh
build/run-build-test-packages-one-target.sh
build/run-library.sh
build/run-tests.sh

index 231424accd37d1549e1edf3d066aa93a135dfa31..07482bde73e01d82f590b6b3fa1d9e1f95719001 100644 (file)
@@ -35,3 +35,4 @@ _version.py
 *.log
 arvados-snakeoil-ca.pem
 .vagrant
+packages
diff --git a/build/libcloud-pin.sh b/build/libcloud-pin.sh
deleted file mode 100644 (file)
index 9cc2924..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright (C) The Arvados Authors. All rights reserved.
-#
-# SPDX-License-Identifier: AGPL-3.0
-
-LIBCLOUD_PIN=2.3.1.dev2
-
-using_fork=true
-if [[ $using_fork = true ]]; then
-    LIBCLOUD_PIN_SRC="https://github.com/arvados/libcloud/archive/apache-libcloud-$LIBCLOUD_PIN.zip"
-else
-    LIBCLOUD_PIN_SRC=""
-fi
index 51fee9fce144f9978204a2b771d49b45b8473943..2592d8686bc9a8e5e53cd60d8890f1ffb7399200 100644 (file)
@@ -2,6 +2,7 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
+SHELL := '/bin/bash'
 all: centos7/generated debian10/generated debian11/generated ubuntu1804/generated ubuntu2004/generated
 
 centos7/generated: common-generated-all
@@ -24,8 +25,19 @@ ubuntu2004/generated: common-generated-all
        test -d ubuntu2004/generated || mkdir ubuntu2004/generated
        cp -f -rlt ubuntu2004/generated common-generated/*
 
-GOTARBALL=go1.17.1.linux-amd64.tar.gz
-NODETARBALL=node-v10.23.1-linux-x64.tar.xz
+GOTARBALL_=DOES_NOT_EXIST
+NODETARBALL_=DOES_NOT_EXIST
+GOTARBALL_x86_64=go1.17.1.linux-amd64.tar.gz
+NODETARBALL_x86_64=node-v10.23.1-linux-x64.tar.xz
+GOTARBALL_aarch64=go1.17.1.linux-arm64.tar.gz
+NODETARBALL_aarch64=node-v10.23.1-linux-arm64.tar.xz
+
+# Get the bash variable $HOSTTYPE (this requires the SHELL line above)
+HOSTTYPE=$(shell echo $${HOSTTYPE})
+
+GOTARBALL=${GOTARBALL_$(HOSTTYPE)}
+NODETARBALL=${NODETARBALL_$(HOSTTYPE)}
+
 RVMKEY1=mpapis.asc
 RVMKEY2=pkuczynski.asc
 
index 0d37859ee82ac15b256e248310d58578d544c89a..5ed33dc9f3ac5f22b4899577f1b0244f5bf18e6f 100755 (executable)
@@ -12,7 +12,7 @@ for target in `find -maxdepth 1 -type d |grep -v generated`; do
   target=${target#./}
   echo $target
   cd $target
-  docker build -t arvados/build:$target .
+  docker build --tag arvados/build:$target --build-arg HOSTTYPE=$HOSTTYPE .
   cd ..
 done
 
index edfe3405f443bd10fc2b50ca9b504fc76a7654f4..14a28901cb77e8ec5d9897e6a0ab50cd7d36bde8 100644 (file)
@@ -2,9 +2,31 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
-FROM centos:7
+ARG HOSTTYPE
+
+FROM centos:7 as build_x86_64
+# Install go
+ONBUILD ADD generated/go1.17.1.linux-amd64.tar.gz /usr/local/
+ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
+# Install nodejs and npm
+ONBUILD ADD generated/node-v10.23.1-linux-x64.tar.xz /usr/local/
+ONBUILD RUN ln -s /usr/local/node-v10.23.1-linux-x64/bin/* /usr/local/bin/
+
+FROM centos:7 as build_aarch64
+# Install go
+ONBUILD ADD generated/go1.17.1.linux-arm64.tar.gz /usr/local/
+ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
+# Install nodejs and npm
+ONBUILD ADD generated/node-v10.23.1-linux-arm64.tar.xz /usr/local/
+ONBUILD RUN ln -s /usr/local/node-v10.23.1-linux-arm64/bin/* /usr/local/bin/
+
+FROM build_${HOSTTYPE}
+
 MAINTAINER Arvados Package Maintainers <packaging@arvados.org>
 
+ENV DEBIAN_FRONTEND noninteractive
+
+SHELL ["/bin/bash", "-c"]
 # Install dependencies.
 RUN yum -q -y install make automake gcc gcc-c++ libyaml-devel patch readline-devel zlib-devel libffi-devel openssl-devel bzip2 libtool bison sqlite-devel rpm-build git perl-ExtUtils-MakeMaker libattr-devel nss-devel libcurl-devel which tar unzip scl-utils centos-release-scl postgresql-devel fuse-devel xz-libs git wget pam-devel
 
@@ -14,8 +36,9 @@ ADD generated/pkuczynski.asc /tmp/
 RUN gpg --import --no-tty /tmp/mpapis.asc && \
     gpg --import --no-tty /tmp/pkuczynski.asc && \
     curl -L https://get.rvm.io | bash -s stable && \
-    /usr/local/rvm/bin/rvm install 2.5 && \
+    /usr/local/rvm/bin/rvm install 2.5 -j $(grep -c processor /proc/cpuinfo) && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.5 && \
+    echo "gem: --no-document" >> ~/.gemrc && \
     /usr/local/rvm/bin/rvm-exec default gem install bundler --version 2.2.19 && \
     /usr/local/rvm/bin/rvm-exec default gem install fpm --version 1.10.2
 
@@ -30,14 +53,6 @@ RUN cd /usr/local/src \
 && make install \
 && ln -sf /usr/local/src/bash-4.4.12/bash /bin/bash
 
-# Install golang binary
-ADD generated/go1.17.1.linux-amd64.tar.gz /usr/local/
-RUN ln -s /usr/local/go/bin/go /usr/local/bin/
-
-# Install nodejs and npm
-ADD generated/node-v10.23.1-linux-x64.tar.xz /usr/local/
-RUN ln -s /usr/local/node-v10.23.1-linux-x64/bin/* /usr/local/bin/
-
 # Need to "touch" RPM database to workaround bug in interaction between
 # overlayfs and yum (https://bugzilla.redhat.com/show_bug.cgi?id=1213602)
 RUN touch /var/lib/rpm/* && yum -q -y install python3 python3-pip python3-devel
@@ -45,7 +60,17 @@ RUN touch /var/lib/rpm/* && yum -q -y install python3 python3-pip python3-devel
 # Install virtualenv
 RUN /usr/bin/pip3 install 'virtualenv<20'
 
-RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && cd /tmp/arvados/services/api && /usr/local/rvm/bin/rvm-exec default bundle && cd /tmp/arvados/apps/workbench && /usr/local/rvm/bin/rvm-exec default bundle
+RUN /usr/local/rvm/bin/rvm-exec default bundle config --global jobs $(let a=$(grep -c processor /proc/cpuinfo )-1; echo $a)
+# Cf. https://build.betterup.com/one-weird-trick-that-will-speed-up-your-bundle-install/
+ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
+
+RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
+    cd /tmp/arvados/services/api && \
+    /usr/local/rvm/bin/rvm-exec default bundle install && \
+    cd /tmp/arvados/apps/workbench && \
+    /usr/local/rvm/bin/rvm-exec default bundle install && \
+    cd /tmp/arvados && \
+    go mod download
 
 # The version of setuptools that comes with CentOS is way too old
 RUN pip3 install 'setuptools<45'
index 809d935880fd4b7beaac09f3cd348ac75a04782c..efff0acc930564fd2cd801eeaad362c8c0109f91 100644 (file)
@@ -2,12 +2,33 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
+ARG HOSTTYPE
+
 ## dont use debian:10 here since the word 'buster' is used for rvm precompiled binaries
-FROM debian:buster
+FROM debian:buster as build_x86_64
+# Install go
+ONBUILD ADD generated/go1.17.1.linux-amd64.tar.gz /usr/local/
+ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
+# Install nodejs and npm
+ONBUILD ADD generated/node-v10.23.1-linux-x64.tar.xz /usr/local/
+ONBUILD RUN ln -s /usr/local/node-v10.23.1-linux-x64/bin/* /usr/local/bin/
+# No cross compilation support for debian10 because of https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477
+
+FROM debian:buster as build_aarch64
+# Install go
+ONBUILD ADD generated/go1.17.1.linux-arm64.tar.gz /usr/local/
+ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
+# Install nodejs and npm
+ONBUILD ADD generated/node-v10.23.1-linux-arm64.tar.xz /usr/local/
+ONBUILD RUN ln -s /usr/local/node-v10.23.1-linux-arm64/bin/* /usr/local/bin/
+
+FROM build_${HOSTTYPE}
+
 MAINTAINER Arvados Package Maintainers <packaging@arvados.org>
 
 ENV DEBIAN_FRONTEND noninteractive
 
+SHELL ["/bin/bash", "-c"]
 # Install dependencies.
 RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y python3 python3-setuptools python3-pip libcurl4-gnutls-dev curl git procps libattr1-dev libfuse-dev libgnutls28-dev libpq-dev unzip python3-venv python3-dev libpam-dev equivs
 
@@ -20,20 +41,23 @@ ADD generated/pkuczynski.asc /tmp/
 RUN gpg --import --no-tty /tmp/mpapis.asc && \
     gpg --import --no-tty /tmp/pkuczynski.asc && \
     curl -L https://get.rvm.io | bash -s stable && \
-    /usr/local/rvm/bin/rvm install 2.5 && \
+    /usr/local/rvm/bin/rvm install 2.5 -j $(grep -c processor /proc/cpuinfo) && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.5 && \
+    echo "gem: --no-document" >> ~/.gemrc && \
     /usr/local/rvm/bin/rvm-exec default gem install bundler --version 2.2.19 && \
     /usr/local/rvm/bin/rvm-exec default gem install fpm --version 1.10.2
 
-# Install golang binary
-ADD generated/go1.17.1.linux-amd64.tar.gz /usr/local/
-RUN ln -s /usr/local/go/bin/go /usr/local/bin/
-
-# Install nodejs and npm
-ADD generated/node-v10.23.1-linux-x64.tar.xz /usr/local/
-RUN ln -s /usr/local/node-v10.23.1-linux-x64/bin/* /usr/local/bin/
-
-RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && cd /tmp/arvados/services/api && /usr/local/rvm/bin/rvm-exec default bundle && cd /tmp/arvados/apps/workbench && /usr/local/rvm/bin/rvm-exec default bundle
+RUN /usr/local/rvm/bin/rvm-exec default bundle config --global jobs $(let a=$(grep -c processor /proc/cpuinfo )-1; echo $a)
+# Cf. https://build.betterup.com/one-weird-trick-that-will-speed-up-your-bundle-install/
+ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
+
+RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
+    cd /tmp/arvados/services/api && \
+    /usr/local/rvm/bin/rvm-exec default bundle install && \
+    cd /tmp/arvados/apps/workbench && \
+    /usr/local/rvm/bin/rvm-exec default bundle install && \
+    cd /tmp/arvados && \
+    go mod download
 
 ENV WORKSPACE /arvados
 CMD ["/usr/local/rvm/bin/rvm-exec", "default", "bash", "/jenkins/run-build-packages.sh", "--target", "debian10"]
index 06380ef896b2b79669fc758b02616315e5de8525..54a6a0ec1dd75887d92200c3fbce636a35a476b5 100644 (file)
@@ -2,12 +2,38 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
+ARG HOSTTYPE
+
 ## dont use debian:11 here since the word 'bullseye' is used for rvm precompiled binaries
-FROM debian:bullseye
+FROM debian:bullseye as build_x86_64
+# Install go
+ONBUILD ADD generated/go1.17.1.linux-amd64.tar.gz /usr/local/
+ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
+# Install nodejs and npm
+ONBUILD ADD generated/node-v10.23.1-linux-x64.tar.xz /usr/local/
+ONBUILD RUN ln -s /usr/local/node-v10.23.1-linux-x64/bin/* /usr/local/bin/
+# On x86, we want some cross-compilation support for arm64
+# Add gcc-aarch64-linux-gnu to compile go binaries for arm64
+ONBUILD RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y gcc-aarch64-linux-gnu
+# We also need libpam compiled for arm64
+ONBUILD RUN /usr/bin/dpkg --add-architecture arm64
+ONBUILD RUN /usr/bin/apt-get update && /usr/bin/apt-get install -o APT::Immediate-Configure=0 -q -y libpam0g-dev:arm64 libfuse-dev:arm64
+
+FROM debian:bullseye as build_aarch64
+# Install go
+ONBUILD ADD generated/go1.17.1.linux-arm64.tar.gz /usr/local/
+ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
+# Install nodejs and npm
+ONBUILD ADD generated/node-v10.23.1-linux-arm64.tar.xz /usr/local/
+ONBUILD RUN ln -s /usr/local/node-v10.23.1-linux-arm64/bin/* /usr/local/bin/
+
+FROM build_${HOSTTYPE}
+
 MAINTAINER Arvados Package Maintainers <packaging@arvados.org>
 
 ENV DEBIAN_FRONTEND noninteractive
 
+SHELL ["/bin/bash", "-c"]
 # Install dependencies.
 RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y python3 python3-setuptools python3-pip libcurl4-gnutls-dev curl git procps libattr1-dev libfuse-dev libgnutls28-dev libpq-dev unzip python3-venv python3-dev libpam-dev equivs
 
@@ -20,21 +46,23 @@ ADD generated/pkuczynski.asc /tmp/
 RUN gpg --import --no-tty /tmp/mpapis.asc && \
     gpg --import --no-tty /tmp/pkuczynski.asc && \
     curl -L https://get.rvm.io | bash -s stable && \
-    /usr/local/rvm/bin/rvm install 2.5 && \
+    /usr/local/rvm/bin/rvm install 2.5 -j $(grep -c processor /proc/cpuinfo) && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.5 && \
-    echo "gem: --no-document" >> /etc/gemrc && \
+    echo "gem: --no-document" >> ~/.gemrc && \
     /usr/local/rvm/bin/rvm-exec default gem install bundler --version 2.2.19 && \
     /usr/local/rvm/bin/rvm-exec default gem install fpm --version 1.10.2
 
-# Install golang binary
-ADD generated/go1.17.1.linux-amd64.tar.gz /usr/local/
-RUN ln -s /usr/local/go/bin/go /usr/local/bin/
-
-# Install nodejs and npm
-ADD generated/node-v10.23.1-linux-x64.tar.xz /usr/local/
-RUN ln -s /usr/local/node-v10.23.1-linux-x64/bin/* /usr/local/bin/
+RUN /usr/local/rvm/bin/rvm-exec default bundle config --global jobs $(let a=$(grep -c processor /proc/cpuinfo )-1; echo $a)
+# Cf. https://build.betterup.com/one-weird-trick-that-will-speed-up-your-bundle-install/
+ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
 
-RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && cd /tmp/arvados/services/api && /usr/local/rvm/bin/rvm-exec default bundle && cd /tmp/arvados/apps/workbench && /usr/local/rvm/bin/rvm-exec default bundle
+RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
+    cd /tmp/arvados/services/api && \
+    /usr/local/rvm/bin/rvm-exec default bundle install && \
+    cd /tmp/arvados/apps/workbench && \
+    /usr/local/rvm/bin/rvm-exec default bundle install && \
+    cd /tmp/arvados && \
+    go mod download
 
 ENV WORKSPACE /arvados
 CMD ["/usr/local/rvm/bin/rvm-exec", "default", "bash", "/jenkins/run-build-packages.sh", "--target", "debian11"]
index 4a210373fa23bde894e1522e35e47d41f769cb7e..d3727849268ef16d5ce322f58e86e136bf3d98f3 100644 (file)
@@ -2,11 +2,32 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
-FROM ubuntu:bionic
+ARG HOSTTYPE
+
+FROM ubuntu:bionic as build_x86_64
+# Install go
+ONBUILD ADD generated/go1.17.1.linux-amd64.tar.gz /usr/local/
+ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
+# Install nodejs and npm
+ONBUILD ADD generated/node-v10.23.1-linux-x64.tar.xz /usr/local/
+ONBUILD RUN ln -s /usr/local/node-v10.23.1-linux-x64/bin/* /usr/local/bin/
+# No cross compilation support for ubuntu1804 because of https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477
+
+FROM ubuntu:bionic as build_aarch64
+# Install go
+ONBUILD ADD generated/go1.17.1.linux-arm64.tar.gz /usr/local/
+ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
+# Install nodejs and npm
+ONBUILD ADD generated/node-v10.23.1-linux-arm64.tar.xz /usr/local/
+ONBUILD RUN ln -s /usr/local/node-v10.23.1-linux-arm64/bin/* /usr/local/bin/
+
+FROM build_${HOSTTYPE}
+
 MAINTAINER Arvados Package Maintainers <packaging@arvados.org>
 
 ENV DEBIAN_FRONTEND noninteractive
 
+SHELL ["/bin/bash", "-c"]
 # Install dependencies.
 RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y python3 python3-pip libcurl4-gnutls-dev libgnutls28-dev curl git libattr1-dev libfuse-dev libpq-dev unzip tzdata python3-venv python3-dev libpam-dev equivs
 
@@ -19,20 +40,23 @@ ADD generated/pkuczynski.asc /tmp/
 RUN gpg --import --no-tty /tmp/mpapis.asc && \
     gpg --import --no-tty /tmp/pkuczynski.asc && \
     curl -L https://get.rvm.io | bash -s stable && \
-    /usr/local/rvm/bin/rvm install 2.5 && \
+    /usr/local/rvm/bin/rvm install 2.5 -j $(grep -c processor /proc/cpuinfo) && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.5 && \
+    echo "gem: --no-document" >> ~/.gemrc && \
     /usr/local/rvm/bin/rvm-exec default gem install bundler --version 2.2.19 && \
     /usr/local/rvm/bin/rvm-exec default gem install fpm --version 1.10.2
 
-# Install golang binary
-ADD generated/go1.17.1.linux-amd64.tar.gz /usr/local/
-RUN ln -s /usr/local/go/bin/go /usr/local/bin/
-
-# Install nodejs and npm
-ADD generated/node-v10.23.1-linux-x64.tar.xz /usr/local/
-RUN ln -s /usr/local/node-v10.23.1-linux-x64/bin/* /usr/local/bin/
-
-RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && cd /tmp/arvados/services/api && /usr/local/rvm/bin/rvm-exec default bundle && cd /tmp/arvados/apps/workbench && /usr/local/rvm/bin/rvm-exec default bundle
+RUN /usr/local/rvm/bin/rvm-exec default bundle config --global jobs $(let a=$(grep -c processor /proc/cpuinfo )-1; echo $a)
+# Cf. https://build.betterup.com/one-weird-trick-that-will-speed-up-your-bundle-install/
+ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
+
+RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
+    cd /tmp/arvados/services/api && \
+    /usr/local/rvm/bin/rvm-exec default bundle install && \
+    cd /tmp/arvados/apps/workbench && \
+    /usr/local/rvm/bin/rvm-exec default bundle install && \
+    cd /tmp/arvados && \
+    go mod download
 
 ENV WORKSPACE /arvados
 CMD ["/usr/local/rvm/bin/rvm-exec", "default", "bash", "/jenkins/run-build-packages.sh", "--target", "ubuntu1804"]
index 276b29fc560db62c2a5967d891f710544a18c49b..58b4bc1ed8dcb0d1262d22452b1dcc1556948ab3 100644 (file)
@@ -2,11 +2,43 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
-FROM ubuntu:focal
+ARG HOSTTYPE
+
+FROM ubuntu:focal as build_x86_64
+# Install go
+ONBUILD ADD generated/go1.17.1.linux-amd64.tar.gz /usr/local/
+ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
+# Install nodejs and npm
+ONBUILD ADD generated/node-v10.23.1-linux-x64.tar.xz /usr/local/
+ONBUILD RUN ln -s /usr/local/node-v10.23.1-linux-x64/bin/* /usr/local/bin/
+# On x86, we want some cross-compilation support for arm64
+# Add gcc-aarch64-linux-gnu to compile go binaries for arm64
+ONBUILD RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y gcc-aarch64-linux-gnu
+# We also need libpam compiled for arm64, and that requires some sources.list mangling
+ONBUILD RUN /bin/sed -i 's/deb http/deb [ arch=amd64 ] http/' /etc/apt/sources.list
+ONBUILD ADD ports.list /etc/apt/sources.list.d/
+ONBUILD RUN /usr/bin/dpkg --add-architecture arm64
+ONBUILD RUN /usr/bin/apt-get update && /usr/bin/apt-get install -o APT::Immediate-Configure=0 -q -y libpam0g-dev:arm64
+# Note that cross compilation support for ubuntu2004 is disabled in
+# run-library.sh because of
+# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477. Hopefully
+# ubuntu2204 will have the fix introduced in debian11.
+
+FROM ubuntu:focal as build_aarch64
+# Install go
+ONBUILD ADD generated/go1.17.1.linux-arm64.tar.gz /usr/local/
+ONBUILD RUN ln -s /usr/local/go/bin/go /usr/local/bin/
+# Install nodejs and npm
+ONBUILD ADD generated/node-v10.23.1-linux-arm64.tar.xz /usr/local/
+ONBUILD RUN ln -s /usr/local/node-v10.23.1-linux-arm64/bin/* /usr/local/bin/
+
+FROM build_${HOSTTYPE}
+
 MAINTAINER Arvados Package Maintainers <packaging@arvados.org>
 
 ENV DEBIAN_FRONTEND noninteractive
 
+SHELL ["/bin/bash", "-c"]
 # Install dependencies.
 RUN /usr/bin/apt-get update && /usr/bin/apt-get install -q -y python3 python3-pip libcurl4-gnutls-dev libgnutls28-dev curl git libattr1-dev libfuse-dev libpq-dev unzip tzdata python3-venv python3-dev libpam-dev shared-mime-info equivs
 
@@ -19,20 +51,24 @@ ADD generated/pkuczynski.asc /tmp/
 RUN gpg --import --no-tty /tmp/mpapis.asc && \
     gpg --import --no-tty /tmp/pkuczynski.asc && \
     curl -L https://get.rvm.io | bash -s stable && \
-    /usr/local/rvm/bin/rvm install 2.5 && \
+    /usr/local/rvm/bin/rvm install 2.5 -j $(grep -c processor /proc/cpuinfo) && \
     /usr/local/rvm/bin/rvm alias create default ruby-2.5 && \
+    echo "gem: --no-document" >> ~/.gemrc && \
     /usr/local/rvm/bin/rvm-exec default gem install bundler --version 2.2.19 && \
     /usr/local/rvm/bin/rvm-exec default gem install fpm --version 1.10.2
 
-# Install golang binary
-ADD generated/go1.17.1.linux-amd64.tar.gz /usr/local/
-RUN ln -s /usr/local/go/bin/go /usr/local/bin/
+RUN /usr/local/rvm/bin/rvm-exec default bundle config --global jobs $(let a=$(grep -c processor /proc/cpuinfo )-1; echo $a)
+# Cf. https://build.betterup.com/one-weird-trick-that-will-speed-up-your-bundle-install/
+ENV MAKE "make --jobs $(grep -c processor /proc/cpuinfo)"
 
-# Install nodejs and npm
-ADD generated/node-v10.23.1-linux-x64.tar.xz /usr/local/
-RUN ln -s /usr/local/node-v10.23.1-linux-x64/bin/* /usr/local/bin/
+RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && \
+    cd /tmp/arvados/services/api && \
+    /usr/local/rvm/bin/rvm-exec default bundle install && \
+    cd /tmp/arvados/apps/workbench && \
+    /usr/local/rvm/bin/rvm-exec default bundle install && \
+    cd /tmp/arvados && \
+    go mod download
 
-RUN git clone --depth 1 git://git.arvados.org/arvados.git /tmp/arvados && cd /tmp/arvados/services/api && /usr/local/rvm/bin/rvm-exec default bundle && cd /tmp/arvados/apps/workbench && /usr/local/rvm/bin/rvm-exec default bundle
 
 ENV WORKSPACE /arvados
 CMD ["/usr/local/rvm/bin/rvm-exec", "default", "bash", "/jenkins/run-build-packages.sh", "--target", "ubuntu2004"]
diff --git a/build/package-build-dockerfiles/ubuntu2004/ports.list b/build/package-build-dockerfiles/ubuntu2004/ports.list
new file mode 100644 (file)
index 0000000..5feda77
--- /dev/null
@@ -0,0 +1,8 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+deb [arch=arm64,armhf,ppc64el,s390x] http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe multiverse
+deb [arch=arm64,armhf,ppc64el,s390x] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe multiverse
+deb [arch=arm64,armhf,ppc64el,s390x] http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted universe multiverse
+deb [arch=arm64,armhf,ppc64el,s390x] http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse
index 7a91cb4de15eec13dbd524342b2bb20679666b0e..e06a7329790e3dfa7b1430e33c52a2b86c383cc2 100755 (executable)
@@ -21,6 +21,8 @@ Syntax:
     Build only a specific package
 --only-test <package>
     Test only a specific package
+--arch <arch>
+    Build a specific architecture (amd64 or arm64, defaults to native architecture)
 --force-build
     Build even if the package exists upstream or if it has already been
     built locally
@@ -54,7 +56,7 @@ if ! [[ -d "$WORKSPACE" ]]; then
 fi
 
 PARSEDOPTS=$(getopt --name "$0" --longoptions \
-    help,debug,test-packages,target:,command:,only-test:,force-test,only-build:,force-build,build-version: \
+    help,debug,test-packages,target:,command:,only-test:,force-test,only-build:,force-build,arch:,build-version: \
     -- "" "$@")
 if [ $? -ne 0 ]; then
     exit 1
@@ -90,6 +92,9 @@ while [ $# -gt 0 ]; do
         --only-build)
             ONLY_BUILD="$2"; shift
             ;;
+        --arch)
+            ARCH="$2"; shift
+            ;;
         --debug)
             DEBUG=" --debug"
             ARVADOS_DEBUG="1"
@@ -164,7 +169,7 @@ if [[ -n "$test_packages" ]]; then
     fi
     set -e
     (cd $WORKSPACE/packages/$TARGET
-      dpkg-scanpackages .  2> >(grep -v 'warning' 1>&2) | tee Packages | gzip -c > Packages.gz
+      dpkg-scanpackages --multiversion .  2> >(grep -v 'warning' 1>&2) | tee Packages | gzip -c > Packages.gz
       apt-ftparchive -o APT::FTPArchive::Release::Origin=Arvados release . > Release
     )
   fi
@@ -190,7 +195,7 @@ fi
 
 echo $TARGET
 cd $TARGET
-time docker build --tag=$IMAGE .
+time docker build --tag "$IMAGE" --build-arg HOSTTYPE=$HOSTTYPE .
 popd
 
 if test -z "$packages" ; then
@@ -311,6 +316,7 @@ else
         --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
         --env "ONLY_BUILD=$ONLY_BUILD" \
         --env "FORCE_BUILD=$FORCE_BUILD" \
+        --env "ARCH=$ARCH" \
         "$IMAGE" $COMMAND
     then
         echo
index 26ed168aa6c60365109e63c8bfef83d8831dfe68..0cfe54cd139bb1540bc14ae4db0fceafaf6bb0a3 100755 (executable)
@@ -3,14 +3,13 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
-. `dirname "$(readlink -f "$0")"`/run-library.sh || exit 1
-. `dirname "$(readlink -f "$0")"`/libcloud-pin.sh || exit 1
+. "$(dirname "$(readlink -f "$0")")"/run-library.sh || exit 1
 
 read -rd "\000" helpmessage <<EOF
-$(basename $0): Build Arvados packages
+$(basename "$0"): Build Arvados packages
 
 Syntax:
-        WORKSPACE=/path/to/arvados $(basename $0) [options]
+        WORKSPACE=/path/to/arvados $(basename "$0") [options]
 
 Options:
 
@@ -21,7 +20,9 @@ Options:
 --target <target>
     Distribution to build packages for (default: debian10)
 --only-build <package>
-    Build only a specific package (or $ONLY_BUILD from environment)
+    Build only a specific package (or ONLY_BUILD from environment)
+--arch <arch>
+    Build a specific architecture (or ARCH from environment, defaults to native architecture)
 --force-build
     Build even if the package exists upstream or if it has already been
     built locally
@@ -50,7 +51,7 @@ TARGET=debian10
 COMMAND=
 
 PARSEDOPTS=$(getopt --name "$0" --longoptions \
-    help,build-bundle-packages,debug,target:,only-build:,force-build \
+    help,build-bundle-packages,debug,target:,only-build:,arch:,force-build \
     -- "" "$@")
 if [ $? -ne 0 ]; then
     exit 1
@@ -73,6 +74,9 @@ while [ $# -gt 0 ]; do
         --force-build)
             FORCE_BUILD=1
             ;;
+        --arch)
+            ARCH="$2"; shift
+            ;;
         --debug)
             DEBUG=1
             ;;
@@ -123,7 +127,7 @@ case "$TARGET" in
         ;;
     centos*)
         FORMAT=rpm
-        PYTHON3_PACKAGE=$(rpm -qf "$(which python$PYTHON3_VERSION)" --queryformat '%{NAME}\n')
+        PYTHON3_PACKAGE=$(rpm -qf "$(which python"$PYTHON3_VERSION")" --queryformat '%{NAME}\n')
         PYTHON3_PKG_PREFIX=$PYTHON3_PACKAGE
         PYTHON3_PREFIX=/usr
         PYTHON3_INSTALL_LIB=lib/python$PYTHON3_VERSION/site-packages
@@ -136,7 +140,7 @@ case "$TARGET" in
 esac
 
 
-if ! [[ -n "$WORKSPACE" ]]; then
+if [[ -z "$WORKSPACE" ]]; then
   echo >&2 "$helpmessage"
   echo >&2
   echo >&2 "Error: WORKSPACE environment variable not set"
@@ -147,7 +151,7 @@ fi
 # Test for fpm
 fpm --version >/dev/null 2>&1
 
-if [[ "$?" != 0 ]]; then
+if [[ $? -ne 0 ]]; then
   echo >&2 "$helpmessage"
   echo >&2
   echo >&2 "Error: fpm not found"
@@ -155,8 +159,8 @@ if [[ "$?" != 0 ]]; then
   exit 1
 fi
 
-RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
-RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`"  # absolutized and normalized
+RUN_BUILD_PACKAGES_PATH="$(dirname "$0")"
+RUN_BUILD_PACKAGES_PATH="$(cd "$RUN_BUILD_PACKAGES_PATH" && pwd)"  # absolutized and normalized
 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
   # error; for some reason, the path is not accessible
   # to the script (e.g. permissions re-evaled after suid)
@@ -178,157 +182,110 @@ fi
 chmod o+r "$WORKSPACE" -R
 
 # More cleanup - make sure all executables that we'll package are 755
-cd "$WORKSPACE"
-find -type d -name 'bin' |xargs -I {} find {} -type f |xargs -I {} chmod 755 {}
+cd "$WORKSPACE" || exit 1
+find . -type d -name 'bin' -print0 |xargs -0 -I {} find {} -type f -print0 |xargs -0 -I {} chmod 755 {}
 
 # Now fix our umask to something better suited to building and publishing
 # gems and packages
 umask 0022
 
-debug_echo "umask is" `umask`
+debug_echo "umask is" "$(umask)"
 
 if [[ ! -d "$WORKSPACE/packages/$TARGET" ]]; then
-  mkdir -p $WORKSPACE/packages/$TARGET
+  mkdir -p "$WORKSPACE/packages/$TARGET"
   chown --reference="$WORKSPACE" "$WORKSPACE/packages/$TARGET"
 fi
 
 # Perl packages
 debug_echo -e "\nPerl packages\n"
 
-if [[ -z "$ONLY_BUILD" ]] || [[ "libarvados-perl" = "$ONLY_BUILD" ]] ; then
-  cd "$WORKSPACE/sdk/perl"
-  libarvados_perl_version="$(version_from_git)"
-
-  cd $WORKSPACE/packages/$TARGET
-  test_package_presence libarvados-perl "$libarvados_perl_version"
-
-  if [[ "$?" == "0" ]]; then
-    cd "$WORKSPACE/sdk/perl"
-
-    if [[ -e Makefile ]]; then
-      make realclean >"$STDOUT_IF_DEBUG"
-    fi
-    find -maxdepth 1 \( -name 'MANIFEST*' -or -name "libarvados-perl*.$FORMAT" \) \
-        -delete
-    rm -rf install
-
-    perl Makefile.PL INSTALL_BASE=install >"$STDOUT_IF_DEBUG" && \
-        make install INSTALLDIRS=perl >"$STDOUT_IF_DEBUG" && \
-        fpm_build "$WORKSPACE/sdk/perl" install/lib/=/usr/share libarvados-perl \
-        dir "$(version_from_git)" install/man/=/usr/share/man \
-        "$WORKSPACE/apache-2.0.txt=/usr/share/doc/libarvados-perl/apache-2.0.txt" && \
-        mv --no-clobber libarvados-perl*.$FORMAT "$WORKSPACE/packages/$TARGET/"
-  fi
-fi
+handle_libarvados_perl
 
 # Ruby gems
 debug_echo -e "\nRuby gems\n"
 
 FPM_GEM_PREFIX=$($GEM environment gemdir)
 
-cd "$WORKSPACE/sdk/ruby"
+cd "$WORKSPACE/sdk/ruby" || exit 1
 handle_ruby_gem arvados
 
-cd "$WORKSPACE/sdk/cli"
+cd "$WORKSPACE/sdk/cli" || exit 1
 handle_ruby_gem arvados-cli
 
-cd "$WORKSPACE/services/login-sync"
+cd "$WORKSPACE/services/login-sync" || exit 1
 handle_ruby_gem arvados-login-sync
 
-# Python packages
-debug_echo -e "\nPython packages\n"
-
 # arvados-src
-(
-    cd "$WORKSPACE"
-    COMMIT_HASH=$(format_last_commit_here "%H")
-    arvados_src_version="$(version_from_git)"
-
-    cd $WORKSPACE/packages/$TARGET
-    test_package_presence arvados-src $arvados_src_version src ""
-
-    if [[ "$?" == "0" ]]; then
-      cd "$WORKSPACE"
-      SRC_BUILD_DIR=$(mktemp -d)
-      # mktemp creates the directory with 0700 permissions by default
-      chmod 755 $SRC_BUILD_DIR
-      git clone $DASHQ_UNLESS_DEBUG "$WORKSPACE/.git" "$SRC_BUILD_DIR"
-      cd "$SRC_BUILD_DIR"
-
-      # go into detached-head state
-      git checkout $DASHQ_UNLESS_DEBUG "$COMMIT_HASH"
-      echo "$COMMIT_HASH" >git-commit.version
+handle_arvados_src
 
-      cd $WORKSPACE/packages/$TARGET
-      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"
-
-      rm -rf "$SRC_BUILD_DIR"
-    fi
-)
+# Go packages
+debug_echo -e "\nGo packages\n"
 
 # Go binaries
-cd $WORKSPACE/packages/$TARGET
-export GOPATH=$(mktemp -d)
-package_go_binary cmd/arvados-client arvados-client \
+export GOPATH=~/go
+package_go_binary cmd/arvados-client arvados-client "$FORMAT" "$ARCH" \
     "Arvados command line tool (beta)"
-package_go_binary cmd/arvados-server arvados-server \
+package_go_binary cmd/arvados-server arvados-server "$FORMAT" "$ARCH" \
     "Arvados server daemons"
-package_go_binary cmd/arvados-server arvados-controller \
+package_go_binary cmd/arvados-server arvados-controller "$FORMAT" "$ARCH" \
     "Arvados cluster controller daemon"
-package_go_binary cmd/arvados-server arvados-dispatch-cloud \
+package_go_binary cmd/arvados-server arvados-dispatch-cloud "$FORMAT" "$ARCH" \
     "Arvados cluster cloud dispatch"
-package_go_binary cmd/arvados-server arvados-dispatch-lsf \
+package_go_binary cmd/arvados-server arvados-dispatch-lsf "$FORMAT" "$ARCH" \
     "Dispatch Arvados containers to an LSF cluster"
-package_go_binary services/arv-git-httpd arvados-git-httpd \
+package_go_binary services/arv-git-httpd arvados-git-httpd "$FORMAT" "$ARCH" \
     "Provide authenticated http access to Arvados-hosted git repositories"
-package_go_binary services/crunch-dispatch-local crunch-dispatch-local \
+package_go_binary services/crunch-dispatch-local crunch-dispatch-local "$FORMAT" "$ARCH" \
     "Dispatch Crunch containers on the local system"
-package_go_binary services/crunch-dispatch-slurm crunch-dispatch-slurm \
+package_go_binary services/crunch-dispatch-slurm crunch-dispatch-slurm "$FORMAT" "$ARCH" \
     "Dispatch Crunch containers to a SLURM cluster"
-package_go_binary cmd/arvados-server crunch-run \
+package_go_binary cmd/arvados-server crunch-run "$FORMAT" "$ARCH" \
     "Supervise a single Crunch container"
-package_go_binary services/crunchstat crunchstat \
+package_go_binary services/crunchstat crunchstat "$FORMAT" "$ARCH" \
     "Gather cpu/memory/network statistics of running Crunch jobs"
-package_go_binary services/health arvados-health \
+package_go_binary services/health arvados-health "$FORMAT" "$ARCH" \
     "Check health of all Arvados cluster services"
-package_go_binary services/keep-balance keep-balance \
+package_go_binary services/keep-balance keep-balance "$FORMAT" "$ARCH" \
     "Rebalance and garbage-collect data blocks stored in Arvados Keep"
-package_go_binary services/keepproxy keepproxy \
+package_go_binary services/keepproxy keepproxy "$FORMAT" "$ARCH" \
     "Make a Keep cluster accessible to clients that are not on the LAN"
-package_go_binary cmd/arvados-server keepstore \
+package_go_binary cmd/arvados-server keepstore "$FORMAT" "$ARCH" \
     "Keep storage daemon, accessible to clients on the LAN"
-package_go_binary services/keep-web keep-web \
+package_go_binary services/keep-web keep-web "$FORMAT" "$ARCH" \
     "Static web hosting service for user data stored in Arvados Keep"
-package_go_binary cmd/arvados-server arvados-ws \
+package_go_binary cmd/arvados-server arvados-ws "$FORMAT" "$ARCH" \
     "Arvados Websocket server"
-package_go_binary tools/sync-groups arvados-sync-groups \
+package_go_binary tools/sync-groups arvados-sync-groups "$FORMAT" "$ARCH" \
     "Synchronize remote groups into Arvados from an external source"
-package_go_binary tools/keep-block-check keep-block-check \
+package_go_binary tools/keep-block-check keep-block-check "$FORMAT" "$ARCH" \
     "Verify that all data from one set of Keep servers to another was copied"
-package_go_binary tools/keep-rsync keep-rsync \
+package_go_binary tools/keep-rsync keep-rsync "$FORMAT" "$ARCH" \
     "Copy all data from one set of Keep servers to another"
-package_go_binary tools/keep-exercise keep-exercise \
+package_go_binary tools/keep-exercise keep-exercise "$FORMAT" "$ARCH" \
     "Performance testing tool for Arvados Keep"
-package_go_so lib/pam pam_arvados.so libpam-arvados-go \
+package_go_so lib/pam pam_arvados.so libpam-arvados-go "$FORMAT" "$ARCH" \
     "Arvados PAM authentication module"
 
+# Python packages
+debug_echo -e "\nPython packages\n"
+
 # The Python SDK - Python3 package
-fpm_build_virtualenv "arvados-python-client" "sdk/python" "python3"
+fpm_build_virtualenv "arvados-python-client" "sdk/python" "$FORMAT" "$ARCH"
 
 # Arvados cwl runner - Python3 package
-fpm_build_virtualenv "arvados-cwl-runner" "sdk/cwl" "python3"
+fpm_build_virtualenv "arvados-cwl-runner" "sdk/cwl" "$FORMAT" "$ARCH"
 
 # The FUSE driver - Python3 package
-fpm_build_virtualenv "arvados-fuse" "services/fuse" "python3"
+fpm_build_virtualenv "arvados-fuse" "services/fuse" "$FORMAT" "$ARCH"
 
 # The Arvados crunchstat-summary tool
-fpm_build_virtualenv "crunchstat-summary" "tools/crunchstat-summary" "python3"
+fpm_build_virtualenv "crunchstat-summary" "tools/crunchstat-summary" "$FORMAT" "$ARCH"
 
 # The Docker image cleaner
-fpm_build_virtualenv "arvados-docker-cleaner" "services/dockercleaner" "python3"
+fpm_build_virtualenv "arvados-docker-cleaner" "services/dockercleaner" "$FORMAT" "$ARCH"
 
 # The Arvados user activity tool
-fpm_build_virtualenv "arvados-user-activity" "tools/user-activity" "python3"
+fpm_build_virtualenv "arvados-user-activity" "tools/user-activity" "$FORMAT" "$ARCH"
 
 # The python->python3 metapackages
 build_metapackage "arvados-fuse" "services/fuse"
@@ -339,87 +296,15 @@ build_metapackage "arvados-docker-cleaner" "services/dockercleaner"
 build_metapackage "arvados-user-activity" "tools/user-activity"
 
 # The cwltest package, which lives out of tree
-cd "$WORKSPACE"
-if [[ -e "$WORKSPACE/cwltest" ]]; then
-       rm -rf "$WORKSPACE/cwltest"
-fi
-git clone https://github.com/common-workflow-language/cwltest.git
-# signal to our build script that we want a cwltest executable installed in /usr/bin/
-mkdir cwltest/bin && touch cwltest/bin/cwltest
-fpm_build_virtualenv "cwltest" "cwltest" "python3"
-# The python->python3 metapackage
-build_metapackage "cwltest" "cwltest"
-cd "$WORKSPACE"
-rm -rf "$WORKSPACE/cwltest"
-
-calculate_go_package_version arvados_server_version cmd/arvados-server
-arvados_server_iteration=$(default_iteration "arvados-server" "$arvados_server_version" "go")
-
-# Build the API server package
-test_rails_package_presence arvados-api-server "$WORKSPACE/services/api"
-if [[ "$?" == "0" ]]; then
-  handle_rails_package arvados-api-server "$WORKSPACE/services/api" \
-      "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
-      --description="Arvados API server - Arvados is a free and open source platform for big data science." \
-      --license="GNU Affero General Public License, version 3.0" --depends "arvados-server = ${arvados_server_version}-${arvados_server_iteration}"
-fi
+handle_cwltest "$FORMAT" "$ARCH"
 
-# Build the workbench server package
-test_rails_package_presence arvados-workbench "$WORKSPACE/apps/workbench"
-if [[ "$?" == "0" ]] ; then
-  (
-      set -e
-
-      # The workbench package has a build-time dependency on the arvados-server
-      # package for config manipulation, so install it first.
-      cd $WORKSPACE/cmd/arvados-server
-      get_complete_package_name arvados_server_pkgname arvados-server ${arvados_server_version} go
-
-      arvados_server_pkg_path="$WORKSPACE/packages/$TARGET/${arvados_server_pkgname}"
-      if [[ ! -e ${arvados_server_pkg_path} ]]; then
-        arvados_server_pkg_path="$WORKSPACE/packages/$TARGET/processed/${arvados_server_pkgname}"
-      fi
-      if [[ "$FORMAT" == "deb" ]]; then
-        dpkg -i ${arvados_server_pkg_path}
-      else
-        rpm -i ${arvados_server_pkg_path}
-      fi
-
-      cd "$WORKSPACE/apps/workbench"
-
-      # We need to bundle to be ready even when we build a package without vendor directory
-      # because asset compilation requires it.
-      bundle install --system >"$STDOUT_IF_DEBUG"
-
-      # clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
-      # and we want that in the package, so it's easier to not exclude the tmp directory
-      # from the package - empty it instead.
-      rm -rf tmp
-      mkdir tmp
-
-      # Set up an appropriate config.yml
-      arvados-server config-dump -config <(cat /etc/arvados/config.yml 2>/dev/null || echo  "Clusters: {zzzzz: {}}") > /tmp/x
-      mkdir -p /etc/arvados/
-      mv /tmp/x /etc/arvados/config.yml
-      perl -p -i -e 'BEGIN{undef $/;} s/WebDAV(.*?):\n( *)ExternalURL: ""/WebDAV$1:\n$2ExternalURL: "example.com"/g' /etc/arvados/config.yml
-
-      ARVADOS_CONFIG=none RAILS_ENV=production RAILS_GROUPS=assets bin/rake npm:install >"$STDOUT_IF_DEBUG"
-      ARVADOS_CONFIG=none RAILS_ENV=production RAILS_GROUPS=assets bin/rake assets:precompile >"$STDOUT_IF_DEBUG"
-
-      # Remove generated configuration files so they don't go in the package.
-      rm -rf /etc/arvados/
-  )
-
-  if [[ "$?" != "0" ]]; then
-    echo "ERROR: Asset precompilation failed"
-    EXITCODE=1
-  else
-    handle_rails_package arvados-workbench "$WORKSPACE/apps/workbench" \
-        "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
-        --description="Arvados Workbench - Arvados is a free and open source platform for big data science." \
-        --license="GNU Affero General Public License, version 3.0" --depends "arvados-server = ${arvados_server_version}-${arvados_server_iteration}"
-  fi
-fi
+# Rails packages
+debug_echo -e "\nRails packages\n"
+
+# The rails api server package
+handle_api_server "$ARCH"
+# The rails workbench package
+handle_workbench "$ARCH"
 
 # clean up temporary GOPATH
 rm -rf "$GOPATH"
index 1c8296dfca354f2feb2fb577d1aece345e82cbef..e36c4e88c0d0bf146ac88a9d12587ef03b9a960e 100755 (executable)
@@ -11,6 +11,10 @@ Syntax:
 
 --target <target>
     Distribution to build packages for (default: debian10)
+--only-build <package>
+    Build only a specific package (or ONLY_BUILD from environment)
+--arch <arch>
+    Build a specific architecture (or ARCH from environment, defaults to native architecture)
 --upload
     If the build and test steps are successful, upload the packages
     to a remote apt repository (default: false)
@@ -44,7 +48,7 @@ if ! [[ -d "$WORKSPACE" ]]; then
 fi
 
 PARSEDOPTS=$(getopt --name "$0" --longoptions \
-    help,debug,upload,rc,target:,build-version: \
+    help,debug,upload,rc,target:,only-build:,arch:,build-version: \
     -- "" "$@")
 if [ $? -ne 0 ]; then
     exit 1
@@ -68,6 +72,12 @@ while [ $# -gt 0 ]; do
         --target)
             TARGET="$2"; shift
             ;;
+        --only-build)
+            ONLY_BUILD="$2"; shift
+            ;;
+        --arch)
+            ARCH="$2"; shift
+            ;;
         --debug)
             DEBUG=" --debug"
             ;;
@@ -93,6 +103,14 @@ done
 
 build_args+=(--target "$TARGET")
 
+if [[ -n "$ONLY_BUILD" ]]; then
+  build_args+=(--only-build "$ONLY_BUILD")
+fi
+
+if [[ -n "$ARCH" ]]; then
+  build_args+=(--arch "$ARCH")
+fi
+
 exit_cleanly() {
     trap - INT
     report_outcomes
index 4a3e756ad920bca734f12ea5a40f64668f40d77b..b0d4daa722bd2440a4d471ea5b2a62cb1cbbe289 100755 (executable)
@@ -79,6 +79,25 @@ calculate_python_sdk_cwl_package_versions() {
   cwl_runner_version=$(cd sdk/cwl && python3 arvados_version.py)
 }
 
+# Usage: get_native_arch
+get_native_arch() {
+  # Only amd64 and aarch64 are supported at the moment
+  local native_arch=""
+  case "$HOSTTYPE" in
+    x86_64)
+      native_arch="amd64"
+      ;;
+    aarch64)
+      native_arch="arm64"
+      ;;
+    *)
+      echo "Error: architecture not supported"
+      exit 1
+      ;;
+  esac
+  echo $native_arch
+}
+
 handle_ruby_gem() {
     local gem_name="$1"; shift
     local gem_version="$(nohash_version_from_git)"
@@ -130,36 +149,106 @@ calculate_go_package_version() {
   __returnvar="$version"
 }
 
-# Usage: package_go_binary services/foo arvados-foo "Compute foo to arbitrary precision" [apache-2.0.txt]
+# Usage: package_go_binary services/foo arvados-foo [deb|rpm] [amd64|arm64] "Compute foo to arbitrary precision" [apache-2.0.txt]
 package_go_binary() {
+  local src_path="$1"; shift
+  local prog="$1"; shift
+  local package_format="$1"; shift
+  local target_arch="$1"; shift
+  local description="$1"; shift
+  local license_file="${1:-agpl-3.0.txt}"; shift
+
+  if [[ -n "$ONLY_BUILD" ]] && [[ "$prog" != "$ONLY_BUILD" ]]; then
+    # arvados-workbench depends on arvados-server at build time, so even when
+    # only arvados-workbench is being built, we need to build arvados-server too
+    if [[ "$prog" != "arvados-server" ]] || [[ "$ONLY_BUILD" != "arvados-workbench" ]]; then
+      debug_echo -e "Skipping build of $prog package."
+      return 0
+    fi
+  fi
+
+  native_arch=$(get_native_arch)
+
+  if [[ "$native_arch" != "amd64" ]] && [[ -n "$target_arch" ]] && [[ "$native_arch" != "$target_arch" ]]; then
+    echo "Error: no cross compilation support for Go on $native_arch, can not build $prog for $target_arch"
+    return 1
+  fi
+
+  cross_compilation=1
+  if [[ "$TARGET" == "centos7" ]]; then
+    if [[ "$native_arch" == "amd64" ]] && [[ -n "$target_arch" ]] && [[ "$native_arch" != "$target_arch" ]]; then
+      echo "Error: no cross compilation support for Go on $native_arch for $TARGET, can not build $prog for $target_arch"
+      return 1
+    fi
+    cross_compilation=0
+  fi
+
+  if [[ "$package_format" == "deb" ]] &&
+     [[ "$TARGET" == "debian10" ]] || [[ "$TARGET" == "ubuntu1804" ]] || [[ "$TARGET" == "ubuntu2004" ]]; then
+    # Due to bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477 the libfuse-dev package for arm64 does
+    # not install properly side by side with the amd64 version before Debian 11.
+    if [[ "$native_arch" == "amd64" ]] && [[ -n "$target_arch" ]] && [[ "$native_arch" != "$target_arch" ]]; then
+      echo "Error: no cross compilation support for Go on $native_arch for $TARGET, can not build $prog for $target_arch"
+      return 1
+    fi
+    cross_compilation=0
+  fi
+
+  if [[ -n "$target_arch" ]]; then
+    archs=($target_arch)
+  else
+    # No target architecture specified, default to native target. When on amd64
+    # also crosscompile arm64 (when supported).
+    archs=($native_arch)
+    if [[ $cross_compilation -ne 0 ]]; then
+      archs+=("arm64")
+    fi
+  fi
+
+  for ta in ${archs[@]}; do
+    package_go_binary_worker "$src_path" "$prog" "$package_format" "$description" "$native_arch" "$ta" "$license_file"
+    retval=$?
+    if [[ $retval -ne 0 ]]; then
+      return $retval
+    fi
+  done
+}
+
+# Usage: package_go_binary services/foo arvados-foo deb "Compute foo to arbitrary precision" [amd64/arm64] [amd64/arm64] [apache-2.0.txt]
+package_go_binary_worker() {
     local src_path="$1"; shift
     local prog="$1"; shift
+    local package_format="$1"; shift
     local description="$1"; shift
+    local native_arch="${1:-amd64}"; shift
+    local target_arch="${1:-amd64}"; shift
     local license_file="${1:-agpl-3.0.txt}"; shift
 
-    if [[ -n "$ONLY_BUILD" ]] && [[ "$prog" != "$ONLY_BUILD" ]]; then
-      # arvados-workbench depends on arvados-server at build time, so even when
-      # only arvados-workbench is being built, we need to build arvados-server too
-      if [[ "$prog" != "arvados-server" ]] || [[ "$ONLY_BUILD" != "arvados-workbench" ]]; then
-        return 0
-      fi
-    fi
-
-    debug_echo "package_go_binary $src_path as $prog"
-
+    debug_echo "package_go_binary $src_path as $prog (native arch: $native_arch, target arch: $target_arch)"
     local basename="${src_path##*/}"
     calculate_go_package_version go_package_version $src_path
 
     cd $WORKSPACE/packages/$TARGET
-    test_package_presence $prog $go_package_version go
-
-    if [[ "$?" != "0" ]]; then
-      return 1
+    test_package_presence "$prog" "$go_package_version" "go" "" "$target_arch"
+    if [[ $? -ne 0 ]]; then
+      return 0
     fi
 
-    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"
+    echo "Building $package_format ($target_arch) package for $prog from $src_path"
+    if [[ "$native_arch" == "amd64" ]] && [[ "$target_arch" == "arm64" ]]; then
+      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"
+    else
+      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"
+    fi
 
     local -a switches=()
+
+    binpath=$GOPATH/bin/${basename}
+    if [[ "${target_arch}" != "${native_arch}" ]]; then
+      switches+=("-a${target_arch}")
+      binpath="$GOPATH/bin/linux_${target_arch}/${basename}"
+    fi
+
     systemd_unit="$WORKSPACE/${src_path}/${prog}.service"
     if [[ -e "${systemd_unit}" ]]; then
         switches+=(
@@ -169,16 +258,23 @@ package_go_binary() {
     fi
     switches+=("$WORKSPACE/${license_file}=/usr/share/doc/$prog/${license_file}")
 
-    fpm_build "${WORKSPACE}/${src_path}" "$GOPATH/bin/${basename}=/usr/bin/${prog}" "${prog}" dir "${go_package_version}" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=${description}" "${switches[@]}"
+    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[@]}"
 }
 
-# Usage: package_go_so lib/foo arvados_foo.so arvados-foo "Arvados foo library"
+# Usage: package_go_so lib/foo arvados_foo.so arvados-foo deb amd64 "Arvados foo library"
 package_go_so() {
     local src_path="$1"; shift
     local sofile="$1"; shift
     local pkg="$1"; shift
+    local package_format="$1"; shift
+    local target_arch="$1"; shift # supported: amd64, arm64
     local description="$1"; shift
 
+    if [[ -n "$ONLY_BUILD" ]] && [[ "$pkg" != "$ONLY_BUILD" ]]; then
+      debug_echo -e "Skipping build of $pkg package."
+      return 0
+    fi
+
     debug_echo "package_go_so $src_path as $pkg"
 
     calculate_go_package_version go_package_version $src_path
@@ -282,19 +378,18 @@ get_complete_package_name() {
   fi
 
   if [[ "$arch" == "" ]]; then
-    rpm_architecture="x86_64"
-    deb_architecture="amd64"
+    native_arch=$(get_native_arch)
+    rpm_native_arch="x86_64"
+    if [[ "$HOSTTYPE" == "aarch64" ]]; then
+      rpm_native_arch="arm64"
+    fi
+    rpm_architecture="$rpm_native_arch"
+    deb_architecture="$native_arch"
 
     if [[ "$pkgtype" =~ ^(src)$ ]]; then
       rpm_architecture="noarch"
       deb_architecture="all"
     fi
-
-    # These python packages have binary components
-    if [[ "$pkgname" =~ (ruamel|ciso|pycrypto|pyyaml) ]]; then
-      rpm_architecture="x86_64"
-      deb_architecture="amd64"
-    fi
   else
     rpm_architecture=$arch
     deb_architecture=$arch
@@ -325,7 +420,7 @@ test_package_presence() {
     fi
 
     local full_pkgname
-    get_complete_package_name full_pkgname $pkgname $version $pkgtype $iteration $arch
+    get_complete_package_name full_pkgname "$pkgname" "$version" "$pkgtype" "$iteration" "$arch"
 
     # See if we can skip building the package, only if it already exists in the
     # processed/ directory. If so, move it back to the packages directory to make
@@ -431,14 +526,253 @@ handle_rails_package() {
     rm -rf "$scripts_dir"
 }
 
+# Usage: handle_api_server [amd64|arm64]
+handle_api_server () {
+  local target_arch="${1:-amd64}"; shift
+
+  if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "arvados-api-server" ]] ; then
+    debug_echo -e "Skipping build of arvados-api-server package."
+    return 0
+  fi
+
+  native_arch=$(get_native_arch)
+  if [[ "$target_arch" != "$native_arch" ]]; then
+    echo "Error: no cross compilation support for Rails yet, can not build arvados-api-server for $ARCH"
+    echo
+    exit 1
+  fi
+
+  # Build the API server package
+  test_rails_package_presence arvados-api-server "$WORKSPACE/services/api"
+  if [[ "$?" == "0" ]]; then
+    calculate_go_package_version arvados_server_version cmd/arvados-server
+    arvados_server_iteration=$(default_iteration "arvados-server" "$arvados_server_version" "go")
+    handle_rails_package arvados-api-server "$WORKSPACE/services/api" \
+        "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
+        --description="Arvados API server - Arvados is a free and open source platform for big data science." \
+        --license="GNU Affero General Public License, version 3.0" --depends "arvados-server = ${arvados_server_version}-${arvados_server_iteration}"
+  fi
+}
+
+# Usage: handle_workbench [amd64|arm64]
+handle_workbench () {
+  local target_arch="${1:-amd64}"; shift
+  if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "arvados-workbench" ]] ; then
+    debug_echo -e "Skipping build of arvados-workbench package."
+    return 0
+  fi
+
+  native_arch=$(get_native_arch)
+  if [[ "$target_arch" != "$native_arch" ]]; then
+    echo "Error: no cross compilation support for Rails yet, can not build arvados-workbench for $native_arch"
+    echo
+    exit 1
+  fi
+
+  if [[ "$native_arch" != "amd64" ]]; then
+    echo "Error: building the arvados-workbench package is not yet supported on this architecture ($native_arch)."
+    echo
+    exit 1
+  fi
+
+  # Build the workbench server package
+  test_rails_package_presence arvados-workbench "$WORKSPACE/apps/workbench"
+  if [[ "$?" == "0" ]] ; then
+    (
+        set -e
+
+        calculate_go_package_version arvados_server_version cmd/arvados-server
+        arvados_server_iteration=$(default_iteration "arvados-server" "$arvados_server_version" "go")
+
+        # The workbench package has a build-time dependency on the arvados-server
+        # package for config manipulation, so install it first.
+        cd $WORKSPACE/cmd/arvados-server
+        get_complete_package_name arvados_server_pkgname arvados-server ${arvados_server_version} go
+
+        arvados_server_pkg_path="$WORKSPACE/packages/$TARGET/${arvados_server_pkgname}"
+        if [[ ! -e ${arvados_server_pkg_path} ]]; then
+          arvados_server_pkg_path="$WORKSPACE/packages/$TARGET/processed/${arvados_server_pkgname}"
+        fi
+        if [[ "$FORMAT" == "deb" ]]; then
+          dpkg -i ${arvados_server_pkg_path}
+        else
+          rpm -i ${arvados_server_pkg_path}
+        fi
+
+        cd "$WORKSPACE/apps/workbench"
+
+        # We need to bundle to be ready even when we build a package without vendor directory
+        # because asset compilation requires it.
+        bundle install --system >"$STDOUT_IF_DEBUG"
+
+        # clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
+        # and we want that in the package, so it's easier to not exclude the tmp directory
+        # from the package - empty it instead.
+        rm -rf tmp
+        mkdir tmp
+
+        # Set up an appropriate config.yml
+        arvados-server config-dump -config <(cat /etc/arvados/config.yml 2>/dev/null || echo  "Clusters: {zzzzz: {}}") > /tmp/x
+        mkdir -p /etc/arvados/
+        mv /tmp/x /etc/arvados/config.yml
+        perl -p -i -e 'BEGIN{undef $/;} s/WebDAV(.*?):\n( *)ExternalURL: ""/WebDAV$1:\n$2ExternalURL: "example.com"/g' /etc/arvados/config.yml
+
+        ARVADOS_CONFIG=none RAILS_ENV=production RAILS_GROUPS=assets bin/rake npm:install >"$STDOUT_IF_DEBUG"
+        ARVADOS_CONFIG=none RAILS_ENV=production RAILS_GROUPS=assets bin/rake assets:precompile >"$STDOUT_IF_DEBUG"
+
+        # Remove generated configuration files so they don't go in the package.
+        rm -rf /etc/arvados/
+    )
+
+    if [[ "$?" != "0" ]]; then
+      echo "ERROR: Asset precompilation failed"
+      EXITCODE=1
+    else
+      handle_rails_package arvados-workbench "$WORKSPACE/apps/workbench" \
+          "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
+          --description="Arvados Workbench - Arvados is a free and open source platform for big data science." \
+          --license="GNU Affero General Public License, version 3.0" --depends "arvados-server = ${arvados_server_version}-${arvados_server_iteration}"
+    fi
+  fi
+}
+
+# Usage: handle_cwltest [deb|rpm] [amd64|arm64]
+handle_cwltest () {
+  local package_format="$1"; shift
+  local target_arch="${1:-amd64}"; shift
+
+  if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "python3-cwltest" ]] ; then
+    debug_echo -e "Skipping build of cwltest package."
+    return 0
+  fi
+  cd "$WORKSPACE"
+  if [[ -e "$WORKSPACE/cwltest" ]]; then
+    rm -rf "$WORKSPACE/cwltest"
+  fi
+  git clone https://github.com/common-workflow-language/cwltest.git
+  # signal to our build script that we want a cwltest executable installed in /usr/bin/
+  mkdir cwltest/bin && touch cwltest/bin/cwltest
+  fpm_build_virtualenv "cwltest" "cwltest" "$package_format" "$target_arch"
+  # The python->python3 metapackage
+  build_metapackage "cwltest" "cwltest"
+  cd "$WORKSPACE"
+  rm -rf "$WORKSPACE/cwltest"
+}
+
+# Usage: handle_arvados_src
+handle_arvados_src () {
+  if [[ -n "$ONLY_BUILD" ]] && [[ "$ONLY_BUILD" != "arvados-src" ]] ; then
+    debug_echo -e "Skipping build of arvados-src package."
+    return 0
+  fi
+  # arvados-src
+  (
+      cd "$WORKSPACE"
+      COMMIT_HASH=$(format_last_commit_here "%H")
+      arvados_src_version="$(version_from_git)"
+
+      cd $WORKSPACE/packages/$TARGET
+      test_package_presence arvados-src "$arvados_src_version" src ""
+
+      if [[ "$?" == "0" ]]; then
+        cd "$WORKSPACE"
+        SRC_BUILD_DIR=$(mktemp -d)
+        # mktemp creates the directory with 0700 permissions by default
+        chmod 755 $SRC_BUILD_DIR
+        git clone $DASHQ_UNLESS_DEBUG "$WORKSPACE/.git" "$SRC_BUILD_DIR"
+        cd "$SRC_BUILD_DIR"
+
+        # go into detached-head state
+        git checkout $DASHQ_UNLESS_DEBUG "$COMMIT_HASH"
+        echo "$COMMIT_HASH" >git-commit.version
+
+        cd $WORKSPACE/packages/$TARGET
+        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"
+
+        rm -rf "$SRC_BUILD_DIR"
+      fi
+  )
+}
+
+# Usage: handle_libarvados_perl
+handle_libarvados_perl () {
+  if [[ -n "$ONLY_BUILD" ]] || [[ "$ONLY_BUILD" != "libarvados-perl" ]] ; then
+    debug_echo -e "Skipping build of libarvados-perl package."
+    return 0
+  fi
+  cd "$WORKSPACE/sdk/perl"
+  libarvados_perl_version="$(version_from_git)"
+
+  cd $WORKSPACE/packages/$TARGET
+  test_package_presence libarvados-perl "$libarvados_perl_version"
+
+  if [[ "$?" == "0" ]]; then
+    cd "$WORKSPACE/sdk/perl"
+
+    if [[ -e Makefile ]]; then
+      make realclean >"$STDOUT_IF_DEBUG"
+    fi
+    find -maxdepth 1 \( -name 'MANIFEST*' -or -name "libarvados-perl*.$FORMAT" \) \
+        -delete
+    rm -rf install
+
+    perl Makefile.PL INSTALL_BASE=install >"$STDOUT_IF_DEBUG" && \
+        make install INSTALLDIRS=perl >"$STDOUT_IF_DEBUG" && \
+        fpm_build "$WORKSPACE/sdk/perl" install/lib/=/usr/share libarvados-perl \
+        dir "$(version_from_git)" install/man/=/usr/share/man \
+        "$WORKSPACE/apache-2.0.txt=/usr/share/doc/libarvados-perl/apache-2.0.txt" && \
+        mv --no-clobber libarvados-perl*.$FORMAT "$WORKSPACE/packages/$TARGET/"
+  fi
+}
+
 # Build python packages with a virtualenv built-in
+# Usage: fpm_build_virtualenv arvados-python-client sdk/python [deb|rpm] [amd64|arm64]
 fpm_build_virtualenv () {
-  PKG=$1
-  shift
-  PKG_DIR=$1
-  shift
-  PACKAGE_TYPE=${1:-python}
-  shift
+  local pkg=$1; shift
+  local pkg_dir=$1; shift
+  local package_format="$1"; shift
+  local target_arch="${1:-amd64}"; shift
+
+  native_arch=$(get_native_arch)
+
+  if [[ "$pkg" != "arvados-docker-cleaner" ]]; then
+    PYTHON_PKG=$PYTHON3_PKG_PREFIX-$pkg
+  else
+    # Exception to our package naming convention
+    PYTHON_PKG=$pkg
+  fi
+
+  if [[ -n "$ONLY_BUILD" ]] && [[ "$PYTHON_PKG" != "$ONLY_BUILD" ]]; then
+    # arvados-python-client sdist should always be built if we are building a
+    # python package.
+    if [[ "$ONLY_BUILD" != "python3-arvados-cwl-runner" ]] &&
+       [[ "$ONLY_BUILD" != "python3-arvados-fuse" ]] &&
+       [[ "$ONLY_BUILD" != "python3-crunchstat-summary" ]] &&
+       [[ "$ONLY_BUILD" != "arvados-docker-cleaner" ]] &&
+       [[ "$ONLY_BUILD" != "python3-arvados-user-activity" ]]; then
+      debug_echo -e "Skipping build of $pkg package."
+      return 0
+    fi
+  fi
+
+  if [[ -n "$target_arch" ]] && [[ "$native_arch" == "$target_arch" ]]; then
+      fpm_build_virtualenv_worker "$pkg" "$pkg_dir" "$package_format" "$native_arch" "$target_arch"
+  elif [[ -z "$target_arch" ]]; then
+    fpm_build_virtualenv_worker "$pkg" "$pkg_dir" "$package_format" "$native_arch" "$native_arch"
+  else
+    echo "Error: no cross compilation support for Python yet, can not build $pkg for $target_arch"
+    return 1
+  fi
+}
+
+# Build python packages with a virtualenv built-in
+# Usage: fpm_build_virtualenv_worker arvados-python-client sdk/python python3 [deb|rpm] [amd64|arm64] [amd64|arm64]
+fpm_build_virtualenv_worker () {
+  PKG=$1; shift
+  PKG_DIR=$1; shift
+  local package_format="$1"; shift
+  local native_arch="${1:-amd64}"; shift
+  local target_arch=${1:-amd64}; shift
 
   # Set up
   STDOUT_IF_DEBUG=/dev/null
@@ -453,14 +787,9 @@ fpm_build_virtualenv () {
     ARVADOS_BUILDING_ITERATION=1
   fi
 
-  local python=""
-  case "$PACKAGE_TYPE" in
-    python3)
-        python=python3
-        pip=pip3
-        PACKAGE_PREFIX=$PYTHON3_PKG_PREFIX
-        ;;
-  esac
+  local python=python3
+  pip=pip3
+  PACKAGE_PREFIX=$PYTHON3_PKG_PREFIX
 
   if [[ "$PKG" != "arvados-docker-cleaner" ]]; then
     PYTHON_PKG=$PACKAGE_PREFIX-$PKG
@@ -469,12 +798,6 @@ fpm_build_virtualenv () {
     PYTHON_PKG=$PKG
   fi
 
-  # arvados-python-client sdist should always be built, to be available
-  # for other dependent packages.
-  if [[ -n "$ONLY_BUILD" ]] && [[ "arvados-python-client" != "$PKG" ]] && [[ "$PYTHON_PKG" != "$ONLY_BUILD" ]] && [[ "$PKG" != "$ONLY_BUILD" ]]; then
-    return 0
-  fi
-
   cd $WORKSPACE/$PKG_DIR
 
   rm -rf dist/*
@@ -514,11 +837,11 @@ fpm_build_virtualenv () {
   # We can't do this earlier than here, because we need PYTHON_VERSION...
   # This isn't so bad; the sdist call above is pretty quick compared to
   # the invocation of virtualenv and fpm, below.
-  if ! test_package_presence "$PYTHON_PKG" $UNFILTERED_PYTHON_VERSION $PACKAGE_TYPE $ARVADOS_BUILDING_ITERATION; then
+  if ! test_package_presence "$PYTHON_PKG" "$UNFILTERED_PYTHON_VERSION" "$python" "$ARVADOS_BUILDING_ITERATION" "$target_arch"; then
     return 0
   fi
 
-  echo "Building $FORMAT package for $PKG from $PKG_DIR"
+  echo "Building $package_format ($target_arch) package for $PKG from $PKG_DIR"
 
   # Package the sdist in a virtualenv
   echo "Creating virtualenv..."
@@ -601,7 +924,11 @@ fpm_build_virtualenv () {
   # Finally, generate the package
   echo "Creating package..."
 
-  declare -a COMMAND_ARR=("fpm" "-s" "dir" "-t" "$FORMAT")
+  declare -a COMMAND_ARR=("fpm" "-s" "dir" "-t" "$package_format")
+
+  if [[ -n "$target_arch" ]] && [[ "$target_arch" != "amd64" ]]; then
+    COMMAND_ARR+=("-a$target_arch")
+  fi
 
   if [[ "$MAINTAINER" != "" ]]; then
     COMMAND_ARR+=('--maintainer' "$MAINTAINER")
@@ -621,7 +948,7 @@ fpm_build_virtualenv () {
   LICENSE_STRING=`grep license $WORKSPACE/$PKG_DIR/setup.py|cut -f2 -d=|sed -e "s/[',\\"]//g"`
   COMMAND_ARR+=('--license' "$LICENSE_STRING")
 
-  if [[ "$FORMAT" == "rpm" ]]; then
+  if [[ "$package_format" == "rpm" ]]; then
     # Make sure to conflict with the old rh-python36 packages we used to publish
     COMMAND_ARR+=('--conflicts' "rh-python36-python-$PKG")
   fi
@@ -707,8 +1034,8 @@ fpm_build_virtualenv () {
     echo
     echo -e "\n${COMMAND_ARR[@]}\n"
   else
-    echo `ls *$FORMAT`
-    mv $WORKSPACE/$PKG_DIR/dist/*$FORMAT $WORKSPACE/packages/$TARGET/
+    echo `ls *$package_format`
+    mv $WORKSPACE/$PKG_DIR/dist/*$package_format $WORKSPACE/packages/$TARGET/
   fi
   echo
 }
index 5dba59b758c52bcef49c2854f8a61de9352f6ed8..492dde1dc69987e4d287510c799929462dc8a350 100755 (executable)
@@ -3,8 +3,6 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
-. `dirname "$(readlink -f "$0")"`/libcloud-pin.sh
-
 COLUMNS=80
 . `dirname "$(readlink -f "$0")"`/run-library.sh