From 3b3a13513d745c8a06e4c3082c448fab6e651fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 5 Jan 2023 11:30:10 +0100 Subject: [PATCH] Support arm64 builds --- builder/Dockerfile.centos-7 | 8 +++++--- builder/Dockerfile.centos-8 | 8 +++++--- builder/Dockerfile.debian-10 | 6 +++--- builder/Dockerfile.debian-11 | 6 +++--- builder/Dockerfile.opensuse-153 | 8 +++++--- builder/Dockerfile.opensuse-154 | 10 ++++++---- builder/Dockerfile.rhel-9 | 10 ++++++---- builder/Dockerfile.ubuntu-1804 | 6 +++--- builder/Dockerfile.ubuntu-2004 | 6 +++--- builder/Dockerfile.ubuntu-2204 | 6 +++--- builder/build.sh | 2 +- install.sh | 23 ++++++++++++++++++----- jenkins/Dockerfile | 2 +- 13 files changed, 62 insertions(+), 39 deletions(-) diff --git a/builder/Dockerfile.centos-7 b/builder/Dockerfile.centos-7 index 9853b61..61451ec 100644 --- a/builder/Dockerfile.centos-7 +++ b/builder/Dockerfile.centos-7 @@ -49,9 +49,11 @@ RUN yum -y update \ RUN pip3 install awscli --upgrade --user && \ ln -s /root/.local/bin/aws /usr/bin/aws -RUN curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.rpm && \ - yum install -y nfpm_amd64.rpm && \ - rm nfpm_amd64.rpm +RUN if [ "$(arch)" == "aarch64" ]; then echo arm64; else echo amd64; fi > /tmp/arch + +RUN curl -LO "https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_$(cat /tmp/arch).rpm" && \ + yum install -y "nfpm_$(cat /tmp/arch).rpm" && \ + rm "nfpm_$(cat /tmp/arch).rpm" RUN chmod 0777 /opt diff --git a/builder/Dockerfile.centos-8 b/builder/Dockerfile.centos-8 index 6f80956..5c535ab 100644 --- a/builder/Dockerfile.centos-8 +++ b/builder/Dockerfile.centos-8 @@ -50,9 +50,11 @@ RUN dnf -y upgrade \ RUN pip3 install awscli --upgrade --user \ && ln -s /root/.local/bin/aws /usr/bin/aws -RUN curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.rpm && \ - dnf install -y nfpm_amd64.rpm && \ - rm nfpm_amd64.rpm +RUN if [ "$(arch)" == "aarch64" ]; then echo arm64; else echo amd64; fi > /tmp/arch + +RUN curl -LO "https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_$(cat /tmp/arch).rpm" && \ + dnf install -y "nfpm_$(cat /tmp/arch).rpm" && \ + rm "nfpm_$(cat /tmp/arch).rpm" RUN chmod 0777 /opt diff --git a/builder/Dockerfile.debian-10 b/builder/Dockerfile.debian-10 index a6c812a..67b5e08 100644 --- a/builder/Dockerfile.debian-10 +++ b/builder/Dockerfile.debian-10 @@ -14,9 +14,9 @@ RUN pip3 install awscli RUN chmod 0777 /opt -RUN curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.deb && \ - apt install -y ./nfpm_amd64.deb && \ - rm nfpm_amd64.deb +RUN curl -LO "https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_$(dpkg --print-architecture).deb" && \ + apt install -y "./nfpm_$(dpkg --print-architecture).deb" && \ + rm "nfpm_$(dpkg --print-architecture).deb" # Override the default pager used by R ENV PAGER /usr/bin/pager diff --git a/builder/Dockerfile.debian-11 b/builder/Dockerfile.debian-11 index 1845673..b31afda 100644 --- a/builder/Dockerfile.debian-11 +++ b/builder/Dockerfile.debian-11 @@ -14,9 +14,9 @@ RUN pip3 install awscli RUN chmod 0777 /opt -RUN curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.deb && \ - apt install -y ./nfpm_amd64.deb && \ - rm nfpm_amd64.deb +RUN curl -LO "https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_$(dpkg --print-architecture).deb" && \ + apt install -y "./nfpm_$(dpkg --print-architecture).deb" && \ + rm "nfpm_$(dpkg --print-architecture).deb" # Override the default pager used by R ENV PAGER /usr/bin/pager diff --git a/builder/Dockerfile.opensuse-153 b/builder/Dockerfile.opensuse-153 index 87a144c..df3b732 100644 --- a/builder/Dockerfile.opensuse-153 +++ b/builder/Dockerfile.opensuse-153 @@ -70,9 +70,11 @@ RUN zypper --non-interactive --gpg-auto-import-keys -n install \ RUN pip install awscli -RUN curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.rpm && \ - zypper --non-interactive --no-gpg-checks install nfpm_amd64.rpm && \ - rm nfpm_amd64.rpm +RUN if [ "$(arch)" == "aarch64" ]; then echo arm64; else echo amd64; fi > /tmp/arch + +RUN curl -LO "https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_$(cat /tmp/arch).rpm" && \ + zypper --non-interactive --no-gpg-checks install "nfpm_$(cat /tmp/arch).rpm" && \ + rm "nfpm_$(cat /tmp/arch).rpm" RUN chmod 0777 /opt diff --git a/builder/Dockerfile.opensuse-154 b/builder/Dockerfile.opensuse-154 index 042f188..9bce666 100644 --- a/builder/Dockerfile.opensuse-154 +++ b/builder/Dockerfile.opensuse-154 @@ -67,14 +67,16 @@ RUN zypper --non-interactive --gpg-auto-import-keys -n install \ && zypper clean # Install AWS CLI -RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \ +RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -p).zip" -o "awscliv2.zip" && \ unzip awscliv2.zip && \ ./aws/install && \ rm -rf aws awscliv2.zip -RUN curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.rpm && \ - zypper --non-interactive --no-gpg-checks install nfpm_amd64.rpm && \ - rm nfpm_amd64.rpm +RUN if [ "$(arch)" == "aarch64" ]; then echo arm64; else echo amd64; fi > /tmp/arch + +RUN curl -LO "https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_$(cat /tmp/arch).rpm" && \ + zypper --non-interactive --no-gpg-checks install "nfpm_$(cat /tmp/arch).rpm" && \ + rm "nfpm_$(cat /tmp/arch).rpm" RUN chmod 0777 /opt diff --git a/builder/Dockerfile.rhel-9 b/builder/Dockerfile.rhel-9 index e57eb31..a96ea65 100644 --- a/builder/Dockerfile.rhel-9 +++ b/builder/Dockerfile.rhel-9 @@ -46,14 +46,16 @@ RUN dnf -y upgrade \ && dnf clean all # Install AWS CLI -RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \ +RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -p).zip" -o "awscliv2.zip" && \ unzip awscliv2.zip && \ ./aws/install && \ rm -rf aws awscliv2.zip -RUN curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.rpm && \ - dnf install -y nfpm_amd64.rpm && \ - rm nfpm_amd64.rpm +RUN if [ "$(arch)" == "aarch64" ]; then echo arm64; else echo amd64; fi > /tmp/arch + +RUN curl -LO "https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_$(cat /tmp/arch).rpm" && \ + dnf install -y "nfpm_$(cat /tmp/arch).rpm" && \ + rm "nfpm_$(cat /tmp/arch).rpm" RUN chmod 0777 /opt diff --git a/builder/Dockerfile.ubuntu-1804 b/builder/Dockerfile.ubuntu-1804 index 4c38fbd..2d0fc61 100644 --- a/builder/Dockerfile.ubuntu-1804 +++ b/builder/Dockerfile.ubuntu-1804 @@ -11,9 +11,9 @@ RUN set -x \ RUN pip install awscli -RUN curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.deb && \ - apt install -y ./nfpm_amd64.deb && \ - rm nfpm_amd64.deb +RUN curl -LO "https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_$(dpkg --print-architecture).deb" && \ + apt install -y "./nfpm_$(dpkg --print-architecture).deb" && \ + rm "nfpm_$(dpkg --print-architecture).deb" RUN chmod 0777 /opt diff --git a/builder/Dockerfile.ubuntu-2004 b/builder/Dockerfile.ubuntu-2004 index 4733f5e..6e89ff7 100644 --- a/builder/Dockerfile.ubuntu-2004 +++ b/builder/Dockerfile.ubuntu-2004 @@ -11,9 +11,9 @@ RUN set -x \ RUN pip3 install awscli -RUN curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.deb && \ - apt install -y ./nfpm_amd64.deb && \ - rm nfpm_amd64.deb +RUN curl -LO "https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_$(dpkg --print-architecture).deb" && \ + apt install -y "./nfpm_$(dpkg --print-architecture).deb" && \ + rm "nfpm_$(dpkg --print-architecture).deb" RUN chmod 0777 /opt diff --git a/builder/Dockerfile.ubuntu-2204 b/builder/Dockerfile.ubuntu-2204 index 5d28093..18ea4a0 100644 --- a/builder/Dockerfile.ubuntu-2204 +++ b/builder/Dockerfile.ubuntu-2204 @@ -11,9 +11,9 @@ RUN set -x \ RUN pip3 install awscli -RUN curl -LO https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_amd64.deb && \ - apt install -y ./nfpm_amd64.deb && \ - rm nfpm_amd64.deb +RUN curl -LO "https://github.com/goreleaser/nfpm/releases/download/v2.18.1/nfpm_$(dpkg --print-architecture).deb" && \ + apt install -y "./nfpm_$(dpkg --print-architecture).deb" && \ + rm "nfpm_$(dpkg --print-architecture).deb" RUN chmod 0777 /opt diff --git a/builder/build.sh b/builder/build.sh index 565a677..e40064d 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -67,7 +67,7 @@ compile_r() { # tools/config.guess in R versions older than 3.2.2 guess 'unknown' instead of 'pc' # test the version and properly set the flag. - build_flag='--build=x86_64-pc-linux-gnu' + build_flag="--build=$(uname -p)-pc-linux-gnu" if _version_is_greater_than ${R_VERSION} 3.2.2; then build_flag='' fi diff --git a/install.sh b/install.sh index 44ccaef..7c3dd97 100755 --- a/install.sh +++ b/install.sh @@ -144,19 +144,30 @@ do_show_versions () { done } -# Returns the installer name for a given version and OS +# Returns the installer name for a given version, OS, arch download_name () { os=$1 version=$2 + arch=$3 + case $arch in + "x86_64" | "amd64") + rpm_arch="x86_64" + deb_arch="amd64" + ;; + "aarch64") + rpm_arch="aarch64" + deb_arch="arm64" + ;; + esac case $os in "RedHat" | "CentOS" | "Amazon" | "Alma" | "Rocky") - echo "R-${version}-1-1.x86_64.rpm" + echo "R-${version}-1-1.${rpm_arch}.rpm" ;; "Ubuntu" | "Debian") - echo "r-${version}_1_amd64.deb" + echo "r-${version}_1_${deb_arch}.deb" ;; "LEAP12" | "LEAP15" | "SLES12" | "SLES15") - echo "R-${version}-1-1.x86_64.rpm" + echo "R-${version}-1-1.${rpm_arch}.rpm" ;; esac } @@ -486,8 +497,10 @@ do_install () { prompt_version [ -z $SELECTED_VERSION ] && { echo "Invalid version"; exit 1; } + arch=$(uname -p) + # Get the name of the installer to use - installer_file_name=$(download_name "${os}" "${SELECTED_VERSION}") + installer_file_name=$(download_name "${os}" "${SELECTED_VERSION}" "${arch}") # Get the URL to download from. If the installer already exists in the current # directory, this will return a blank string. diff --git a/jenkins/Dockerfile b/jenkins/Dockerfile index 0c27a8b..fafa24e 100644 --- a/jenkins/Dockerfile +++ b/jenkins/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update -qq && apt-get install -y python-pip RUN pip install awscli # install docker cli -RUN wget -q -O /tmp/docker-cli.deb https://download.docker.com/linux/debian/dists/stretch/pool/stable/amd64/docker-ce-cli_18.09.2~3-0~debian-stretch_amd64.deb \ +RUN wget -q -O /tmp/docker-cli.deb https://download.docker.com/linux/debian/dists/stretch/pool/stable/$(dpkg --print-architecture)/docker-ce-cli_18.09.2~3-0~debian-stretch_$(dpkg --print-architecture).deb \ && dpkg -i /tmp/docker-cli.deb RUN npm install -g serverless