From d58da33a81ab8dddf5073de1f0361d4625fc3bc8 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Thu, 14 Jan 2021 07:26:14 -0500 Subject: [PATCH] Package and serve binaries for all RHEL architectures (#413) --- openshift-serverless-clients.spec | 10 +++++++--- openshift/ci-operator/generate-ci-config.sh | 6 ++++++ .../client/Dockerfile.cliartifacts | 7 +++++-- openshift/e2e-common.sh | 2 +- package_cliartifacts.sh | 17 +++++++++-------- serve.py | 8 +++++--- 6 files changed, 33 insertions(+), 17 deletions(-) diff --git a/openshift-serverless-clients.spec b/openshift-serverless-clients.spec index 361bd6f124..d20b3b30b9 100644 --- a/openshift-serverless-clients.spec +++ b/openshift-serverless-clients.spec @@ -16,8 +16,6 @@ Summary: %{product_name} client kn CLI binary License: ASL 2.0 URL: https://github.com/openshift/knative-client/tree/release-%{kn_cli_version} -ExclusiveArch: x86_64 - Source0: %{source_tar} BuildRequires: golang >= %{golang_version} Provides: %{package_name} @@ -34,10 +32,13 @@ TAG=%{kn_cli_version} make build-cross %install mkdir -p %{buildroot}/%{_bindir} -install -m 0755 kn-linux-amd64 %{buildroot}/%{_bindir}/kn +install -m 0755 kn-linux-$(go env GOARCH) %{buildroot}/%{_bindir}/kn install -d %{buildroot}%{_datadir}/%{name}-redistributable/{linux,macos,windows} install -p -m 755 kn-linux-amd64 %{buildroot}%{_datadir}/%{name}-redistributable/linux/kn-linux-amd64 +install -p -m 755 kn-linux-arm64 %{buildroot}%{_datadir}/%{name}-redistributable/linux/kn-linux-arm64 +install -p -m 755 kn-linux-ppc64le %{buildroot}%{_datadir}/%{name}-redistributable/linux/kn-linux-ppc64le +install -p -m 755 kn-linux-s390x %{buildroot}%{_datadir}/%{name}-redistributable/linux/kn-linux-s390x install -p -m 755 kn-darwin-amd64 %{buildroot}/%{_datadir}/%{name}-redistributable/macos/kn-darwin-amd64 install -p -m 755 kn-windows-amd64.exe %{buildroot}/%{_datadir}/%{name}-redistributable/windows/kn-windows-amd64.exe @@ -60,6 +61,9 @@ Obsoletes: %{package_name} < %{kn_version} %dir %{_datadir}/%{name}-redistributable/macos/ %dir %{_datadir}/%{name}-redistributable/windows/ %{_datadir}/%{name}-redistributable/linux/kn-linux-amd64 +%{_datadir}/%{name}-redistributable/linux/kn-linux-arm64 +%{_datadir}/%{name}-redistributable/linux/kn-linux-ppc64le +%{_datadir}/%{name}-redistributable/linux/kn-linux-s390x %{_datadir}/%{name}-redistributable/macos/kn-darwin-amd64 %{_datadir}/%{name}-redistributable/windows/kn-windows-amd64.exe diff --git a/openshift/ci-operator/generate-ci-config.sh b/openshift/ci-operator/generate-ci-config.sh index 03c6cbd96d..a97acd9124 100755 --- a/openshift/ci-operator/generate-ci-config.sh +++ b/openshift/ci-operator/generate-ci-config.sh @@ -53,6 +53,12 @@ images: paths: - destination_dir: . source_path: /go/src/github.com/knative/client/kn-linux-amd64 + - destination_dir: . + source_path: /go/src/github.com/knative/client/kn-linux-arm64 + - destination_dir: . + source_path: /go/src/github.com/knative/client/kn-linux-ppc64le + - destination_dir: . + source_path: /go/src/github.com/knative/client/kn-linux-s390x - destination_dir: . source_path: /go/src/github.com/knative/client/kn-darwin-amd64 - destination_dir: . diff --git a/openshift/ci-operator/knative-images/client/Dockerfile.cliartifacts b/openshift/ci-operator/knative-images/client/Dockerfile.cliartifacts index c8aeafdf20..f7d807159c 100644 --- a/openshift/ci-operator/knative-images/client/Dockerfile.cliartifacts +++ b/openshift/ci-operator/knative-images/client/Dockerfile.cliartifacts @@ -4,10 +4,13 @@ FROM registry.access.redhat.com/ubi8/ubi-minimal:latest RUN mkdir -p /opt/app-root/src/go/src/github.com/knative/client WORKDIR /opt/app-root/src/go/src/github.com/knative/client RUN microdnf install -y zip tar gzip python3 -ADD package_cliartifacts.sh LICENSE kn-*-amd64* serve.py ./ +ADD package_cliartifacts.sh LICENSE kn-*-* serve.py ./ RUN bash package_cliartifacts.sh && \ - mkdir -p /usr/share/kn/{linux_amd64,macos,windows} && \ + mkdir -p /usr/share/kn/{linux_{amd64,arm64,ppc64le,s390x},macos,windows} && \ mv kn-linux-amd64.tar.gz /usr/share/kn/linux_amd64/ && \ + mv kn-linux-arm64.tar.gz /usr/share/kn/linux_arm64/ && \ + mv kn-linux-ppc64le.tar.gz /usr/share/kn/linux_ppc64le/ && \ + mv kn-linux-s390x.tar.gz /usr/share/kn/linux_s390x/ && \ mv kn-macos-amd64.tar.gz /usr/share/kn/macos/ && \ mv kn-windows-amd64.zip /usr/share/kn/windows/ CMD ["python3", "serve.py"] diff --git a/openshift/e2e-common.sh b/openshift/e2e-common.sh index 1d491752c1..6fffa4b4e3 100755 --- a/openshift/e2e-common.sh +++ b/openshift/e2e-common.sh @@ -62,7 +62,7 @@ build_knative_client() { ./hack/build.sh -x || failed=1 if [[ $failed -eq 0 ]]; then - mv kn-linux-amd64 kn + mv kn-linux-$(go env GOARCH) kn fi return $failed diff --git a/package_cliartifacts.sh b/package_cliartifacts.sh index 0813634f8e..03e7358d03 100755 --- a/package_cliartifacts.sh +++ b/package_cliartifacts.sh @@ -17,23 +17,21 @@ pkg_tar() { local dir case "$1" in - x86_64) - dir=linux + amd64|arm64|ppc64le|s390x) + dir=linux-$1 mkdir "${OUTDIR}/${dir}" - mv kn-linux-amd64 ${OUTDIR}/${dir}/kn + mv kn-linux-$1 ${OUTDIR}/${dir}/kn chmod +x ${OUTDIR}/${dir}/kn ;; macos) - dir=macos + dir=macos-amd64 mkdir "${OUTDIR}/${dir}" mv kn-darwin-amd64 ${OUTDIR}/${dir}/kn chmod +x ${OUTDIR}/${dir}/kn ;; - #uncomment following when we support building mentioned archs - #aarch64|ppc64le|s390x) dir=linux-${1};; esac cp LICENSE ${OUTDIR}/${dir} - tar -zcf kn-${dir}-amd64.tar.gz -C ${OUTDIR}/${dir} . + tar -zcf kn-${dir}.tar.gz -C ${OUTDIR}/${dir} . } pkg_zip_for_windows() { @@ -46,6 +44,9 @@ pkg_zip_for_windows() { OUTDIR=$(mktemp -dt knbinary.XXXXXXXXXX) trap "rm -rf '${OUTDIR}'" EXIT INT TERM -pkg_tar x86_64 +pkg_tar amd64 +pkg_tar arm64 +pkg_tar ppc64le +pkg_tar s390x pkg_tar macos pkg_zip_for_windows diff --git a/serve.py b/serve.py index 4e38f296a7..afa2d9ce43 100755 --- a/serve.py +++ b/serve.py @@ -26,18 +26,20 @@ def run(self): temp_dir = tempfile.mkdtemp() print(('serving from {}'.format(temp_dir))) os.chdir(temp_dir) -for arch in ['amd64']: +for arch in ['amd64','arm64','ppc64le','s390x']: os.mkdir(arch) - for operating_system in ['linux', 'macos', 'windows']: - os.mkdir(os.path.join(arch, operating_system)) for arch, operating_system, path in [ ('amd64', 'linux', '/usr/share/kn/linux_amd64/kn-linux-amd64.tar.gz'), + ('arm64', 'linux', '/usr/share/kn/linux_amd64/kn-linux-arm64.tar.gz'), + ('ppc64le', 'linux', '/usr/share/kn/linux_ppc64le/kn-linux-ppc64le.tar.gz'), + ('s390x', 'linux', '/usr/share/kn/linux_s390x/kn-linux-s390x.tar.gz'), ('amd64', 'macos', '/usr/share/kn/macos/kn-macos-amd64.tar.gz'), ('amd64', 'windows', '/usr/share/kn/windows/kn-windows-amd64.zip'), ]: basename = os.path.basename(path) target_path = os.path.join(arch, operating_system, basename) + os.mkdir(os.path.join(arch, operating_system)) os.symlink(path, target_path) # Create socket