commit:     e7bb372cd624e03d26c9b98d1cdcd0e3eea97fde
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Sun Feb  8 10:38:43 2026 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Fri Feb 13 17:27:51 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e7bb372c

sys-cluster/kubectl: Fix cross-compiling

Closes: https://github.com/gentoo/gentoo/pull/45684

Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
Signed-off-by: William Hubbs <williamh <AT> gentoo.org>

 sys-cluster/kubectl/kubectl-1.35.0.ebuild | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/sys-cluster/kubectl/kubectl-1.35.0.ebuild 
b/sys-cluster/kubectl/kubectl-1.35.0.ebuild
index 01373c7aa851..23967ac4b0f2 100644
--- a/sys-cluster/kubectl/kubectl-1.35.0.ebuild
+++ b/sys-cluster/kubectl/kubectl-1.35.0.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=8
 
-inherit go-module toolchain-funcs shell-completion
+inherit go-env go-module shell-completion sysroot
 
 DESCRIPTION="CLI to run commands against Kubernetes clusters"
 HOMEPAGE="https://kubernetes.io";
@@ -23,26 +23,25 @@ BDEPEND=">=dev-lang/go-1.25.4"
 QA_PRESTRIPPED=usr/bin/kubectl
 
 src_compile() {
+       local GOOS=$(go-env_goos)
+
        CGO_LDFLAGS="$(usex hardened '-fno-PIC ' '')" \
                emake -j1 GOFLAGS="${GOFLAGS}" GOLDFLAGS="" LDFLAGS="" 
FORCE_HOST_GO=yes \
+               KUBE_BUILD_PLATFORMS="${GOOS}/${GOARCH}" 
KUBE_${GOOS@U}_${GOARCH@U}_CC="${CC}" \
                WHAT=cmd/${PN}
 
-       if ! tc-is-cross-compiler; then
-               einfo "generating shell completion files"
-               _output/bin/${PN} completion bash > ${PN}.bash || die
-               _output/bin/${PN} completion zsh > ${PN}.zsh || die
-               _output/bin/${PN} completion fish > ${PN}.fish || die
-       fi
+       bin=_output/local/bin/${GOOS}/${GOARCH}/${PN}
+
+       einfo "generating shell completion files"
+       sysroot_try_run_prefixed ${bin} completion bash > ${PN}.bash || die
+       sysroot_try_run_prefixed ${bin} completion zsh > ${PN}.zsh || die
+       sysroot_try_run_prefixed ${bin} completion fish > ${PN}.fish || die
 }
 
 src_install() {
-       dobin _output/bin/${PN}
-
-       if ! tc-is-cross-compiler; then
-               newbashcomp ${PN}.bash ${PN}
-               newzshcomp ${PN}.zsh _${PN}
-               dofishcomp ${PN}.fish
-       else
-               ewarn "Shell completion files not installed! Install them 
manually with '${PN} completion --help'"
-       fi
+       dobin ${bin}
+
+       [[ -s ${PN}.bash ]] && newbashcomp ${PN}.bash ${PN}
+       [[ -s ${PN}.zsh ]] && newzshcomp ${PN}.zsh _${PN}
+       [[ -s ${PN}.fish ]] && dofishcomp ${PN}.fish
 }

Reply via email to