Skip to content

Commit

Permalink
MULTIARCH-3440: update the code to use go-containerregistry for all a…
Browse files Browse the repository at this point in the history
…rches and add arm64

Signed-off-by: Paul Bastide <pbastide@redhat.com>
  • Loading branch information
prb112 committed May 26, 2023
1 parent 0bec359 commit ed1bfbc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ builds:
- amd64
- ppc64le
- s390x
- arm64
env:
- CGO_ENABLED=1
flags:
Expand Down
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
30 changes: 11 additions & 19 deletions test/e2e/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit ed1bfbc

Please sign in to comment.