# Template file for 'cri-o'
pkgname=cri-o
version=1.13.3
revision=4
build_style=go
go_import_path="github.com/kubernetes-sigs/cri-o"
go_package="${go_import_path}/cmd/crio ${go_import_path}/cmd/crio-config"
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"
short_desc="OCI-based implementation of Kubernetes Container Runtime Interface"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0"
homepage="https://github.com/kubernetes-sigs/cri-o"
distfiles="https://github.com/kubernetes-sigs/cri-o/archive/v${version}.tar.gz"
checksum=69c89094c5c03fa1cb58c11ccd7bdae7ba0da644d5f0124e0a9a508c548d1ba2

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" cri-o-devel"
fi

post_build() {
	cd conmon
	if [ "$CROSS_BUILD" ]; then
		crio-config
	else
		"${GOPATH}"/bin/crio-config
	fi
	cd ..
	CFLAGS+=' -fPIC' make -C conmon
	make -C pause
	if [ "$CROSS_BUILD" ]; then
		crio --config="" config --default > crio.conf
	else
		"${GOPATH}"/bin/crio --config="" config --default > crio.conf
	fi
	make docs
}

post_install() {
	vinstall bin/conmon 755 usr/libexec/crio
	vinstall bin/pause 755 usr/libexec/crio
	make install.man PREFIX="${DESTDIR}/usr"
	vinstall crio.conf 644 etc/crio
	vinstall 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}"
}

cri-o-devel_package() {
	short_desc+=" - development tools"
	depends="${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/bin/crio-config
	}
}
