# Template file for 'cri-o'
pkgname=cri-o
version=1.36.3
revision=1
build_style=go
build_helper="qemu"
go_import_path="github.com/cri-o/cri-o"
go_package="${go_import_path}/cmd/crio"
go_build_tags="apparmor seccomp exclude_graphdriver_btrfs btrfs_noversion
 containers_image_ostree_stub"
conf_files="/etc/crictl.yaml /etc/crio/crio.conf /etc/crio/seccomp.json"
hostmakedepends="pkg-config go-md2man"
makedepends="gpgme-devel libglib-devel libseccomp-devel libapparmor-devel
 device-mapper-devel"
depends="conmon"
checkdepends="which"
short_desc="OCI-based implementation of Kubernetes Container Runtime Interface"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0"
homepage="https://github.com/cri-o/cri-o"
distfiles="https://github.com/cri-o/cri-o/archive/v${version}.tar.gz"
checksum=8f5a4e258729518a598f05e0733b540df4c6bd889b6cd9a783a868cdb5345399

do_check() {
	# test tag enables the *_test_inject.go helpers the test suite relies on
	go test -p "$XBPS_MAKEJOBS" -tags "test ${go_build_tags}" -ldflags "${go_ldflags}" \
		$(go list ./... | grep -Ev '/(internal/factory/container|server)$')

	# skip tests that need substrate not available in ci builds
	go test -p "$XBPS_MAKEJOBS" -tags "test ${go_build_tags}" -ldflags "${go_ldflags}" \
		-skip='TestAddOCIBindsRROMountsError/should_fail_to_add_an_RRO_mount_without_private_propagation' \
		./internal/factory/container ./server \
		-args -ginkgo.skip='memory limit to both swap and RAM|Limit and SwapLimit are set|Set Cgroupv2 resources'
}

post_build() {
	local _crio="$(find "${GOPATH}"/bin -name crio)"
	vtargetrun "${_crio}" --config="" config --default > crio.conf
	make docs
}

post_install() {
	make install.man PREFIX="${DESTDIR}/usr"
	vinstall crio.conf 644 etc/crio
	vinstall vendor/go.podman.io/common/pkg/seccomp/seccomp.json 644 etc/crio
	vinstall crictl.yaml 644 etc
	vinstall crio-umount.conf 644 usr/share/oci-umount/oci-umount.d
	vmkdir usr/share/examples/"${pkgname}"
	vcopy contrib/cni usr/share/examples/"${pkgname}"
}
