From ed1bfbcb233052c1a989dfc294793f076a345994 Mon Sep 17 00:00:00 2001 From: Paul Bastide Date: Wed, 24 May 2023 14:57:58 -0400 Subject: [PATCH] MULTIARCH-3440: update the code to use go-containerregistry for all arches and add arm64 Signed-off-by: Paul Bastide --- .goreleaser.yaml | 1 + Dockerfile | 9 +++------ test/e2e/lib/util.sh | 30 +++++++++++------------------- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 34df5c317..52a88e552 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -13,6 +13,7 @@ builds: - amd64 - ppc64le - s390x + - arm64 env: - CGO_ENABLED=1 flags: diff --git a/Dockerfile b/Dockerfile index 0f9014e06..016b79620 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,22 +20,19 @@ ARG DNF_LIST="\ ################################################################################# # Build UBI8 Builder with multi-arch support -# Link gcc to /usr/bin/s390x-linux-gnu-gcc as go requires it on s390x RUN set -ex \ - && ARCH=$(arch | sed 's|x86_64|amd64|g') \ + && ARCH=$(arch | sed 's|x86_64|amd64|g' | sed 's|aarch64|arm64|g') \ && dnf install -y --nodocs --setopt=install_weak_deps=false ${DNF_LIST} \ && dnf clean all -y \ && GO_VERSION=go1.19.5 \ && curl -sL https://golang.org/dl/${GO_VERSION}.linux-${ARCH}.tar.gz \ | tar xzvf - --directory /usr/local/ \ && /usr/local/go/bin/go version \ - && ln -f /usr/local/go/bin/go /usr/bin/go \ - && ln /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc + && ln -f /usr/local/go/bin/go /usr/bin/go ################################################################################# # Link gcc to /usr/bin/s390x-linux-gnu-gcc as go requires it on s390x -RUN ARCH=$(arch | sed 's|x86_64|amd64|g') \ - && [ "${ARCH}" == "s390x" ] \ +RUN [ "$(arch)" == "s390x" ] \ && ln /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc \ || echo "Not running on s390x, skip linking gcc binary" diff --git a/test/e2e/lib/util.sh b/test/e2e/lib/util.sh index 7fc9c4748..0702a2e25 100644 --- a/test/e2e/lib/util.sh +++ b/test/e2e/lib/util.sh @@ -55,33 +55,25 @@ function install_deps() { tar xvf opm.tar bin/opm mv bin/opm $GOBIN rm -f registry2.tar opm.tar - wget -O $GOBIN/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 - chmod +x $GOBIN/jq + wget -O $GOBIN/jq https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 + chmod +x $GOBIN/jq else + # non-x86_64 flow pushd ${DATA_TMP} - # Creates a temp directory - mkdir -p test/e2e/operator-test.deps - cd test/e2e/operator-test.deps - curl -o $GOBIN/opm -L https://github.com/operator-framework/operator-registry/releases/download/v1.26.5/linux-$(arch)-opm + # For ppc64le, this is compiled with Power9 compatibility (does not run on Power8) + ARCH=$(arch | sed 's|aarch64|arm64|g') + curl -o $GOBIN/opm -L https://github.com/operator-framework/operator-registry/releases/download/v1.27.1/linux-${ARCH}-opm chmod +x $GOBIN/opm - # Serves a local registry - # When PR https://github.com/google/go-containerregistry/pull/1680 - # is in a release the following few lines won't be necessary. - git clone https://github.com/google/go-containerregistry.git - cd go-containerregistry - git checkout $(git describe --tags) # latest tag - go build ./cmd/crane - mv crane $GOBIN/ - - crane export $(arch)/registry:2 registry2.tar + GOFLAGS=-mod=mod go install github.com/google/go-containerregistry/cmd/crane@latest + mv ~/go/bin/crane $GOBIN/ + + crane export ${ARCH}/registry:2 registry2.tar tar xvf registry2.tar bin/registry - cp bin/registry ../ mv bin/registry $GOBIN + rm registry2.tar - cd .. - rm -rf go-containerregistry/ popd fi }