File kubectl.spec of Package kubernetes

# spec file for package kubectl
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%{!?tmpfiles_create:%global tmpfiles_create systemd-tmpfiles --create}
# baseversion - version of kubernetes for this package
%define baseversion 1.17
Name:           kubectl
Version:        1.18.0
Release:        0
Summary:        Kubectl (Kubernetes client tools)
License:        Apache-2.0
Group:          System/Management
Source:         kubernetes-%{version}.tar.xz
Source28:       kubernetes.obsinfo
Source30:       kubectl-rpmlintrc
BuildRequires:  bash-completion
BuildRequires:  fdupes
BuildRequires:  git
BuildRequires:  go-go-md2man
# Kubernetes 1.17.0 requires at least go 1.13.4 (see changelog)
BuildRequires:  golang(API) = 1.13
BuildRequires:  go >= 1.13.4
BuildRequires:  golang(
BuildRequires:  golang-packaging
BuildRequires:  rsync
BuildRequires:  systemd-rpm-macros
Requires:       bash-completion
# Conflict with kubernetes-client which already provides kubectl but as a link
# to hyperkube, provided by kubernetes-common
Conflicts:      kubernetes-client
# kubectl as a seperate package was created purely for use in SLE/PackageHub, not relevant to openSUSE where kubernetes-client is packaged. So disable building outside of Backports
%if 0%{?is_opensuse} && ! 0%{?is_backports}
ExclusiveArch: do-not-build
ExcludeArch:    %{ix86} s390

Kubectl (Kubernetes client tool). This package contains only the kubectl tool so
it can be distributed and installed without any other kubernetes package.

It groups containers that make up an application into logical units
for management and discovery.

%setup -q -n kubernetes-%{version}

# This is fixing bug bsc#1065972
export KUBE_GIT_COMMIT=$(grep "commit:" %{SOURCE28} | cut -d ":" -f2 | tr -d " ")
# KUBE_GIT_TREE_STATE="clean" indicates no changes since the git commit id
# KUBE_GIT_TREE_STATE="dirty" indicates source code changes after the git commit id
export KUBE_GIT_TREE_STATE="clean"
export KUBE_GIT_VERSION=v%{version}

%ifarch ppc64le
export GOLDFLAGS='-linkmode=external'
make %{?_smp_mflags} WHAT="cmd/hyperkube cmd/kubeadm test/e2e/e2e.test"
make %{?_smp_mflags} ginkgo

# The majority of the documentation has already been moved into
#, and most of the files stored in the `docs`
# directory simply point there. That being said, some of the files are actual
# man pages, but they have to be generated with `hack/`. So,
# let's do that and run ``.
./hack/ || true
pushd docs
cp %{SOURCE2}


%ifarch ppc64le aarch64

install -m 755 -d %{buildroot}%{_bindir}

cp ${output_path}/hyperkube %{buildroot}%{_bindir}/kubectl

# install the bash completion
install -d -m 0755 %{buildroot}%{_datadir}/bash-completion/completions/
%{buildroot}%{_bindir}/kubectl completion bash > %{buildroot}%{_datadir}/bash-completion/completions/kubectl

# cleanup before copying dirs...
rm -f hack/.linted_packages
find .    -name '.gitignore' -type f -delete
find hack -name '*.sh.orig' -type f -delete
find hack -name '.golint_*' -type f -delete

# install manpages
install -d %{buildroot}%{_mandir}/man1
install -p -m 644 docs/man/man1/kubectl* %{buildroot}%{_mandir}/man1
%fdupes -s %{buildroot}

%license LICENSE