# Maintainer: Rafael Ávila de Espíndola <rafael@espindo.la>
pkgname=virtiofsd
pkgver=1.11.1
pkgrel=0
pkgdesc="virtio-fs vhost-user device daemon"
url="https://gitlab.com/virtio-fs/virtiofsd"
# fails to build on 32-bit
arch="all !x86 !armhf !armv7"
license="Apache-2.0 AND BSD-3-Clause"
makedepends="
	cargo
	cargo-auditable
	libcap-ng-dev
	libseccomp-dev
	"
source="https://gitlab.com/virtio-fs/virtiofsd/-/archive/v$pkgver/virtiofsd-v$pkgver.tar.bz2"
builddir="$srcdir/virtiofsd-v$pkgver"
options="net"

# qemu doesn't ship this anymore, split to this project
provides="qemu-virtiofsd=$pkgver-r$pkgrel"
replaces="qemu-virtiofsd"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --frozen --release
}

package() {
	install -Dm755 target/release/virtiofsd \
		-t "$pkgdir"/usr/libexec/
	# Keep a symlink at the old install location just in case
	mkdir -p "$pkgdir"/usr/lib/qemu
	ln -s ../../libexec/virtiofsd "$pkgdir"/usr/lib/qemu

	install -Dm644 50-virtiofsd.json \
		-t "$pkgdir"/usr/share/qemu/vhost-user/
}

sha512sums="
d6abaa2e53cfff53ff8b934259a36b05d2f55d6df3d87e9865578db6d0c81ee68ec57d79a29163555abd90f6a4a5e288598ef0a457ce28167c623ac13015e2dd  virtiofsd-v1.11.1.tar.bz2
"
