# Template file for 'podman'
pkgname=podman
version=5.8.3
revision=1
_container_libs_common=0.67.1
build_style=go
build_wrksrc=podman-${version}
go_import_path="github.com/containers/podman/v5"
go_package="${go_import_path}/cmd/podman ${go_import_path}/cmd/rootlessport"
go_build_tags="seccomp apparmor containers_image_ostree_stub cni libsqlite3"
hostmakedepends="pkg-config go-md2man python3 mdocml"
makedepends="gpgme-devel libseccomp-devel device-mapper-devel libbtrfs-devel sqlite-devel"
depends="runc conmon cni-plugins slirp4netns fuse-overlayfs containers-common
 containers.image containers.storage netavark passt"
checkdepends="qemu"
short_desc="Simple management tool for containers and images"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0"
homepage="https://podman.io/"
changelog="https://raw.githubusercontent.com/containers/podman/main/RELEASE_NOTES.md"
distfiles="https://github.com/containers/podman/archive/v${version}.tar.gz
 https://github.com/containers/container-libs/archive/refs/tags/common/v${_container_libs_common}.tar.gz"
checksum="c54a2ec4b4fb5577288992aaa78684397ec3552fb2d1234d910ec50097d05c0f
 5438aa7763acd6d0ddb39426bec20bc344c53161716d88a9d75ac1fed0172b64"

case $XBPS_TARGET_MACHINE in
	aarch64* | x86_64*) ;;
	*) make_check="no" ;; # Upstream only supports tests on aarch64 and x86_64
esac

post_build() {
	# Manually building podman-remote since we don't have per go_package go_build_tags.
	# Using `go build` instead of install since -o doesn't work with that.
	go build -p "$XBPS_MAKEJOBS" -mod=vendor -modcacherw -v \
		-tags "remote ${go_build_tags}" \
		-o podman-remote "${go_import_path}/cmd/podman"
	make docs
}

do_check() {
	rm -v cmd/quadlet/main_test.go pkg/systemd/quadlet/unitdirs_test.go # TODO fix this with something like export TESTFLAGS="--skip-package quadlet --skip-file quadlet"
	make .install.ginkgo
	make localunit
}

post_install() {
	vmkdir usr/libexec/podman
	mv "${DESTDIR}/usr/bin/rootlessport" "${DESTDIR}/usr/libexec/podman/rootlessport"
	make install.man DESTDIR="${DESTDIR}" PREFIX="/usr"
	make install.completions DESTDIR="${DESTDIR}" PREFIX="/usr"
	cp ${wrksrc}/container-libs-common-v${_container_libs_common}/common/pkg/config/containers.conf \
		containers.cgfs.conf
	vsed -i -e 's|#cgroup_manager = "systemd"|cgroup_manager = "cgroupfs"|g' \
		containers.cgfs.conf
	vinstall containers.cgfs.conf 644 usr/share/containers containers.conf
	vsv podman
	vsv podman-docker
	vbin podman-remote
	ln -sf podman ${DESTDIR}/usr/bin/podmansh
}
