# Template file for 'libnvidia-container'
pkgname=libnvidia-container
version=1.11.0
revision=1
archs="x86_64"
hostmakedepends="tar xz curl bmake groff m4 pkg-config which go"
makedepends="rpcsvc-proto libcap-devel libseccomp-devel libtirpc-devel"
short_desc="NVIDIA container runtime library"
maintainer="Quentin Freimanis <quentinfreimanis@gmail.com>"
license="Apache-2.0"
homepage="https://github.com/NVIDIA/libnvidia-container"
distfiles="https://github.com/NVIDIA/libnvidia-container/archive/v${version}.tar.gz"
checksum=ff09fa96615d26b2484588bbd5a8e435fa9c2d931838c3de48c990892960d6b7

do_build() {
	make dist prefix=/usr REVISION=${version}
}

pre_install() {
	cd dist
	tar xvf ${pkgname}_${version}_${archs}.tar.xz
}

do_install() {
	vinstall dist/${pkgname}_${version}/usr/lib/${pkgname}.so.${version} 755 /usr/lib/
	vinstall dist/${pkgname}_${version}/usr/lib/${pkgname}-go.so.${version} 755 /usr/lib/
	ln -s /usr/lib/${pkgname}.so.${version} ${DESTDIR}/usr/lib/${pkgname}.so.${version%%.*}
	ln -s /usr/lib/${pkgname}-go.so.${version} ${DESTDIR}/usr/lib/${pkgname}-go.so.${version%%.*}

	vbin dist/${pkgname}_${version}/usr/bin/nvidia-container-cli
}

libnvidia-container-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vinstall dist/${sourcepkg}_${version}/usr/lib/${sourcepkg}.a 644 /usr/lib/
		ln -s /usr/lib/${pkgname}.so.${version} ${PKGDESTDIR}/usr/lib/${pkgname}.so
		ln -s /usr/lib/${pkgname}-go.so.${version} ${PKGDESTDIR}/usr/lib/${pkgname}-go.so
		vinstall dist/${sourcepkg}_${version}/usr/include/nvc.h 644 /usr/include/
		vinstall dist/${sourcepkg}_${version}/usr/lib/pkgconfig/${sourcepkg}.pc 644 /usr/lib/pkgconfig/
	}
}
