app-emulation/cri-tools: apply Flatcar patches

Make use of the existing helpers provided by `coreos-go.eclass`.
To optimize the binary size of crictl, add "-X" to GO_LDFLAGS,
like "-X $(PROJECT)/pkg/version.Version=$(VERSION)" in the original
Makefile of cri-tools. We cannot follow way of Gentoo ebuilds like
`emake`, because Makefile of cri-tools does not allow users to pass in
${GOARCH}.

Add `arm64` to ACCEPTED_KEYWORDS.

Remove unnecessary files from installation, as well as the shell
completion eclass.
This commit is contained in:
Dongsu Park 2023-01-26 10:47:15 +01:00
parent c4cea36448
commit 40532081c3

View File

@ -3,32 +3,44 @@
EAPI=7
inherit bash-completion-r1 go-module
# Flatcar: remove bash-completion, inherit coreos-go
inherit go-module coreos-go
COREOS_GO_VERSION="go1.19"
COREOS_GO_PACKAGE="github.com/kubernetes-sigs/cri-tools"
COREOS_GO_MOD="vendor"
MY_PV="v${PV/_beta/-beta.}"
EGO_PN="${COREOS_GO_PACKAGE}"
DESCRIPTION="CLI and validation tools for Kubelet Container Runtime (CRI)"
HOMEPAGE="https://github.com/kubernetes-sigs/cri-tools"
SRC_URI="https://github.com/kubernetes-sigs/cri-tools/archive/v${PV}.tar.gz -> ${P}.tar.gz"
LICENSE="Apache-2.0 BSD BSD-2 CC-BY-SA-4.0 ISC MIT MPL-2.0"
SLOT="0"
KEYWORDS="~amd64"
# Flatcar: keyword arm64
KEYWORDS="amd64 arm64"
DEPEND="dev-lang/go"
S=${WORKDIR}/cri-tools-${PV}
RESTRICT+=" test"
src_compile() {
emake VERSION="${PV}"
./build/bin/crictl completion bash > "crictl.bash" || die
./build/bin/crictl completion zsh > "crictl.zsh" || die
# Flatcar: make use of the existing helpers provided by `coreos-go.eclass`.
# To optimize the binary size of crictl, add "-X" to GO_LDFLAGS,
# like "-X $(PROJECT)/pkg/version.Version=$(VERSION)" in the original
# Makefile of cri-tools. We cannot follow way of Gentoo ebuilds like `emake`,
# because Makefile of cri-tools does not allow users to pass in ${GOARCH}.
# Remove shell completions.
GO_LDFLAGS="-s -w -extldflags=-Wl,-z,now,-z,relro,-z,defs "
GO_LDFLAGS+="-X ${COREOS_GO_PACKAGE}/pkg/version.Version=${PV} "
go_build "${COREOS_GO_PACKAGE}/cmd/crictl"
}
src_install() {
dobin ./build/bin/crictl
newbashcomp crictl.bash crictl
insinto /usr/share/zsh/site-functions
newins crictl.zsh _crictl
# Flatcar: install only crictl binary, remove shell completions.
dobin "${GOBIN}/crictl"
dodoc -r docs {README,RELEASE,CHANGELOG,CONTRIBUTING}.md
}