Skip to content

Commit

Permalink
Package and serve binaries for all RHEL architectures (knative#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
yselkowitz authored Jan 14, 2021
1 parent 612ee3a commit d58da33
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 17 deletions.
10 changes: 7 additions & 3 deletions openshift-serverless-clients.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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

Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions openshift/ci-operator/generate-ci-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion openshift/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions package_cliartifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
8 changes: 5 additions & 3 deletions serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d58da33

Please sign in to comment.